-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
diamond.square.terrain #4
Comments
Looking good! You're getting better at writing things out first. Once you've written something out as you do above, try getting to the next level and writing something that looks a bit more like pseudo-code. A good way of telling if you've written pseudo-code is whether or not you use words like Make sure you're applying the diamond step then the square step to all sub-matrices/quadrants. Consider whether step 1 and step 2 are really different steps. In one you're applying to a particular sub-matrix (which just happens to be the whole matrix!) and in the second you're looping over a load of sub-matrices. As far as indexing goes, you're already thinking about the right lines, so let me give you a hint. You are correct in that you know how to get out a single row and a single column (--> a single cell in your matrix). See if you can figure out how to do it using the example of how to do something similar in a vector below: vector <- c("Will", "Sarah", "Jeni", "Barry")
toupper(vector[2])
toupper(vector[2:3]) ...what do you reckon?... |
In order to apply diamond before square in every sub-matrix, can we just use a for loop? As far as indexing goes, I do know how to get chunks of a vector like that. It is, however, harder to work in 2D! I am not very good at programming so I decided to try a for loop. I'm sure there is a better way. This is the error message: |
Look at what I've written ( The thing with errors is to read them slowly and carefully. I'll help you break down this one.
I would imagine that's enough to get it... |
Will: You beat me to it by seconds. I was about to say that Jenessa can fix this one, especially your item 1) the error message. |
Can you index the index? Like as in: |
I wouldn't call it indexing the index, but yes you can. Go back to your
|
Ok, so matrix[1:3, 1:3] grabs the first quadrant! Now it's a matter of trying to apply both steps to all four quadrants, and all four of their sub quadrants, and so on, which I believe I am going to use expand.grid to use. |
It's my turn, I'm trying to call you on Skype |
@Wolflab
I am having a hard time with writing a function to go through the matrix applying the diamond and square step sequentially. Here is what I want to do in English:
So step two is what I really need help with. I think that I know the basics of indexing a matrix (matrix[row, column]) but I don't know how to index a whole block of a matrix. @willpearse?
The text was updated successfully, but these errors were encountered: