boardgame2vec/gothok/init

37 lines
903 B
Plaintext
Raw Normal View History

2018-01-28 00:12:39 +00:00
#!/usr/bin/env python
import capnp
import state_capnp as game
import random
# First let us create all the cards in the game
state = game.State.new_message()
# 0-8 indexes as per state.capnp
2018-01-28 00:22:14 +00:00
# TODO: Read the strings out of the state definition
2018-01-28 00:12:39 +00:00
houses = ["empty", "varys", "tully", "tyrell", "baratheon", "targaryen", "lannister", "greyjoy", "stark"]
cards = []
2018-03-10 20:18:22 +00:00
for x in range(1, 9):
for y in range(0, x):
2018-01-28 00:12:39 +00:00
card = game.Card.new_message()
card.house = houses[x]
cards.append(card)
pass
random.shuffle(cards)
2018-01-28 00:22:14 +00:00
cardlist = state.init('cardlist', 36)
2018-01-28 00:12:39 +00:00
for index, card in enumerate(cards):
location = game.Location.new_message()
2018-01-28 00:22:14 +00:00
location.board.x = index / 6
2018-03-03 22:11:11 +00:00
location.board.y = index % 6
2018-01-28 00:22:14 +00:00
card.location = location
cardlist[index] = card
# Now we have an initial state of the game, write it down
f = open('state.bin', 'w+b')
2018-01-28 00:23:44 +00:00
state.write_packed(f)
2018-03-03 22:11:11 +00:00
f.close()