I want to simulate a self that would avoid random walking in two dimensions on a square mesh and plot a path.
So far I've written the code for this problem:
n < - 100 x & lt; - 0 y & lt; - 0 randomwalkx & lt; - 0 Randwicki & lt; - For 0 (1: n) (random == 1) {x
The path travels only in a diagonal direction Does anyone see me or solve this mistake?
The problem is in this line:
if (ycheck == "TRUE" and & amp; xcheck == "TRUE") {
This is what the line is doing, doing so can not let your walking "backwards" assume that your Walks random walkx = (0,1,1,2), randomized = (0,0, -1, -1) and your next role gives you x = x-1: the next coordinate will be 1, - 1 . Both x = 1 and y = -1 are present in your random running history, so your loop will roll again until you move on in the same direction for X or Y.
If you can fix this by changing something like Paste (Paste (X, Y)% Paste (RandWox, RandWalk))
{{code >
No comments:
Post a Comment