0

In my test:

@board.disp_s
@board.state = [1,0,0,1,0,0,0,0,0]
@board.disp_s

corresponding output:

Layout:
nilnilnil 
nilnilnil 
nilnilnil 

Layout:
100 
100 
110 

now... I'm pretty sure I told it to be

100
100
000

code from my model: http://pastebin.com/2Mpu7tU7

I'm sure that none of my methods being called by the test are modifying the @board_layout.... so I'm confused.

2
  • It would be better to include all the code here rather than in an external pastebin link. Commented Jan 30, 2011 at 3:05
  • I did that, cause the code is.. around 70 lines Commented Jan 30, 2011 at 3:41

1 Answer 1

3

The disp_s method is not computing the indexes correctly.

  def disp_s
    puts "Layout:"
    WIDTH.times do |row|
      WIDTH.times do |col|
        print @board_layout[col * row + col]
      end
      puts " "
    end

The col * row + col should likely be WIDTH * row + col.

I haven't looked carefully enough at your code to be sure there are no other issues, but this would definitely print incorrect values.

Sign up to request clarification or add additional context in comments.

1 Comment

lol, thanks. Silly mistake. Guess I wast just staring at it too long.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.