I have got this bit of code for a simple game and i need annotate and can someone explain to me the processes which are occuring.

# set up our maximum and minimum number of blocks
MAXBLOCKS=100
MINBLOCKS=0

# set up the initial number of blocks in the tower
userBlocks=50

# count how many cards are dealt in the game
dealCount=0

# some instructions:
print "The aim is to get 100 or more blocks in your tower."
print "The computer will randomly select a card for you (1-10)."
print "The value of the card will affect your towers height."
print "Even numbers add blocks, odd numbers remove blocks."
print "Cards are worth the following:"
print " Card value - Block Value"
print "================================"
print " 1,2 - +/- 05"
print " 3,4 - +/- 10"
print " 5,6 - +/- 15"
print " 7,8 - +/- 20"
print " 9,10 - +/- 25\n"

# let the user know how many blocks they're starting with
print "Will you be lucky??"
dummy = raw_input("Press enter to start drawing cards and find out...\n")

# create a little space once user has pressed enter
print "\n\n"

# while the players amount of blocks is within the limits
while(userBlocks<MAXBLOCKS and userBlocks>MINBLOCKS):

# Deal a card and show it to the user
card = random.randrange(1,10)
print "The card drawn is:", card

#now we'll get the blockValue of the card
blockValue=0;
if ( card==1 or card==2):
blockValue=5
elif (card==3 or card==4):
blockValue=10
elif (card==5 or card==6):
blockValue=15
elif (card==7 or card==8):
blockValue=20
else:
blockValue=25

#now should we add or subtract?
print blockValue, "points have been",

# if card value is even, add the blockvalue to the users blocks
if(card%2==0):
userBlocks+=blockValue
else: # card is odd, so subtract!
print "subtracted from",
userBlocks-=blockValue

# if we're still within our limits, inform the player of their
# current block total...
if(userBlocks>MINBLOCKS and userBlocks<MAXBLOCKS):
print "You now have", userBlocks, "blocks in your tower!\n"

# increment the deal counter
dealCount+=1

# end of game
print "GAME OVER after", dealCount, "deals!"

# if users total was MINBLOCKS or less
if userBlocks <= MINBLOCKS:
print "You lost all of your blocks! You lose!"
else: #user must have won!
print "You won! Your tower is", userBlocks, "high!"

First of all, if please wrap any code with the code-tags so it's formatted and we can read it. Second, are you asking for an explanation of how the game works or how the code works?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.