Another user posted a question about a dice game earlier. I have this
same assignment. The goal of the assignment is the create a program to
roll two dice, add the number of those dice to the score, and if you get
a 1 you lose. After each roll the program asks the user to roll or pass.

I've accomplished this...but I'm pretty sure the way I set up the
scoring isn't the most efficient way to do it, but I don't know how else
to do it. Can anyone help me?

# Die Pieces #################################
frame = "+-----+\n"
blank = "|     |\n"
center ="|  *  |\n"
right = "|*    |\n"
left =  "|    *|\n"
both =  "|*   *|\n"
#############################################

# Dice ######################################
one = frame + blank + center + blank + frame
two = frame + right + blank + left + frame
three = frame + right + center + left + frame
four = frame + both + blank + both + frame
five = frame + both + center + both + frame
six = frame + (both * 3) + frame
#############################################

score = 0
turns = 0
faces = [one, two, three, four, five, six]

answered = false

while (answered == false) do

  puts "Would you like to Roll or Pass?"
    input = gets().chomp().downcase()

  if (input == "pass")
    puts "\nFinal Score is: " + score.to_s() + "\nBye!"
    (answered = true)
  end

  if (input != "pass")
    roll_1 = faces[rand(6)]
    roll_2 = faces[rand(6)]
    puts roll_1 + roll_2

From here    if (roll_1 == faces[1])
        score = score + 2
      elsif (roll_1 == faces[2])
        score = score + 3
      elsif (roll_1 == faces[3])
        score = score + 4
      elsif (roll_1 == faces[4])
        score = score + 5
      elsif (roll_1 == faces[5])
      score = score + 6
      end

      if (roll_2 == faces[1])
        score = score + 2
      elsif (roll_2 == faces[2])
        score = score + 3
      elsif (roll_2 == faces[3])
        score = score + 4
      elsif (roll_2 == faces[4])
        score = score + 5
      elsif (roll_2 == faces[5])
        score = score + 6
To here      end

    puts "Current Score is: " + score.to_s()
    turns = turns + 1
  elsif ((roll_1 == faces[0])||(roll_2 == faces[0]))
    puts "You rolled a 1. You lose!"
    (answered = true)
  end
end

puts "Turns taken: " + turns.to_s()
-- 
Posted via http://www.ruby-forum.com/.