Skip to content

Commit

Permalink
Officially support two-stage-bot, Trigger CI
Browse files Browse the repository at this point in the history
  • Loading branch information
tae898 committed Nov 23, 2023
1 parent 742f014 commit 2e7ebe7
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/schnapsen/bots/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
from .ml_bot import MLDataBot, MLPlayingBot, train_ML_model
from .gui.guibot import SchnapsenServer
from .minimax import MiniMaxBot
from .two_stage_bot import TwoStageBot

__all__ = ["RandBot", "AlphaBetaBot", "RdeepBot", "MLDataBot", "MLPlayingBot", "train_ML_model", "SchnapsenServer", "MiniMaxBot"]
__all__ = ["RandBot", "AlphaBetaBot", "RdeepBot", "MLDataBot", "MLPlayingBot", "train_ML_model", "SchnapsenServer", "MiniMaxBot", "TwoStageBot"]
29 changes: 29 additions & 0 deletions src/schnapsen/bots/two_stage_bot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"""Two stage bot"""
from typing import Optional
from schnapsen.game import (
Bot,
Move,
PlayerPerspective,
GamePhase,
)


class TwoStageBot(Bot):
"""Bot which plays first the one, than the other startegy"""

def __init__(
self, bot1: Bot, bot2: Bot, name: Optional[str] = "ProbabilityBot"
) -> None:
super().__init__(name)
self.bot_phase1: Bot = bot1
self.bot_phase2: Bot = bot2

def get_move(
self, perspective: PlayerPerspective, leader_move: Optional[Move]
) -> Move:
if perspective.get_phase() == GamePhase.ONE:
return self.bot_phase1.get_move(perspective, leader_move)
elif perspective.get_phase() == GamePhase.TWO:
return self.bot_phase2.get_move(perspective, leader_move)
else:
raise AssertionError("Phase ain't right.")

0 comments on commit 2e7ebe7

Please sign in to comment.