Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Officially support two-stage-bot, Trigger CI #107

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you remove this default value?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops sorry . removed!

) -> 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.")
Loading