Base class
AgentBase
connectFourLab.game.agents.basicAgents.AgentBase()
Base class Agent
To inherit from this class it's required to implement
the action method
def action(self, board): # choose a column based in a given board return chosen_column # 0-6
Attributes
name- str, required, name of the agentdescription- str, required, description of the agentkind- str, required, category of the agentmodel_key- str, required for agents who uses neural network modelsclock_management- bool, optional, defaultFalse(*)- flag that indicates whether or not the agent can manage a time limit game
require_nn_model- bool, optional, defaultFalse(*)- flag that indicates whether or not the agent needs a neural network model
(*) - only necessary in the app interface
Saving the data
You can easily save the data from all turns of the game
using save all data will be saved separately in:
data_scenario- state of the boarddata_action- taken actiondata_reward- attributed reward
def action(self, board): choice = self.random_choice(board) self.save(board, choice) return choice
Exception
BadImplementation- some class didn't implemented the required method(s)
Clock management
If the game is time limited the update_clock will be
called every turn and you will be able to manage the
Timer (see Timer) in self.clock.
Using Neural Networks
To use neural network you need a Trainer which have to create and train a model for the agent.
The trained models are stored in the game/models/ folder.
Example
MCTSNN- Monte Carlo Tree Search with Neural Network implementation - see documentation