Пример #1
0
 def move_up(self, matrix):
     if matrix in self.up_table:
         self.hits += 1
         return self.up_table[matrix]
     else:
         self.up_table[matrix] = game.move_up(matrix)
         return self.up_table[matrix]
Пример #2
0
def move_up(matrix):
    if matrix in UP_TABLE:
        global HITS
        HITS += 1
        return UP_TABLE[matrix]
    else:
        UP_TABLE[matrix] = game.move_up(matrix)
        return UP_TABLE[matrix]
Пример #3
0
def action(x,i):
    if i == 0:
        return game.move_up(x)
    elif i == 1:
        return game.move_down(x)
    elif i == 2:
        return game.move_left(x)
    elif i == 3:
        return game.move_right(x)
Пример #4
0
 def action(loc, board):
     if loc == 0:
         board = game.move_up(board)
     elif loc == 1:
         board = game.move_down(board)
     elif loc == 2:
         board = game.move_left(board)
     else:
         board = game.move_right(board)
     return board
Пример #5
0
def find_best_move(matrix):
    best_move = None
    best_score = -1
    matrixes = [game.move_up(matrix),
                game.move_down(matrix),
                game.move_left(matrix),
                game.move_right(matrix)]
    for i in range(4):
        if matrixes[i] != matrix:
            score = score_matrix(matrixes[i])
            if score >= best_score:
                best_score = score
                best_move = i
    return best_move, best_score
Пример #6
0
def action(x, board):
    comp = 0
    loc = 0
    for i in range(4):
        if x[i] > comp:
            loc = i
            comp = x[i]
    if loc == 0:
        board = game.move_up(board)
    elif loc == 1:
        board = game.move_down(board)
    elif loc == 2:
        board = game.move_left(board)
    else:
        board = game.move_right(board)
    return board