chessai.agents.guard
1import chessai.core.action 2import chessai.core.agent 3import chessai.core.gamestate 4 5class GuardAgent(chessai.core.agent.Agent): 6 """ An agent that will capture a piece if possible, otherwise it will stay still. """ 7 8 def get_action(self, 9 state: chessai.core.gamestate.GameState) -> chessai.core.action.Action: 10 """ 11 Returns a stochastic aggressive action based on the game state. 12 """ 13 14 # Try to capture a piece. 15 legal_actions = state.get_legal_move_actions() 16 for action in legal_actions: 17 if (state.is_capture(action)): 18 return action 19 20 # If we couldn't find an action that is a capture, do nothing. 21 return chessai.core.action.NoneAction()
6class GuardAgent(chessai.core.agent.Agent): 7 """ An agent that will capture a piece if possible, otherwise it will stay still. """ 8 9 def get_action(self, 10 state: chessai.core.gamestate.GameState) -> chessai.core.action.Action: 11 """ 12 Returns a stochastic aggressive action based on the game state. 13 """ 14 15 # Try to capture a piece. 16 legal_actions = state.get_legal_move_actions() 17 for action in legal_actions: 18 if (state.is_capture(action)): 19 return action 20 21 # If we couldn't find an action that is a capture, do nothing. 22 return chessai.core.action.NoneAction()
An agent that will capture a piece if possible, otherwise it will stay still.
9 def get_action(self, 10 state: chessai.core.gamestate.GameState) -> chessai.core.action.Action: 11 """ 12 Returns a stochastic aggressive action based on the game state. 13 """ 14 15 # Try to capture a piece. 16 legal_actions = state.get_legal_move_actions() 17 for action in legal_actions: 18 if (state.is_capture(action)): 19 return action 20 21 # If we couldn't find an action that is a capture, do nothing. 22 return chessai.core.action.NoneAction()
Returns a stochastic aggressive action based on the game state.