connect4
connect4 copied to clipboard
Environment to create new AI agents
The purpose of this changes is to have a more appropiate and tidy environment to develop new AI agents. It also contains an agent based on minimax algorithm.
New files
- game_AI_vs_AI: this file allows us to spectate a game between 2 agents
- agents: where all the different agents will be implemented. It contains an agent based on minimax algorithm wich uses a original heuristic based on the Odd-Even strategy of connect4. It also contains a random agent.
New feautures:
In ConnectGame:
New methods:
- make_movement
- play_game
- compare_agents
In GameBoard:
The changes made in this class have two objectives. The first one is to improve efficient (very useful for the future AI agents). The second one is to be able to know which squares verified that if a player had a piece in a given coordinate he would win (win squares). This will be very useful for future AI agents that calculate the heuristic of a board .
New attributes
- slots_filled. It makes more efficient to calculate ties
- p1_win_squares and p2_win_squares. A set with the coordinates of the win squares.
Methods changed
- drop_piece
- horizontal win
- vertical win
- diagonal win
- winning move
- tie move
New methods
- is_valid_coord
- _set_horizontal_win_squares
- _set_vertical_win_squares
- _set_diagonal_win_squares
- _set_win_square
- _analyze_square
In GameData:
New attributes
- winner
I will let you know about this PR asap.. have few things on my plate as of now.. btw thanks for the effort :)