Skip to main content

A Python bisca library

Project description

libbisca

A Python bisca library

Build Status Coverage Status Version PyPi

License Code style: black

libbisca is a Python bisca library. Bisca is a Portuguese trick-taking card game.

State: Alpha (still needs a lot of work)

This is a small hobby project. In the future I may write a BiscaAI (game engines) and a Bisca GUI (probably using tkinter) on top of this. Keeping them separate should allow anyone else to use libbisca (the game rules) without the rest.

Usage example (non-exhaustive)

>>> import libbisca as bisca

>>> state = bisca.get_state()

>>> state
State(hand_size=3, turn=South, stock=[5D, 6H, 5C, QD, AH, QH, KS, 6S, QS, 4C, 4S, 7H, 5H, 3C, AC, 2C, JD, KC, AD, 2D, 4H, KH, AS, KD, QC, 3D, 4D, 3S, JS, JC, 3H, 2S, 5S, 7S], trump=5D, players={North: PlayerState(hand=[7C, 2H, 7D], pile=[], score=0), South: PlayerState(hand=[6C, JH, 6D], pile=[], score=0)}, table=[])

>>> state.play(bisca.get_card("4D"))

>>> state
State(hand_size=3, turn=North, stock=[2C, 7D, QC, JC, 5S, 3H, 7S, JH, AH, 2H, 5C, 5D, QD, 7H, 5H, JS, 3S, 6H, JD, KH, KD, 6S, QS, KS, 3C, AD, 6D, KC, 4S, AC, 6C, AS, 4H, 4C], trump=2C, players={North: PlayerState(hand=[2S, QH, 3D], pile=[], score=0), South: PlayerState(hand=[2D, 7C], pile=[], score=0)}, table=[4D])

>>> state.do_random_move()
(QH, (South, 2, [4D, QH], [4C, 4H]))

>>> state
State(hand_size=3, turn=South, stock=[2C, 7D, QC, JC, 5S, 3H, 7S, JH, AH, 2H, 5C, 5D, QD, 7H, 5H, JS, 3S, 6H, JD, KH, KD, 6S, QS, KS, 3C, AD, 6D, KC, 4S, AC, 6C, AS], trump=2C, players={North: PlayerState(hand=[2S, 3D, 4H], pile=[], score=0), South: PlayerState(hand=[2D, 7C, 4C], pile=[[4D, QH]], score=2)}, table=[])

>>> state.do_random_rollout()

>>> state
State(hand_size=3, turn=North, stock=[], trump=2C, players={North: PlayerState(hand=[], pile=[[7H, 5C], [3C, 5D], [7D, 2C], [5S, 3H]], score=20), South: PlayerState(hand=[], pile=[[4D, QH], [2D, 2S], [7C, 3D], [AC, 4S], [AS, 6D], [KC, 6C], [KS, 4H], [AD, KD], [6S, JD], [4C, QS], [KH, 3S], [JS, QD], [5H, AH], [7S, JH], [JC, QC], [6H, 2H]], score=100)}, table=[])

>>> state.is_endgame()
True

>>> state.legal_moves
[]

>>> state.get_winner()
South

>>> state.players[bisca.Player.SOUTH].score
100

Development setup

Assuming you are working on linux and have pipenv installed, do:

make install
make unit

Release History

This project follows Keep a Changelog, so all information is in CHANGELOG.md.

License and author info

Nuno Miguel Casteloa da Silva -- NunoMCSilva@gmail.com

Distributed under the GPL 3.0 license. See LICENSE.md for more information.

https://github.com/NunoMCSilva/libbisca

Thanks

My thanks to all the projects, articles and code that inspired/helped me. There are too many to list here independently.

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

libbisca-0.1.2.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

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

libbisca-0.1.2-py3-none-any.whl (23.8 kB view details)

Uploaded Python 3

File details

Details for the file libbisca-0.1.2.tar.gz.

File metadata

  • Download URL: libbisca-0.1.2.tar.gz
  • Upload date:
  • Size: 9.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/42.0.1 requests-toolbelt/0.9.1 tqdm/4.44.1 CPython/3.7.3

File hashes

Hashes for libbisca-0.1.2.tar.gz
Algorithm Hash digest
SHA256 37e353a08399362ab48310a787a13b85a8cde4bf02ae5e22d17d34f9a73e0a03
MD5 5c339e799a3d76d63480d6177cf5a1c2
BLAKE2b-256 423cf85dbbac23e9391e6790460cf0d13c20472dd08406781bd9ad25d8766c2e

See more details on using hashes here.

File details

Details for the file libbisca-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: libbisca-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 23.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/42.0.1 requests-toolbelt/0.9.1 tqdm/4.44.1 CPython/3.7.3

File hashes

Hashes for libbisca-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e28c477088ce01e516f0cc8c6130129ef107ddb6360e3e959e1caa6af10c5dd3
MD5 91782ee14fa8a6868f1b4e130dd06546
BLAKE2b-256 957247cda5370ba87372dcd9fa70096a662e8874c6933440f51da3a484201003

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