• (2 Pages)
  • +
  • 1
  • 2

Beginning Games for N00blets: Rock, Paper, Scissors Also introduces Math's Random, a little Wrapper, and simple GUI Rate Topic: -----

#16 xclite  Icon User is offline

  • LIKE A BOSS
  • member icon


Reputation: 877
  • View blog
  • Posts: 3,122
  • Joined: 12-May 09

Posted 28 June 2010 - 06:56 AM

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?"
Was This Post Helpful? 0
  • +
  • -

#17 NeoTifa  Icon User is offline

  • Whorediot
  • member icon





Reputation: 2495
  • View blog
  • Posts: 15,453
  • Joined: 24-September 08

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

Was This Post Helpful? 0
  • +
  • -

#18 Zekorov  Icon User is offline

  • D.I.C Head

Reputation: 22
  • View blog
  • Posts: 226
  • Joined: 16-May 10

Posted 28 June 2010 - 10:19 AM

vielen dank :)
Was This Post Helpful? 0
  • +
  • -

#19 xclite  Icon User is offline

  • LIKE A BOSS
  • member icon


Reputation: 877
  • View blog
  • Posts: 3,122
  • Joined: 12-May 09

Posted 28 June 2010 - 10:34 AM

View PostNeoTifa, 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

Was This Post Helpful? 0
  • +
  • -

#20 NeoTifa  Icon User is offline

  • Whorediot
  • member icon





Reputation: 2495
  • View blog
  • Posts: 15,453
  • Joined: 24-September 08

Posted 28 June 2010 - 11:14 AM

o_____o

This post has been edited by NeoTifa: 28 June 2010 - 11:14 AM

Was This Post Helpful? 0
  • +
  • -

#21 Guest_james*


Reputation:

Posted 13 July 2010 - 08:53 AM

Nice :)
Was This Post Helpful? 0

  • (2 Pages)
  • +
  • 1
  • 2