Code hacks

From Armagetron
Revision as of 00:07, 31 October 2005 by TiTnAsS (talk | contribs)

From time to time people do various hacks to the code or write various scripts and programs to support the game. We'll try to collect them here so you can use them too. If you have a hack you'd like to add, just add it here. For it to format correctly, put

<nowiki> 
"<code> <pre> 
Copy paste your script here, in the space inbetween the code and pre commands.

" </nowiki>

TiTnAsS pro version of "Take"

numMatches = 15
player1 = raw_input("Player 1's name: ")
player2 = raw_input("Player 2's name: ")
players = (player1,player2)
currentPlayer = 0
print "The rules to this game are simple."
print "You can't take more then 3 matches."
print "The person to take the last match is the loser."
print "Good luck! :)"
while numMatches > 0:
    print " "
    print "It's",players[currentPlayer] + "'s","turn."
    print "There are",numMatches,"matches left."
    inputValid = False
    while inputValid is not True:
        numTaken = str(raw_input("How many matches do you want to take? ") )
        if numTaken.isdigit():
            numTaken = int(numTaken)
            if numTaken > 3 or numTaken <= 0:
                print "You must pick 1-3 matches.  You picked " + str(numTaken)
            else:
                inputValid = True
        else:
            print "You must enter a number from 1 to 3."
    numMatches = numMatches - numTaken
    currentPlayer = 1 - currentPlayer
print players[currentPlayer],"is the winner!"