write Game logic