code: def loop(self):
          
          pause_key = self.board.PAUSE
          margins = {'left': 4, 'top': 4, 'bottom': 4}
  
          atexit.register(self.showCursor)
  
          try:
              self.hideCursor()
              while True:
                  self.clearScreen()
                  print(self.__str__(margins=margins))
                  if self.board.won() or not self.board.canMove():
                      break
                  m = self.readMove()
  
                  if m == pause_key:
                      self.saveBestScore()
                      if self.store():
                          print("Game successfully saved. "
                                "Resume it with `term2048 --resume`.")
                          return self.score
  
                      print("An error ocurred while saving your game.")
                      return None
  
                  self.incScore(self.board.move(m))
  
          except KeyboardInterrupt:
              self.saveBestScore()
              return None
  
          self.saveBestScore()
          print('You won!' if self.board.won() else 'Game Over')
          return self.score
docs: main game loop. returns the final score.