shortdeck1.0

This commit is contained in:
2025-09-30 18:09:49 +08:00
commit ee95b8e049
24 changed files with 532 additions and 0 deletions

41
shortdeck_arena/agent.py Normal file
View 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)