Skip to main content

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()

Metadata

Release files for ping-game-theory-25 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ping-game-theory-25 0.1.3
File Size Uploaded
ping_game_theory_25-0.1.3.tar.gz 2.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ping-game-theory-25 0.1.3
File Interpreter ABI Platform
ping_game_theory_25-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 6.8 kB

Release files / ping_game_theory_25-0.1.3.tar.gz

Download URL ping_game_theory_25-0.1.3.tar.gz
Size 2.7 kB
Tags Source
SHA-256 checksum
How to use checksums
44dfbf6df21b710f54d11623a9c8aab727f8f5170781ab3f9fe4949d1f5cee42
BLAKE2b-256 checksum
How to use checksums
0f4fc8ff4bce4841ff76d5235587f33d39153dfbaa54b307765ff7a588921caa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.13

Release files / ping_game_theory_25-0.1.3-py3-none-any.whl

Download URL ping_game_theory_25-0.1.3-py3-none-any.whl
Size 4.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dda7e017546589492b2056d10e008d74098898059404f851ccdc588693be2d84
BLAKE2b-256 checksum
How to use checksums
c778aa5f2e44ae4b8a67dcdd4717e8e47e4687365168d90c1b6d53954857689a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.13

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page