Initial commit: Generator for Circus

This commit is contained in:
Alexandre CATTEAU 2024-04-28 18:56:21 +02:00
commit 737915cb3b
2 changed files with 38 additions and 0 deletions

6
README.md Normal file
View File

@ -0,0 +1,6 @@
# Ticket to Campaign
Tooling for running a campaign of Ticket to Ride Legacy: Legends of the West without altering the game material
### Components
* `data-generator.py` contains models to generate data for a campaign
* currently, only generates a Circus instance

32
data-generator.py Normal file
View File

@ -0,0 +1,32 @@
# Generation of data for a campaign of Ticket to Ride Legacy Legends of the West
# Imports
import random
# Class for Circus: list of <number> wagons, of the 5 colors
class Circus:
# There are:
# 4 wagons of each colors (until 2 players' stop)
# 2 wagons of each colors (until 3 players' stop)
# 2 wagons of each colors (until 4 players' stop)
# 2 wagons of each colors (until 5 players' stop)
# NOTE: In the original distribution, the same color never appears twice in a row
# We chose to remove this constraint, for the sake of simplicity
def __init__(self, playersNb):
wagonsPerColors = 2 * playersNb
colors = "blue", "green", "black", "red", "yellow"
remaining = {"blue": wagonsPerColors, "green": wagonsPerColors, "black": wagonsPerColors, "red": wagonsPerColors, "yellow": wagonsPerColors}
self.wagons = []
for n in range(0, 5 * wagonsPerColors):
color = colors[random.randint(0, 4)]
while remaining[color] == 0:
color = colors[random.randint(0, 4)]
self.wagons.append(color)
remaining[color] = remaining[color] - 1
#def next(): # returns next color (i.e., color that the player will get it they use circus)
myCircus = Circus(3)
print(myCircus.wagons)