Skip to main content

No project description provided

Project description

pyhandel

Python wrapper for building bots for the Kuh-Handel online bot coding challenge. Wraps the core Rust implementation via PyO3.

Installation

pip install pyhandel

Type stubs for better IDE support:

pip install pyhandel pyhandel-stubs

Usage

Implement the PlayerActions class and connect to the game server via Client:

import asyncio
from pyhandel.client import Client
from pyhandel.messages.actions import (
    AuctionDecision, Bidding, InitialTrade, NoAction,
    PlayerTurnDecision, SendMoney, TradeOpponentDecision,
)
from pyhandel.messages.game_updates import AuctionRound, GameUpdate, TradeOffer
from pyhandel.player.player_actions import PlayerActions


class Bot(PlayerActions):

    def setup(self):
        pass  # initialize your bot here

    def _draw_or_trade(self) -> PlayerTurnDecision:
        raise NotImplementedError

    def _trade(self) -> InitialTrade:
        raise NotImplementedError

    def _provide_bidding(self, state: AuctionRound) -> Bidding:
        raise NotImplementedError

    def _buy_or_sell(self, state: AuctionRound) -> AuctionDecision:
        raise NotImplementedError

    def _send_money_to_player(self, player: str, amount: int) -> SendMoney:
        raise NotImplementedError

    def _respond_to_trade(self, offer: TradeOffer) -> TradeOpponentDecision:
        raise NotImplementedError

    def _receive_game_update(self, update: GameUpdate) -> NoAction:
        raise NotImplementedError


async def run(client, num_rounds):
    for _ in range(num_rounds):
        await client.play_one_round("pvp_games")

if __name__ == "__main__":
    bot = Bot()
    bot.setup()
    client = Client("your_bot_name", "your_token", bot, "s://ufuk-guenes.com", True)
    asyncio.run(run(client, 1))

Documentation

License

MIT

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

pyhandel-0.2.3.tar.gz (42.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyhandel-0.2.3-cp313-cp313-manylinux_2_34_x86_64.whl (4.0 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

File details

Details for the file pyhandel-0.2.3.tar.gz.

File metadata

  • Download URL: pyhandel-0.2.3.tar.gz
  • Upload date:
  • Size: 42.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.9.6

File hashes

Hashes for pyhandel-0.2.3.tar.gz
Algorithm Hash digest
SHA256 928bf1f3feaa04343b77b629986ce17eb3ca99772e301ae7efe9d9d86360538a
MD5 72cffe35687e32a94e106e73c9cdf70c
BLAKE2b-256 1210d751f014210b4bdb9ca87f70741d0ac9e456a8cdd15dbc6613d5f63ab667

See more details on using hashes here.

File details

Details for the file pyhandel-0.2.3-cp313-cp313-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for pyhandel-0.2.3-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 b4be945903db966068b607659380dc53d03de85d723c364ba622669fd0358994
MD5 3a3968d47fb9a9cf3318b71d6aee4c2d
BLAKE2b-256 39e3bfb3b266a12ae3ae14d7c3d4f487ae1849752333978f14909493bc1fa572

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page