I am trying to get a random number

I am trying to randomize my level with the placement enemies, but when I use random.random() the whole thing, doesn’t crash but is messed up.

It obviously won’t work because that’s not Python. Coffeescript is really a simplified version of JS, and both CS and JS use Math.random() to generate a random number 0 <= x < 1.0.

Oh. Thanks for pointing that out.

CodeCombat uses a seeded random number generator, which I would suggest using instead. The methods are defined here.

Seeded as in the same results are produced from the same seed, allowing the exact same pseudo-random positions to be generated multiple times if you want to repeat a game exactly.

e.g. this.world.rand.randf().

1 Like

Good point. Seeded RNG must be used for levels(ie. Kithgard Mastery) where playback is disabled. For forest levels and above, the differences are less important as players are given a different seed once they press submit. But usually any RNG that affects the visual-aspect should be done using seeded RNG. (For the sake of units not flying around every time users run the level)