Skip to content

Instantly share code, notes, and snippets.

@DominoPivot
Last active November 4, 2018 07:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DominoPivot/1d7cd9c9160391fcf4d9df2554d5f370 to your computer and use it in GitHub Desktop.
Save DominoPivot/1d7cd9c9160391fcf4d9df2554d5f370 to your computer and use it in GitHub Desktop.
spymao - 0h Game Jam 2018 entry
import random
deck = None
hand = None
def speak(message="", penalty=""):
maxlen = max(len(message), len(penalty))
# pad both parts even
message = format(message, "<" + str(maxlen))
penalty = format(penalty, "<" + str(maxlen))
# split into padded lines
messages = [message[i:i+39] for i in range(0, len(message), 39)]
penalties = [penalty[i:i+39] for i in range(0, len(penalty), 39)]
text = "\n".join("{} {}".format(m, p) for m, p in zip(messages, penalties))
print(text)
def draw_card():
global hand
global deck
card = deck.pop()
deck.append(card)
speak("Drew the card: {}".format(card))
def ask(question, accepted):
while True:
ans = input(question)
if ans in accepted:
return ans
else:
speak(penalty="Invalid action. Draw a penalty card.")
ask("", ("draw",))
draw_card()
def make_deck():
values = ["A"] + [str(num) for num in range(2, 11)] + ["J", "Q", "K"]
cards = [(val, kind) for val in values for kind in "♥♦♣♠"] + [("Joker", "")] * 2
return cards
def main():
global hand
global deck
print("This game is played by entering commands exactly as told.")
print("The only thing I'm allowed to tell you about spymao is that I'm not allowed to talk about its rules.")
print("The game begins")
deck = make_deck() * 2
random.shuffle(deck)
hand = []
print("> The dealer distributes a card.")
ask("Draw card?", ("no"))
print("The game is over")
if __name__ == '__main__':
main()

spymao

The 0h game jam is a silly challenge where you have to code a game during the free hour you gain when daylight saving time ends. In my case, I worked on a game from 2am to 2am. Silliness aside, this challenge is actually quite difficult. You need to come up with a game that can be made within an hour, and at a time you're probably dead tired too.

I thought about making a text-based game since I was too ambitious over the past years. Python seemed like a good option, but I was a bit rusty and tired so I spent the first half hour of the jam fiddling with loops and strings. I learned how to pad and align strings in the process.

I decided to make a game akin to Mao. The only thing you're allowed to say about Mao is that you're not allowed to talk about its rules. The idea is that the player has to type commands to play the game but has no clue what they're supposed to type, and get a penalty whenever they do something wrong. Through trial and error the player figures out the rules and manages to play the game. The more the player plays and the more absurd they'll realize the rules are.

But alas, in the little amount of time I had, I only managed to program some basic IO and a tiny, tiny ruleset. It's still a nice POC and I now totally want to make this into a proper original game.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment