Skip to content

Instantly share code, notes, and snippets.

@gulnara
gulnara / gist:6100119
Created July 28, 2013 20:32
nested dictionary solution
import pprint
def nested_tree(edges):
nested = {}
for i in edges:
key = i[0]
value = {}
temp = i[1]
@gulnara
gulnara / guessing_game.uni
Created May 9, 2013 18:01
guessing game in Unicorn
show "What's your name?"
name <- string_prompt
show "Hello ", name
show "Let's play a game! Pick any number between 1 and 20."
show "You have 5 tries!"
@gulnara
gulnara / gist:5432870
Created April 22, 2013 06:42
initial grammar for Unicorn
file_input: stmt_list ENDMARKER
stmt_list: (NEWLINE | stmt)*
stmt: simple_stmt | compound_stmt
simple_stmt: print_stmt | assignment
print_stmt: 'show' (atom)+
@gulnara
gulnara / gist:5392641
Created April 16, 2013 01:23
hangman game rewritten with Unicorn
list HANGMAN
HANGMAN:0 <- '''
+---+
| |
|
|
|
|
========='''
@gulnara
gulnara / gist:5384900
Last active December 16, 2015 05:29
simple guessing game in my language
#assignment is done via <-, equality is id with only one =
prompt <- '>'
#printing is done via show
show 'What's your name?'
#the input from user is taken via user_input = raw_input in python
@gulnara
gulnara / eat the boy
Created March 14, 2013 04:41
eat the boy in the princess game
target_el = GAME_BOARD.get_el(self.x, self.y)
if target_el == PLAYER:
global GAME_OVER
GAME_OVER = True
GAME_BOARD.draw_msg("You've been eaten! Ha Ha Ha!")
self.board.set_el(self.x, self.y, self)
_____
def keyboard_handler():
@gulnara
gulnara / gist:5158829
Last active December 14, 2015 22:29
push rocks in the princess_game
class Rock(GameElement):
IMAGE = "Rock"
SOLID = True
def interact(self, player):
del_x = player.x - self.x
del_y = player.y - self.y
next_x = self.x - del_x
next_y = self.y - del_y
@gulnara
gulnara / guard
Last active December 14, 2015 22:29
guard protecting the princess in my python game
class Girl(GameElement):
IMAGE = "Girl"
SOLID = True
def __init__(self):
GameElement.__init__(self)
self.last_move = 0
self.velocity_y = 1
def update(self, dt):