Closed Spencerbrucehudson closed 7 years ago
Looking good Spence. A few pointers:
seq(1,9,by=8)
; seq(1,9,by=4)
; notice a pattern?) and use that to subset by rows and columns.You're doing very well! Almost there. Remember to take breaks - you're only a few lines from doing this, so don't get "task fixated" and try to see the big picture.
Thanks for the help Will. Looks like it's working now. Not quite how you told me to do it, but it seems to be okay. I just need to add noise. Check it out?
Looks fantastic! Well done!!! You implementation is incredibly easy to read, and looks fantastic. Yes, it would be best if you added a little noise to it, but that's really just to make it look more like a terrain. Well done!
Sounds good. Thanks Will!
Hey Will, I've got the terrain up and running, but am unable to apply it to matrices beyond 5x5.
When I run the following code beyond a those constraints (e.g. 9x9):
diamond.square.step <- function(terrain){ for (i in 2^(n:1)) { half <- i/2 for (c in seq(1, l-1, by=i)) { for (r in seq(1, l-1, by=i)) {
terrain[(1:(r+i)),(1:(c+i))] <- diamond.step(terrain[(1:(r+i)),(1:(c+i))]) terrain[(1:(r+i)),(1:(c+i))] <- square.step(terrain[(1:(r+i)),(1:(c+i))])
terrain[((1+half):(1+i)),(1:(c+half))] <- diamond.step(terrain[((1+half):(1+i)),(1:(c+half))]) terrain[((1+half):(1+i)),(1:(c+half))] <- square.step(terrain[((1+half):(1+i)),(1:(c+half))])
terrain[(1:(r+i)),((1+half):(c+i))] <- diamond.step(terrain[(1:(r+i)),((1+half):(c+i))]) terrain[(1:(r+i)),((1+half):(c+i))] <- square.step(terrain[(1:(r+i)),((1+half):(c+i))])
terrain[((1+half):(r+i)),((1+half):(c+i))] <- diamond.step(terrain[((1+half):(r+i)),((1+half):(c+i))]) terrain[((1+half):(r+i)),((1+half):(c+i))] <- square.step(terrain[((1+half):(r+i)),((1+half):(c+i))]) } } } return(terrain) }
I get this error:
Error in
[<-
(*tmp*
, h, h, value = 0.4377390625) : subscript out of bounds Called from: diamond.step(terrain[((1 + half):(1 + i)), (1:(c + half))])Any suggestions are much appreciated.
Thanks.