Introduction: Incorrect uses of random(-1, 1) in Walker's step method
kjkuan opened this issue · 2 comments
kjkuan commented
In the Introduction page, I find that the use of random(-1, 1)
doesn't work as expected without rounding. I think it should be used like this:
x += round(random(-1, 1)); y += round(random(-1, 1));
Note: I'm using Processing 2.0.2 on Mac OS X.
scotthmurray commented
What about the code isn't working as expected? What happens instead?
I'm guessing you're getting an error, because x
and y
start out as int
s in this chapter. Yet random(-1, 1)
returns a float
, so make sure you've changed x
and y
to float
s.
shiffman commented
I checked and the text explicitly mentioned the need for floating points so I think this issue can be closed.