Difference between revisions of "Code hacks"

From Armagetron
Line 2: Line 2:
 
<code> <pre>
 
<code> <pre>
 
<nowiki>  
 
<nowiki>  
"<code> <pre>  
+
"<pre>  
 
Copy paste your script here, in the space inbetween the code and pre commands.
 
Copy paste your script here, in the space inbetween the code and pre commands.
 
</pre> </code>" </nowiki> </pre>
 
</pre> </code>" </nowiki> </pre>
 +
Note: there is no <nowiki><code></nowiki> in front of the script.
 +
  
 
== TiTnAsS pro version of "Take" ==
 
== TiTnAsS pro version of "Take" ==
  
<code> <pre>
+
<pre>
 
numMatches = 15
 
numMatches = 15
 
player1 = raw_input("Player 1's name: ")
 
player1 = raw_input("Player 1's name: ")

Revision as of 00:08, 31 October 2005

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> 
"<pre> 
Copy paste your script here, in the space inbetween the code and pre commands.

" </nowiki>

Note: there is no <code> in front of the script.


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!"