agents.dummy_agent
1import asyncio 2import random 3from typing import List, Optional, Tuple 4 5from agents.base_agent import BaseOthelloAgent 6 7 8class DummyOthelloAgent(BaseOthelloAgent): 9 r""" 10 A simple Othello agent that makes random moves. 11 12 This agent follows a stochastic policy: 13 $P(a | s) = \frac{1}{|A(s)|}$ for all $a \in A(s)$, 14 where $A(s)$ is the set of valid actions in state $s$. 15 """ 16 17 async def deliberate( 18 self, board: List[List[int]], valid_actions: List[List[int]] 19 ) -> Optional[Tuple[int, int]]: 20 """ 21 Picks a random valid move from the available actions. 22 23 Args: 24 board: The current $8 \times 8$ game board. 25 valid_actions: A list of valid move coordinates $[x, y]$. 26 27 Returns: 28 The chosen move $(x, y)$ or None. 29 """ 30 # Add a tiny delay so humans can watch the game unfold 31 await asyncio.sleep(0.5) 32 33 if not valid_actions: 34 return ( 35 None # The server will handle turn-skipping if no actions are available 36 ) 37 38 # Pick a random valid coordinate 39 chosen_move = random.choice(valid_actions) 40 return (chosen_move[0], chosen_move[1]) 41 42 43if __name__ == "__main__": 44 agent = DummyOthelloAgent() 45 asyncio.run(agent.run())
9class DummyOthelloAgent(BaseOthelloAgent): 10 r""" 11 A simple Othello agent that makes random moves. 12 13 This agent follows a stochastic policy: 14 $P(a | s) = \frac{1}{|A(s)|}$ for all $a \in A(s)$, 15 where $A(s)$ is the set of valid actions in state $s$. 16 """ 17 18 async def deliberate( 19 self, board: List[List[int]], valid_actions: List[List[int]] 20 ) -> Optional[Tuple[int, int]]: 21 """ 22 Picks a random valid move from the available actions. 23 24 Args: 25 board: The current $8 \times 8$ game board. 26 valid_actions: A list of valid move coordinates $[x, y]$. 27 28 Returns: 29 The chosen move $(x, y)$ or None. 30 """ 31 # Add a tiny delay so humans can watch the game unfold 32 await asyncio.sleep(0.5) 33 34 if not valid_actions: 35 return ( 36 None # The server will handle turn-skipping if no actions are available 37 ) 38 39 # Pick a random valid coordinate 40 chosen_move = random.choice(valid_actions) 41 return (chosen_move[0], chosen_move[1])
A simple Othello agent that makes random moves.
This agent follows a stochastic policy: $P(a | s) = \frac{1}{|A(s)|}$ for all $a \in A(s)$, where $A(s)$ is the set of valid actions in state $s$.
async def
deliberate( self, board: List[List[int]], valid_actions: List[List[int]]) -> Optional[Tuple[int, int]]:
18 async def deliberate( 19 self, board: List[List[int]], valid_actions: List[List[int]] 20 ) -> Optional[Tuple[int, int]]: 21 """ 22 Picks a random valid move from the available actions. 23 24 Args: 25 board: The current $8 \times 8$ game board. 26 valid_actions: A list of valid move coordinates $[x, y]$. 27 28 Returns: 29 The chosen move $(x, y)$ or None. 30 """ 31 # Add a tiny delay so humans can watch the game unfold 32 await asyncio.sleep(0.5) 33 34 if not valid_actions: 35 return ( 36 None # The server will handle turn-skipping if no actions are available 37 ) 38 39 # Pick a random valid coordinate 40 chosen_move = random.choice(valid_actions) 41 return (chosen_move[0], chosen_move[1])
Picks a random valid move from the available actions.
Args: board: The current $8 imes 8$ game board. valid_actions: A list of valid move coordinates $[x, y]$.
Returns: The chosen move $(x, y)$ or None.