Skip to main content

Uruguayan Truco engine, simulator, and library

Project description

pytruco

pytruco is a pure Python Uruguayan Truco engine, simulator, and library.

Install

pip install pytruco

Example

from pytruco.pdt.partida import Partida

p = Partida(
    puntuacion    = 20,
    azules        = ["Alice", "Ariana"],
    rojos         = ["Bob", "Ben"],
    verbose       = True,
    limite_envido = 4
)

print(p)

print(p.cmd("alice envido"))
print(p.cmd("bob quiero"))
print(p.cmd("ariana truco"))
print(p.cmd("ben quiero"))

Random walker example

from pytruco.pdt.partida import Partida
from pytruco.pdt.chi import chis
import random

def random_action(p:Partida, allow_mazo=True):
  aas = chis(p, allow_mazo)
  aas = [aa for aa in aas if len(aa) > 0]
  aa = random.choice(aas)
  return random.choice(aa)

p = Partida(
    puntuacion    = 20,
    azules        = ["Alice", "Ariana"],
    rojos         = ["Bob", "Ben"],
    verbose       = True,
    limite_envido = 4
)

print(p)

while not p.terminada():
    a = random_action(p, allow_mazo=False)
    pkts = a.hacer(p)
    print(f"{a} -> {pkts}")

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

pytruco-0.1.1.tar.gz (53.6 kB view details)

Uploaded Source

Built Distribution

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

pytruco-0.1.1-py3-none-any.whl (48.5 kB view details)

Uploaded Python 3

File details

Details for the file pytruco-0.1.1.tar.gz.

File metadata

  • Download URL: pytruco-0.1.1.tar.gz
  • Upload date:
  • Size: 53.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.20

File hashes

Hashes for pytruco-0.1.1.tar.gz
Algorithm Hash digest
SHA256 6708d7cacb3a44a9eac0f19ac1be66fc6bae742cf764bb5d433530e8d1daa845
MD5 3976f7b7393d71b98e7f291a642085cc
BLAKE2b-256 49308d8e80bee9d7cf9bb8c24cd36fc0e8120e343b8bf81ccdc04da8dc0cb380

See more details on using hashes here.

File details

Details for the file pytruco-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pytruco-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 48.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.20

File hashes

Hashes for pytruco-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ad1407165f81af392b9eeed770409128a7826f60e962bfea684591317ae1ef52
MD5 f3c6aa49dc8cc9e8a8df76afff1bff00
BLAKE2b-256 5bb31afb656440a997571ddc72e394a5f0917b96604bb76855707a4e2e70b6f5

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