Great. After some hundreds of mouse clicks (to be faster than the auto reload) and reloads it traveled back and forth once.Tank Program wrote:Yes well. I wrote pong in php a while back.
http://electricpotential.net/temp/pong/
</random>
whee "turing completness"
- Tank Program
- Forum & Project Admin, PhD
- Posts: 6712
- Joined: Thu Dec 18, 2003 7:03 pm
Patience...Jonathan wrote:Great. After some hundreds of mouse clicks (to be faster than the auto reload) and reloads it traveled back and forth once.Tank Program wrote:Yes well. I wrote pong in php a while back.
http://electricpotential.net/temp/pong/
</random>

That pong game is pretty cool, tank. It seems like if you increased the speed of the ball and the paddles (when you press up/down) you could make it work without sigificantly noticing that it's run server-side. 
Hell, you might be able to make it multi-player too. I don't know how much time you want to spend making a pong game in php, though. It is pretty cool, though.

Hell, you might be able to make it multi-player too. I don't know how much time you want to spend making a pong game in php, though. It is pretty cool, though.
Check out my YouTube channel: https://youtube.com/@davefancella?si=H--oCK3k_dQ1laDN
Be the devil's own, Lucifer's my name.
- Iron Maiden
Be the devil's own, Lucifer's my name.
- Iron Maiden
- Jonathan
- A Brave Victim
- Posts: 3391
- Joined: Thu Feb 03, 2005 12:50 am
- Location: Not really lurking anymore
I'd rather spent my time writing another pong game in C. And I did.Tank Program wrote:Patience...Jonathan wrote:Great. After some hundreds of mouse clicks (to be faster than the auto reload) and reloads it traveled back and forth once.

ˌɑrməˈɡɛˌtrɑn
I didn't realize it was lose if you took last match, ill fix that later and i'm currently working on limiting it to 4 matches per turn..Z-Man wrote:Observe that I could happily take all the matches. That should be impossible, and also I should have lost because I took the last one. And when it's player 2's turn, there are 15 matches again. That last error is because there are actually three variables named "a" in the program: the one from the first line, and the ones in func_a and func_b. Variables are local to their definition, and unless you do something aboutof func_b. Also, the "a" of the two functions will be a different "a" for it, writing to func_a's a won't have an effect on the global "a" or the one every time you call the function. There's a way to access global variables from within functions, but it's better style most of the time to pass a function every variable it needs for operation, and let it return the information the caller needs (here, for example, the number of matches left).
Another run:
About the global variable, i havnt had a chance to check it since i made the functipons cuz i couldnt run it cuz the elif thing, i had it close b4 that tho...ill take care of it
Damn, it sure has been a while!
Welcome to the fine art of programming TnA, the area in which you will spend 90% of your time: figuring out why it don't work.
(This is where the men get separated from the chimps)

Check out my YouTube channel: https://youtube.com/@davefancella?si=H--oCK3k_dQ1laDN
Be the devil's own, Lucifer's my name.
- Iron Maiden
Be the devil's own, Lucifer's my name.
- Iron Maiden
Hurry up, dude. I've got another assignment for you.TiTnAsS wrote:like that quote i posted...and i guess that other thinhg i brought up was true, cuz they changed your rank i just noticed

Check out my YouTube channel: https://youtube.com/@davefancella?si=H--oCK3k_dQ1laDN
Be the devil's own, Lucifer's my name.
- Iron Maiden
Be the devil's own, Lucifer's my name.
- Iron Maiden
Code: Select all
#Homework from Z-Man
#I finally finished it so be amazed!
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."
numTaken = input("How many matches do you want to take? ")
numMatches = numMatches - numTaken
if numTaken > 3:
numMatches = numMatches + numTaken
print "You can't take that many matches."
currentPlayer = 1 - currentPlayer
currentPlayer = 1 - currentPlayer
print players[currentPlayer],"is the winner!"
*Waits for applause...* lol

Damn, it sure has been a while!
You should do your input validation before subtracting num matches. Something like:
Or something like that. Or you can wrap the input getter into a while loop that only exits when the input is valid.
Under no circumstances do you ever want to apply input to variables without validating it somehow! Which is exactly what you did.
Ideally, you would structure your input getting so that there is no such thing as invalid input, but that's not something that happens very often.
Code: Select all
if input > 3 or input < 1:
pass
else:
numMatches = numMatches - input
Code: Select all
isValid = False
while isValid:
input = input("Whateverblahblah")
if input < 3 and input > 0:
isValid = True

Check out my YouTube channel: https://youtube.com/@davefancella?si=H--oCK3k_dQ1laDN
Be the devil's own, Lucifer's my name.
- Iron Maiden
Be the devil's own, Lucifer's my name.
- Iron Maiden
It doesn't work. Type in -1 for matches and see what happens. Type in 0 and watch your turn be skipped.TiTnAsS wrote:If it works as is why bother.. But i'll keep that in mind for the second it dosnt work the way i do itthx for the help

Check out my YouTube channel: https://youtube.com/@davefancella?si=H--oCK3k_dQ1laDN
Be the devil's own, Lucifer's my name.
- Iron Maiden
Be the devil's own, Lucifer's my name.
- Iron Maiden
Code: Select all
## lucifer taught me how to validate my input :)
#Homework from Z-Man
#I finally finished it so be amazed!
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!"
Damn, it sure has been a while!
Applause! It works fine, and it's even good style. A minor glitch (minor because it does not lead to undesired behavior): it does not check anymore whether you took more matches than are there:
Code: Select all
...
It's blubb's turn.
There are 2 matches left.
How many matches do you want to take? 3
bla is the winner!