Strategická: Dodělání abstraktní třídy pro herní logiku
This commit is contained in:
parent
559a43afdc
commit
3cb438254b
1 changed files with 22 additions and 7 deletions
|
@ -1,13 +1,28 @@
|
|||
from typing import Any, List, Tuple, Union, Optional
|
||||
|
||||
class Logic():
|
||||
def __init__(self, teams_count, configuration):
|
||||
pass
|
||||
logic_by_mode = {}
|
||||
def add_logic(cls):
|
||||
logic_by_mode[cls.__name__.lower()] = cls
|
||||
|
||||
def zero_state(self):
|
||||
class Logic:
|
||||
def __init__(self, teams_count: int, configuration: Any):
|
||||
self.teams_count = teams_count
|
||||
self.configuration = configuration
|
||||
|
||||
def zero_state(self) -> Any:
|
||||
return {}
|
||||
|
||||
def step(self, actions):
|
||||
pass
|
||||
def step(self, state: Any, actions: List[Optional[Any]], round_id: int) -> Tuple[Any, List[int]]:
|
||||
return {}, [0] * teams_count # new_state, add_points for each team
|
||||
|
||||
def validate_step(self, state: Any, team_id: int, action: Any, round_id: int) -> Union[None, Any]:
|
||||
return None # Bez chyby
|
||||
# return {"status": "warning", ... } # Drobná chyba, ale tah provedu
|
||||
# throw Exception("Chybí povinná ...") # Zásadní chyba, tah neuznán
|
||||
# Když používají našeho klienta, tak by se toto nemělo stát
|
||||
|
||||
@add_logic
|
||||
class Occupy(Logic):
|
||||
pass
|
||||
|
||||
|
||||
logic_by_mode = {"base": Logic}
|
||||
|
|
Loading…
Reference in a new issue