Game Logic algorithm