Pandemonium Purger
Posts: 1341
Joined: Monday, 24th October 2011, 06:13
Advanced Vault Design
Now let's say you want A, B, and C to be randomly rock or floor, but B should be floor if both A and C are rock. Here's one way to do it (add these lines to the map definition):
This code uses crawl.random2(N) which returns a number from 0 to N-1 (in this case, returns 0 or 1). So we give A a 50% chance of being rock, and the same for C. If we made both A and C rock, we force B to be floor, otherwise we use a subst that gives B the same 50% chance of being rock.
What I don't understand is... any of this. Lets simplify the example. What if there is just A and B? What would the code be to make both A and B 50%? I am sure there are multiple ways to accomplish this in code, like 50% for A, otherwise B, etc. But as a layman I don't understand this code and just want to make a few maps with random elements.
So if I want A to have a 50% chance to be rock or empty space and B to have the opposite (rock instead of space), what is my code?