agents.dummy_agent
1import asyncio 2import random 3from typing import List, Optional, Tuple, Union 4 5from agents.base_agent import BaseUTTTAgent 6 7 8class DummyUTTTAgent(BaseUTTTAgent): 9 """ 10 A simple Ultimate Tic-Tac-Toe agent that picks moves randomly. 11 """ 12 13 async def deliberate( 14 self, 15 board: List[List[int]], 16 macro_board: List[List[int]], 17 active_macro: Optional[List[int]], 18 valid_actions: List[List[int]], 19 ) -> Optional[Union[List[int], Tuple[int, int]]]: 20 """ 21 Randomly selects a move from the available valid actions. 22 23 Args: 24 board (List[List[int]]): The current 9x9 board state. 25 macro_board (List[List[int]]): The current 3x3 macro board state. 26 active_macro (Optional[List[int]]): The active macro board coordinates [my, mx]. 27 valid_actions (List[List[int]]): A list of valid moves [x, y]. 28 29 Returns: 30 Optional[Union[List[int], Tuple[int, int]]]: The chosen move [x, y] or None. 31 """ 32 await asyncio.sleep(0.5) 33 if not valid_actions: 34 return None 35 return random.choice(valid_actions) 36 37 38if __name__ == "__main__": 39 agent = DummyUTTTAgent() 40 asyncio.run(agent.run())
9class DummyUTTTAgent(BaseUTTTAgent): 10 """ 11 A simple Ultimate Tic-Tac-Toe agent that picks moves randomly. 12 """ 13 14 async def deliberate( 15 self, 16 board: List[List[int]], 17 macro_board: List[List[int]], 18 active_macro: Optional[List[int]], 19 valid_actions: List[List[int]], 20 ) -> Optional[Union[List[int], Tuple[int, int]]]: 21 """ 22 Randomly selects a move from the available valid actions. 23 24 Args: 25 board (List[List[int]]): The current 9x9 board state. 26 macro_board (List[List[int]]): The current 3x3 macro board state. 27 active_macro (Optional[List[int]]): The active macro board coordinates [my, mx]. 28 valid_actions (List[List[int]]): A list of valid moves [x, y]. 29 30 Returns: 31 Optional[Union[List[int], Tuple[int, int]]]: The chosen move [x, y] or None. 32 """ 33 await asyncio.sleep(0.5) 34 if not valid_actions: 35 return None 36 return random.choice(valid_actions)
A simple Ultimate Tic-Tac-Toe agent that picks moves randomly.
async def
deliberate( self, board: List[List[int]], macro_board: List[List[int]], active_macro: Optional[List[int]], valid_actions: List[List[int]]) -> Union[List[int], Tuple[int, int], NoneType]:
14 async def deliberate( 15 self, 16 board: List[List[int]], 17 macro_board: List[List[int]], 18 active_macro: Optional[List[int]], 19 valid_actions: List[List[int]], 20 ) -> Optional[Union[List[int], Tuple[int, int]]]: 21 """ 22 Randomly selects a move from the available valid actions. 23 24 Args: 25 board (List[List[int]]): The current 9x9 board state. 26 macro_board (List[List[int]]): The current 3x3 macro board state. 27 active_macro (Optional[List[int]]): The active macro board coordinates [my, mx]. 28 valid_actions (List[List[int]]): A list of valid moves [x, y]. 29 30 Returns: 31 Optional[Union[List[int], Tuple[int, int]]]: The chosen move [x, y] or None. 32 """ 33 await asyncio.sleep(0.5) 34 if not valid_actions: 35 return None 36 return random.choice(valid_actions)
Randomly selects a move from the available valid actions.
Args: board (List[List[int]]): The current 9x9 board state. macro_board (List[List[int]]): The current 3x3 macro board state. active_macro (Optional[List[int]]): The active macro board coordinates [my, mx]. valid_actions (List[List[int]]): A list of valid moves [x, y].
Returns: Optional[Union[List[int], Tuple[int, int]]]: The chosen move [x, y] or None.