agents.dummy_agent
1import asyncio 2import os 3import random 4import sys 5from typing import List, Optional 6 7# Add the parent directory to sys.path to allow running agents as scripts from the root 8sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) 9 10from agents.base_agent import BaseC4Agent 11 12 13class DummyC4Agent(BaseC4Agent): 14 """ 15 A completely random agent for Connect Four. 16 """ 17 18 async def deliberate(self, valid_actions: List[int]) -> Optional[int]: 19 """ 20 Picks a random valid column after a brief delay. 21 22 Args: 23 valid_actions: A list of valid column indices where a piece can be dropped. 24 25 Returns: 26 The chosen column index. 27 """ 28 # Add a tiny delay so human observers can watch the game unfold 29 await asyncio.sleep(0.5) 30 31 # Pick a random valid column 32 chosen_col: int = random.choice(valid_actions) 33 return chosen_col 34 35 36if __name__ == "__main__": 37 agent = DummyC4Agent() 38 asyncio.run(agent.run())
14class DummyC4Agent(BaseC4Agent): 15 """ 16 A completely random agent for Connect Four. 17 """ 18 19 async def deliberate(self, valid_actions: List[int]) -> Optional[int]: 20 """ 21 Picks a random valid column after a brief delay. 22 23 Args: 24 valid_actions: A list of valid column indices where a piece can be dropped. 25 26 Returns: 27 The chosen column index. 28 """ 29 # Add a tiny delay so human observers can watch the game unfold 30 await asyncio.sleep(0.5) 31 32 # Pick a random valid column 33 chosen_col: int = random.choice(valid_actions) 34 return chosen_col
A completely random agent for Connect Four.
async def
deliberate(self, valid_actions: List[int]) -> Optional[int]:
19 async def deliberate(self, valid_actions: List[int]) -> Optional[int]: 20 """ 21 Picks a random valid column after a brief delay. 22 23 Args: 24 valid_actions: A list of valid column indices where a piece can be dropped. 25 26 Returns: 27 The chosen column index. 28 """ 29 # Add a tiny delay so human observers can watch the game unfold 30 await asyncio.sleep(0.5) 31 32 # Pick a random valid column 33 chosen_col: int = random.choice(valid_actions) 34 return chosen_col
Picks a random valid column after a brief delay.
Args: valid_actions: A list of valid column indices where a piece can be dropped.
Returns: The chosen column index.