Chess
agent.h
Go to the documentation of this file.
1 
8 /* */
9 #include <vector>
10 
11 #include "chessboard.h"
12 
14 class Node {
15  public:
16  Node(Chessboard state, std::pair<int, int> move) : board_state(state), move(move), score(0) {}
18  void reset_tree_recursive();
19 
20  Chessboard board_state;
21  std::pair<int, int> move;
22  int score;
23  std::vector<Node *> children;
24 
25  private:
26  Node(Node &&other) = delete;
27  Node &operator=(Node &&other) = delete;
28 };
29 
31 class Agent {
32  public:
33  Agent(Chessboard initial_board);
34  Node *root;
35  std::pair<int, int> find_best_move(int depth);
36 
38  void reset_tree(Chessboard state);
39 
40  private:
41  void initialize_piece_structure_bonus();
42  std::vector<std::pair<int, int>> generate_possible_moves(Node *node, bool b_team);
43 
45  void generate_tree(Node *node, int depth, bool b_team);
47  int minimax(Node *node, int depth, int alpha, int beta, bool maximizingPlayer);
48  int min(int a, int b);
49  int max(int a, int b);
50 
52  int evaluate(Chessboard state);
53 
55  std::vector<int> get_piece_structure(Piece piece);
56  int get_piece_value(Type type);
57 
59  std::vector<int> piece_values;
60 
66  std::vector<std::vector<int>> piece_structures;
67  std::vector<int> pawn_structure_white;
68  std::vector<int> pawn_structure_black;
69  std::vector<int> knight_structure_white;
70  std::vector<int> knight_structure_black;
71  std::vector<int> bishop_structure_white;
72  std::vector<int> bishop_structure_black;
73  std::vector<int> rook_structure_white;
74  std::vector<int> rook_structure_black;
75  std::vector<int> king_structure_white;
76  std::vector<int> king_structure_black;
77  std::vector<int> queen_structure_white;
78  std::vector<int> queen_structure_black;
79 
85  std::vector<int> end_king_structure_white;
86  std::vector<int> end_king_structure_black;
87 
88  Agent(const Agent &other) = delete;
89  Agent &operator=(const Agent &other) = delete;
90  Agent(Agent &&other) = delete;
91  Agent &operator=(Agent &&other) = delete;
92 };
Class structure for the pieces that fill a game state&#39;s board.
Definition: piece.h:31
The Node structure is what makes up the tree of game states/moves traversed within Agent...
Definition: agent.h:14
void reset_tree_recursive()
clears out the tree created for the previous move&#39;s game state recursively
Definition: agent.cpp:308
Used to create, store, and make changes to a game state.
Definition: chessboard.h:24
Class used to programmatically produce a Chess move.
Definition: agent.h:31
Creates, stores, and makes changes to data for a game state.