Skip to main content

Simulator of the child variant of the War card game

Project description

batamiaou

Test

Battle game simulator

Introduction

Bata-Miaou (or similarly Bata-Waf) is a child variant of the "War" card game where there is actually no strategy to win (players can’t do anything).

This project implements a game simulator through a python C extension (limited C API).

Installation

pip install batamiaou

Usage

from batamiaou import BatamiaouGame

# create a new game instance
game = BatamiaouGame()
# run a whole game (it stops when a player has no more cards)
# and returns the number of rounds
rounds = game.run()
# reset the game
game.reset()
# run a single round and returns 1 or 2 (the winning player)
round_winner = game.play()

Deck

A BatamiaouGame embeds a deck attribute that an array of bytes of size 36 (char[36]), that represents the 36 cards of the game.

The value of the i-th card is (i % 6) + 1 (value between 1 and 6).

The elements of deck are used as follows:

Content of deck[i] Value Meaning
0b0001 1 The card i is the player 1 main deck
0b0010 2 The card i is the player 2 main deck
0b0101 5 The card i is the player 1 discard deck
0b0110 6 The card i is the player 1 discard deck
0b0000 0 The card i is currently involved in a battle (generally not seen)

This deck can be read at any time between hands.

# deck is a `bytes` object of length 36
deck = game.deck()
# to get the integers
values = [v for v in map(int, deck)]

You can also use numpy to ease further deck analysis:

import numpy as np

deck = np.frombuffer(game.deck(), dtype=np.uint8)

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

batamiaou-0.1.0.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

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

batamiaou-0.1.0-cp36-abi3-manylinux1_x86_64.manylinux_2_5_x86_64.whl (19.4 kB view details)

Uploaded CPython 3.6+manylinux: glibc 2.5+ x86-64

File details

Details for the file batamiaou-0.1.0.tar.gz.

File metadata

  • Download URL: batamiaou-0.1.0.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for batamiaou-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f576710f86d018640e24e2896c21541795a0f4536830de463a4e5307b5c27dd8
MD5 54fdec550dd1aa638f8c2e716c9af2a0
BLAKE2b-256 9c5850599c2434438cc561d76aa3b2b144d9aae7ff87cb8e271e18af0c4e15ad

See more details on using hashes here.

File details

Details for the file batamiaou-0.1.0-cp36-abi3-manylinux1_x86_64.manylinux_2_5_x86_64.whl.

File metadata

  • Download URL: batamiaou-0.1.0-cp36-abi3-manylinux1_x86_64.manylinux_2_5_x86_64.whl
  • Upload date:
  • Size: 19.4 kB
  • Tags: CPython 3.6+, manylinux: glibc 2.5+ x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for batamiaou-0.1.0-cp36-abi3-manylinux1_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 92a65e6f8aa3d5eeabdc3b7c3b4cfd1222453b5565ebc6fb1d1e6d3ce5a8e729
MD5 eb66512ff440a16088068ab64d58f3c3
BLAKE2b-256 c1ed7b1aaa79c29a822aaf6f55a63f4e93764d58acd5f94956d2a918ddcd2c6d

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