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.
import random # set up our maximum and minimum number of blocksMAXBLOCKS=100MINBLOCKS=0 # set up the initial number of blocks in the toweruserBlocks=50 # count how many cards are dealt in the gamedealCount=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 withprint "You start with", userBlocks, "blocks.\n"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 enterprint "\n\n" # while the players amount of blocks is within the limitswhile(userBlocksMINBLOCKS): # 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): print "added to", userBlocks+=blockValue else: # card is odd, so subtract! print "subtracted from", userBlocks-=blockValue print "your tower." # if we're still within our limits, inform the player of their # current block total... if(userBlocks>MINBLOCKS and userBlocksMINBLOCKS):
# 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):
print "added to",
userBlocks+=blockValue
else: # card is odd, so subtract!
print "subtracted from",
userBlocks-=blockValue
print "your tower."
# if we're still within our limits, inform the player of their
# current block total...
if(userBlocks>MINBLOCKS and userBlocks