Exemple #1
0
    def get_missing_move(state):
        """ Get first valid move for this state that isn't in the DB
    or None if all are present """

        from botmoves import BotMoves
        from botmovesmapped import BotMovesMapped
        from move import Move, COLLAPSE
        valid = state.get_valid_moves()
        s = state.dumps()
        last_move = state.moves[-1]
        weight = last_move.weight + (1 if last_move.type != COLLAPSE else 0)
        if not BotMovesMapped.has(s):
            # Check for collapse
            if state.cycle_squares:
                # Append another valid move to the move string
                all = []
                for move in valid:
                    state.step(Move(2, weight, move[0], move[1]))
                    if state.outcome:
                        all.append(move)
                    else:
                        for a in state.get_valid_moves():
                            all.append('%s/%s' % (move, a))
                    state.unstep()
                valid = all
            # Look for all found moves or any variations in the DB
            for move in valid:
                if not BotMoves.find_state(s, move):
                    return move
        return None
Exemple #2
0
 def get_missing_move(state):
   """ Get first valid move for this state that isn't in the DB
   or None if all are present """
   
   from botmoves import BotMoves
   from botmovesmapped import BotMovesMapped
   from move import Move, COLLAPSE
   valid = state.get_valid_moves()
   s = state.dumps()
   last_move = state.moves[-1]
   weight = last_move.weight + (1 if last_move.type != COLLAPSE else 0)
   if not BotMovesMapped.has(s):
     # Check for collapse
     if state.cycle_squares:
       # Append another valid move to the move string
       all = []
       for move in valid:
         state.step(Move(2, weight, move[0], move[1]))
         if state.outcome:
           all.append(move)
         else:
           for a in state.get_valid_moves():
             all.append('%s/%s'%(move,a))
         state.unstep()
       valid = all
     # Look for all found moves or any variations in the DB
     for move in valid:
       if not BotMoves.find_state(s, move):
         return move
   return None
Exemple #3
0
 def has(state):
   """ returns True if state string found in valid moves mapped table,
   else False """
   
   from botmoves import BotMoves
   return bool(BotMoves.find_state(state, my=BotMovesMapped))