# Fantasy Dice Game explainer

The aim of this puzzle: Change the rules of the game to use dice with more sides and require a higher number rolled.
Walkthrough of the solution: There are two parts to this puzzle — changing the dice and changing the rules. First, to change from a 6-sided die to a 20-sided die, you need to change the number inside of `pickRandom()` from 6 to 20. The number you put inside of `pickRandom` is the biggest number it can choose from – it’s always ‘guessing’ of a number between 1 and the number you give it. So, `pickRandom(20)` is just like a 20-sided die, and you have two of them in this game. The second part of the puzzle is changing the number you need to roll to beat the game which is stored in the variable `power`. The new rules of the game say that you need to roll a 40 to find the treasure, and if you roll any other number, the dragon awakens. You split this up into two checks which are done with if statements. Inside of the parentheses `()`, you want to see if `power` is equal to 40. You’ll need to use `power === 40`, where the `===` symbol means “is equal to”. To see if `power` is not equal to 40, you use the symbol `!==` which means “not equal to”.
Sample code solution:
(Tap below to reveal)

``````var strength = pickRandom(20);
var agility = pickRandom(20);
var power = strength + agility;
print('You rolled: '+ power);
if (power === 40){
print('You stealthfully tiptoe. You found the treasure!');
}
if (power !== 40) {
print('The dragon awakes, retreat!');
}
``````

JavaScript Concepts: Code Block (if statement), Calling Functions, Identifiers, Variable Declaration
Grasshopper Concepts: pickRandom(), print()