Dark theme

Of course, you don't have to use this code for fighting - you could use it to make a chance a character (what we call a non-player character (or NPC)) gives a gem to the player (if, instead of "player_strength" as our variable, we had "number_of_gems"), or the chance they fall into a trap, catch a disease, or find a random amount of money.

Randomness in games helps them feel more natural. Can you think of some examples of randomness from games you play?

[Home > Part 2 > Next]