I'm always tempted to write one of these that always chooses the winning option (after the user has selected) just to frustrate my friends. "Look what I did! It even uses some psychology!" "IT KNOWS WHAT I'M GOING TO PICK WTF HOW IS IT SO SMART?"
Beginning Games for N00blets: Rock, Paper, Scissors Also introduces Math's Random, a little Wrapper, and simple GUI
#17
Posted 28 June 2010 - 07:45 AM
Lol that's just not right. All you'd have to do is get the input and then just have a series of if-else's to choose a winning output for the computer
This post has been edited by NeoTifa: 28 June 2010 - 07:46 AM
#19
Posted 28 June 2010 - 10:34 AM
NeoTifa, on 28 June 2010 - 10:45 AM, said:
Lol that's just not right. All you'd have to do is get the input and then just have a series of if-else's to choose a winning output for the computer 
class Attack
def counter
return nil
end
end
class Rock < Attack
def counter
return Paper
end
end
class Paper < Attack
def counter
return Scissors
end
end
class Scissors < Attack
def counter
return Rock
end
end
def result(attack, pcAttack)
puts "You chose #{attack}, I chose #{pcAttack}."
puts "#{attack == pcAttack ? 'tie' : attack.counter == pcAttack ? : 'lose' : 'win'}"
end
def cheatResult(attack)
result(attack, attack.Counter)
end
end
This post has been edited by xclite: 28 June 2010 - 10:36 AM
#20
Posted 28 June 2010 - 11:14 AM
o_____o
This post has been edited by NeoTifa: 28 June 2010 - 11:14 AM
|
|








MultiQuote







|