Rick,

I'm going to sprinkle a little commentary in here...

On Oct 28, 2009, at 10:35 AM, Max Williams wrote:

> I don't really understand what you're trying to do, but i can see one
> problem.
>
> roll_1 = rand(6) happens inside the if block, right?  (if (input !=
> "pass"))
>
> So it will be done if the if test is true.  And if the first if test  
> is
> true, then the elsif will never be tested - when it finishes the if
> block then it will exit the whole if/elsif section.
>
> Without getting into any other details, and just addressing the if/ 
> else
> stuff, this might be better - it uses a nested if instead of an elsif
> which i think is what you wanted to do.
>
>
> score = 0
> turns = 0
> faces = [one, two, three, four, five, six]
>
> answered = false

Why call this variable "answered"? It seems like you want the next  
line (the start of the loop) to read like "until finished" so why not  
make it so.

finished = false   # or you could use nil
>
> while (answered == false) do

You don't need to have a "do" here. A while (or an until) implicitly  
begins a block.

until finished

>
>  puts "Would you like to Roll or Pass?"

You can leave the cursor after the question by using print instead of  
puts:

   print "Would you like to Roll or Pass? "

>    input = gets().chomp().downcase()

The empty parentheses are typically omitted.

   input = gets.chomp.downcase

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

Again, you have optional parentheses that are idiomatically dropped.  
Also, it's much more likely that you'd see interpolation that string  
concatenation.

   if input == "pass"
     puts "\nFinal Score is: #{score}"
     finished = true

Of course, you could also simply call 'break' here and use the 'loop'  
keyword rather than keep track of a variable to control the loop.  
(Although the 'loop' does take a block so you'd have: 'loop do ...  
end' in place of 'until finished; ... end')

>  else
>    roll_1 = rand(6)
>    roll_2 = rand(6)
>    puts faces[roll_1] + faces[roll_2]
>    score = score + (roll_1 + 1) + (roll_2 +1)
>    turns = turns + 1
>    puts "Current Score is: " + score.to_s()
>
>    if (roll_1 == 0 || roll_2 == 0)
>      puts "You lose!\nFinal Score is: 0"
>      answered = true
>    end
>  end
> end
>
> puts "Turns taken: " + turns.to_s()
> -- 
> Posted via http://www.ruby-forum.com/.

I hope this helps you.

-Rob

Rob Biedenharn		http://agileconsultingllc.com
Rob / AgileConsultingLLC.com