From: andrea Date: 2009-01-08T07:39:48+09:00 Subject: tictactoe and choice I was trying to code the classic tictactoe in ruby. Now it only plays itself doing random moves until someone wins, and there are still some bugs. But the thing that really I don't understand is another, With this line every time I pick the next move: x, y = (0...(board.length)).to_a.choice, (0... (board.length)).to_a.choice But I get always the same game!!: step 0 we have: [[nil, nil, nil], [nil, nil, nil], [nil, nil, nil]] step 1 we have: [[nil, nil, "O"], [nil, nil, nil], [nil, nil, "X"]] step 2 we have: [[nil, "O", "O"], ["X", nil, nil], [nil, nil, "X"]] sorry 2, 2 already set sorry 0, 2 already set step 3 we have: [[nil, "O", "X"], ["X", nil, nil], ["O", "X", "X"]] player X has won [[nil, "O", "X"], ["X", nil, "X"], ["O", "X", "X"]] It looks like there's nothing really random here, am I missing something maybe?? The full source code http://pastie.textmate.org/private/ivw3qswnf6rbppyd78m0qq Thanks a lot for any hint