Example #1
0
 def kill_move(self, moves, board):
     if self.in_board(board) and self.can_kill_left(board):
         moves.append(
             Move((self.posX, self.posY),
                  (self.posX - 1, self.check_side(1)), False))
     if self.in_board(board) and self.can_kill_right(board):
         moves.append(
             Move((self.posX, self.posY),
                  (self.posX + 1, self.check_side(1)), False))
Example #2
0
 def move_down(self, moves, board):
     next_posY = self.posY + 1
     while next_posY <= 7 and board[next_posY][self.posX]['p'] == '':
         moves.append(
             Move((self.posX, self.posY), (self.posX, next_posY), False))
         next_posY += 1
     if next_posY <= 7 and board[next_posY][self.posX]['p'] != '' and board[
             next_posY][self.posX]['p'].side != self.side:
         moves.append(
             Move((self.posX, self.posY), (self.posX, next_posY), False))
Example #3
0
 def move_right(self, moves, board):
     next_posX = self.posX + 1
     while next_posX <= 7 and board[self.posY][next_posX]['p'] == '':
         moves.append(
             Move((self.posX, self.posY), (next_posX, self.posY), False))
         next_posX += 1
     if next_posX <= 7 and board[self.posY][next_posX]['p'] != '' and board[
             self.posY][next_posX]['p'].side != self.side:
         moves.append(
             Move((self.posX, self.posY), (next_posX, self.posY), False))
Example #4
0
 def move_left(self, moves, board):
     next_posX = self.posX - 1
     while next_posX >= 0 and board[self.posY][next_posX]['p'] == '':
         moves.append(
             Move((self.posX, self.posY), (next_posX, self.posY), False))
         next_posX -= 1
     if next_posX >= 0 and board[self.posY][next_posX]['p'] != '' and board[
             self.posY][next_posX]['p'].side != self.side:
         moves.append(
             Move((self.posX, self.posY), (next_posX, self.posY), False))
Example #5
0
 def move_up(self, moves, board):
     next_posY = self.posY - 1
     while next_posY >= 0 and board[next_posY][self.posX]['p'] == '':
         moves.append(
             Move((self.posX, self.posY), (self.posX, next_posY), False))
         next_posY -= 1
     if next_posY >= 0 and board[next_posY][self.posX]['p'] != '' and board[
             next_posY][self.posX]['p'].side != self.side:
         moves.append(
             Move((self.posX, self.posY), (self.posX, next_posY), False))
Example #6
0
 def move_forward(self, moves, board):
     if self.init_pos:
         if self.empty_cell(board, self.posX,
                            self.check_side(2)) and self.empty_cell(
                                board, self.posX, self.check_side(1)):
             moves.append(
                 Move((self.posX, self.posY),
                      (self.posX, self.check_side(2)), False))
         if self.empty_cell(board, self.posX, self.check_side(1)):
             moves.append(
                 Move((self.posX, self.posY),
                      (self.posX, self.check_side(1)), False))
     else:
         if self.in_board(board) and self.empty_cell(
                 board, self.posX, self.check_side(1)):
             moves.append(
                 Move((self.posX, self.posY),
                      (self.posX, self.check_side(1)), False))
Example #7
0
    def make_move(self):
        # output gives a number between 0 and 0.5
        # Takes a list of floats
        # Can loop through each move and add them together
        # I can represent this board as a list of 1's and 2's
        # 1s for ai and 2s for opponents
        # There needs to be 9 inputs

        output = self.net.activate(self.board.encode_board_state())
        row = convert_to_input(output[0])
        column = convert_to_input(output[1])
        print(row, column)
        print(output)
        return Move(row, column, self)
Example #8
0
 def randomize(self):
     valid_moves = self.board.get_valid_moves()
     move_set = valid_moves[randint(0, len(valid_moves))]
     return Move(move_set[0], move_set[1], self)
Example #9
0
 def make_move(self):
     row = int(input("Which row? ")) - 1
     column = int(input("Which column? ")) - 1
     return Move(row, column, self)