Finds if the game is over.

    :type: position: Board
    :rtype: bool
329609
def no_moves(position):
    
    return position.no_moves(color.white) \
        or position.no_moves(color.black)
461332
def finish(self):
        """"""
        self._my_map['over'] = True  # finished == over?
        self._my_map['completionTime'] = DateTime.utcnow()
        self._save()
1130889
def finish(self, msg=None):
        
        if self._finished or self.disable:
            return        
        self._finished = True
        if msg is not None:
            self(msg)
        self._new_msg("< Exiting %s, total time: %0.4f ms", 
                      self._name, (ptime.time() - self._firstTime) * 1000)
        type(self)._depth -= 1
        if self._depth < 1:
            self.flush()
580868
def log_player_ends_turn(self, player):
        
        seconds_delta = (datetime.datetime.now() - self._latest_timestamp).total_seconds()
        self._logln('{0} ends turn after {1}s'.format(player.color, round(seconds_delta)))
        self._latest_timestamp = datetime.datetime.now()
1240367
def finish(self):
        
        if self.state is not State.NORMAL:
            raise ReadError(f'EOF while in {self.state.name} state')
        if self.stack:
            top = self.stack[-1]
            top.raise_unclosed_error()
583673
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
537123
def end(self) -> "GameNode":
        """"""
        node = self

        while node.variations:
            node = node.variations[0]

        return node
618159
def check_board(self):
        """"""
        num_mines = np.sum(self.info_map == 12)
        num_undiscovered = np.sum(self.info_map == 11)
        num_questioned = np.sum(self.info_map == 10)

        if num_mines > 0:
            return 0
        elif np.array_equal(self.info_map == 9, self.mine_map):
            return 1
        elif num_undiscovered > 0 or num_questioned > 0:
            return 2
514369
def tick(self):
        """"""
        for npc in self.npcs:
            self.move_entity(npc, *npc.towards(self.player))
        for entity1, entity2 in itertools.combinations(self.entities, 2):
            if (entity1.x, entity1.y) == (entity2.x, entity2.y):
                if self.player in (entity1, entity2):
                    return 'you lost on turn %d' % self.turn
                entity1.die()
                entity2.die()

        if all(npc.speed == 0 for npc in self.npcs):
            return 'you won on turn %d' % self.turn
        self.turn += 1
        if self.turn % 20 == 0:
            self.player.speed = max(1, self.player.speed - 1)
            self.player.display = on_blue(green(bold(unicode_str(self.player.speed))))
196535
def _watchdog(self):
        
        if not self.is_alive:
            logger.debug("Player has already terminated.")
            self._exit_event.set()
            return
        logger.debug("Watching %s[%d]",
                     self._player_command, self.sub_proc.pid)
        returncode = self.sub_proc.wait()
        logger.debug("%s[%d] exit with code %d",
                     self._player_command, self.sub_proc.pid, returncode)
        self._exit_event.set()
1311593
def capture(board):
    
    game = Game()
    v = (0, 0)
    stub_actor = base.Actor('capture', v, v, v, v, v, v, v, v, v)
    root = base.State(board, stub_actor, stub_actor,
                      turn=1, actions_remaining=1)
    solution_node = None
    for eot in game.all_ends_of_turn(root):
        # check for a solution
        if eot.is_mana_drain:  # quick check before checking whole board
            if eot.parent.board.is_empty():
                solution_node = eot
                break
    # if solution found, build the list of swaps
    solution_sequence = list()  # empty sequence (no solution) by default
    if solution_node:
        node = solution_node
        while node:
            # record each swap in the path to the root
            if not isinstance(node, base.Swap):
                node = node.parent
                continue
            summary = base.Summary(node.parent.board, node.position_pair,
                                   None, None, None)
            solution_sequence.append(summary)
            node = node.parent
    return tuple(reversed(solution_sequence))
634787
def gameloop(self):
        
        try:
            while True:
                self.handle_events()
                self.update()
                self.render()
        except KeyboardInterrupt:
            pass
965767
function() {
        // Compute the amount of play left to go
        t.playLeft = t.playEnd - Date.now();

        // Done playing
        if (t.playLeft <= 0) {
          clearInterval(t.timer);
          t.next();
        }

        // Set the progress bar width
        t.setProgress();
      }
51872
async def stop(self, wait_for_completion=True):
        
        await self.set_position(
            position=CurrentPosition(),
            wait_for_completion=wait_for_completion)
1263363
def board(self, *, _cache: bool = False) -> chess.Board:
        
        return self.headers.board()
764754
def track_end(self):
        
        self.__tracking = False
        changes = self.__changes
        self.__changes = {}
        return changes
843059
def is_touched(self, position):
        
        return position[0] >= self.position[0] and position[0] <= self.position[0]+ self.size[0]