Getting infinite loop from specific array

I am trying to make a Greed game. See attached for my code.

For some reason, when the roll method returns an array with three of 1s
or 5s such as:

[1, 1, 2, 1, 5]

I get an infinite loop printing

You roll [1, 1, 2, 1, 5]
You roll [1, 1, 2, 1, 5]
You roll [1, 1, 2, 1, 5]
...

I do not have this problem for any array that does not have three of 1s
or 5s.

Any idea why I get this problem?

Attachments:
http://www.ruby-forum.com/attachment/8349/about_extra_credit.rb

···

--
Posted via http://www.ruby-forum.com/.

I suggest writing some unit tests for your methods, and stepping
through them with the debugger.

···

On Tue, Apr 16, 2013 at 7:23 PM, Vincent Stowbunenko <lists@ruby-forum.com> wrote:

I am trying to make a Greed game. See attached for my code.

For some reason, when the roll method returns an array with three of 1s
or 5s such as:

[1, 1, 2, 1, 5]

I get an infinite loop printing

You roll [1, 1, 2, 1, 5]
You roll [1, 1, 2, 1, 5]
You roll [1, 1, 2, 1, 5]
...

I do not have this problem for any array that does not have three of 1s
or 5s.

Any idea why I get this problem?

Attachments:
http://www.ruby-forum.com/attachment/8349/about_extra_credit.rb

--
Posted via http://www.ruby-forum.com/\.

Vincent Stowbunenko wrote in post #1105936:

Any idea why I get this problem?

nonscoring_dices returns -1 and you don't have condition for this value
in main loop of 'start' method.

···

--
Posted via http://www.ruby-forum.com/\.