Driver Code for @ping/game-theory-25
Project description
This package contains simple driver code + testing functionality for @ping/game-theory-25
Types
Move (Enum)
class Move(StrEnum):
ROCK = "ROCK"
PAPER = "PAPER"
SCISSOR = "SCISSOR"
Represents a single move in the game.
HistoryEntry (Dataclass)
@dataclass
class HistoryEntry:
self: Move
other: Move
Represents the result of one round of play between two strategies.
| Field | Type | Meaning |
|---|---|---|
self |
Move |
The move played by this strategy |
other |
Move |
The move played by the opponent |
History (Type Alias)
History = Tuple[HistoryEntry, ...]
A read-only sequence of all previous rounds. Each element is a HistoryEntry. The most recent round is at the end of the tuple.
Strategy (Abstract Base Class)
class Strategy(ABC):
@abstractmethod
def begin(self) -> Move:
...
@abstractmethod
def turn(self, history: History) -> Move:
...
Base class for all strategies (bots). Every strategy must implement two methods:
| Method | Called When | Purpose |
|---|---|---|
begin() |
Before the first round | Returns the first move |
turn(history) |
Every round after the first | Returns the next move based on previous history |
Any class that does not implement both methods cannot be instantiated.
Example Strategy
class ILoveRocks(Strategy):
def __init__(self) -> None:
self.author_netid = "lm742"
self.strategy_name = "ILoveRocks"
self.strategy_desc = "I really love rocks"
def begin(self) -> Move:
return Move.ROCK
def turn(self, history: History) -> Move:
return Move.ROCK
Strategy Tester
To ensure every strategy follows the required interface and runs efficiently, the project includes a built-in tester: StrategyTester
The tester automatically checks:
| Check | What it verifies |
|---|---|
| Initialization | Your strategy's __init__ runs without errors |
| Return types | begin() and turn() must always return a valid Move |
| No exceptions | Your strategy must never crash during play |
| Performance | Must complete 10,000 rounds within 60 seconds |
If your strategy passess all checks, you will see:
✅ PASS: 10000 rounds in X.XX seconds
How to Test your Strategy
You must pass in your strategy class without instantiating it
if __name__ == "__main__":
tester = StrategyTester(ILoveRocks)
tester.run()
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ping_game_theory_25-0.1.1.tar.gz.
File metadata
- Download URL: ping_game_theory_25-0.1.1.tar.gz
- Upload date:
- Size: 2.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
46e157736c4c7f46abc3d636292da5ef4bb78aaccb45943d746a3bc996583972
|
|
| MD5 |
e43372ec7e00bb31b887f8811df96188
|
|
| BLAKE2b-256 |
317e9366be5ac0b52529b564c45d23cbcf2917733a1555b59b1d0199f3597a53
|
File details
Details for the file ping_game_theory_25-0.1.1-py3-none-any.whl.
File metadata
- Download URL: ping_game_theory_25-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c77d0ccdca1e88764bbd44203f26858af9e475a53af45ff76551cd703328ef6
|
|
| MD5 |
ff8ed0e64cc87adb53e847c0de9ecdff
|
|
| BLAKE2b-256 |
6e981d7435aa5fbf71969d6bcbeb0d66a3d284eee8fe19384aa63b75bdef1e89
|