shortdeck1.0
This commit is contained in:
41
shortdeck_arena/agent.py
Normal file
41
shortdeck_arena/agent.py
Normal file
@@ -0,0 +1,41 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .simulation import Simulation
|
||||
|
||||
|
||||
class Agent:
|
||||
def __init__(self, pid: int):
|
||||
self.pid = pid
|
||||
|
||||
def try_act(self, sim: 'Simulation'):
|
||||
return None
|
||||
|
||||
def __str__(self):
|
||||
return f"Agent({self.pid})"
|
||||
|
||||
|
||||
class HumanAgent(Agent):
|
||||
def try_act(self, sim: 'Simulation'):
|
||||
return None
|
||||
|
||||
def __str__(self):
|
||||
return "HumanAgent"
|
||||
|
||||
|
||||
class RandomAgent(Agent):
|
||||
def try_act(self, sim: 'Simulation'):
|
||||
import random
|
||||
info = sim.node_info()
|
||||
choices = ["fold", "call"]
|
||||
if info.get("bet_max", 0) > 0:
|
||||
choices.append("bet")
|
||||
|
||||
action = random.choice(choices)
|
||||
if action == "bet":
|
||||
amt = random.randint(max(1, info.get("bet_min", 1)), info.get("bet_max", 1))
|
||||
sim.apply_action(self.pid, "bet", amt)
|
||||
else:
|
||||
sim.apply_action(self.pid, action)
|
||||
Reference in New Issue
Block a user