Want to support CHYOA?
Disable your Ad Blocker! Thanks :)

Chapter 3 by gene.sis gene.sis

What's next?

Roll the Dice

Settings

You can see the working example here.


The settings of this chapter:
Conditions:
-

Score Changes:
00 Round + 1
00 Previous Round + 1
00 Result = R35

Notes: Instead of rolling one dice for each of the characters, only one Random Number is generated. This variable Result can take 36 states from 0 to 35. These 36 states (6 × 6) represent all possible combinations of dice rolls with two six-sided dice. To use a low number of Link Chapters, the combinations are then arranged in a way that creates the range 0 to 14 for Ethan Wins, 15 to 20 for Tie, and 21 to 35 for Olivia Wins. The following table shows the dice rolls and outcomes that are assigned to each result. So if the Random Number of the variable Result is 12, it is assumed that Ethan rolled a 5 and Olivia rolled a 4. That leads to the outcome of Ethan Wins.

 Result   Ethan   Olivia   Outcome 
0 2 1 Ethan Wins
1 3 1 Ethan Wins
2 4 1 Ethan Wins
3 5 1 Ethan Wins
4 6 1 Ethan Wins
5 3 2 Ethan Wins
6 4 2 Ethan Wins
7 5 2 Ethan Wins
8 6 2 Ethan Wins
9 4 3 Ethan Wins
10 5 3 Ethan Wins
11 6 3 Ethan Wins
12 5 4 Ethan Wins
13 6 4 Ethan Wins
14 6 5 Ethan Wins
15 1 1 Tie
16 2 2 Tie
17 3 3 Tie
18 4 4 Tie
19 5 5 Tie
20 6 6 Tie
21 1 2 Olivia Wins
22 1 3 Olivia Wins
23 1 4 Olivia Wins
24 1 5 Olivia Wins
25 1 6 Olivia Wins
26 2 3 Olivia Wins
27 2 4 Olivia Wins
28 2 5 Olivia Wins
29 2 6 Olivia Wins
30 3 4 Olivia Wins
31 3 5 Olivia Wins
32 3 6 Olivia Wins
33 4 5 Olivia Wins
34 4 6 Olivia Wins
35 5 6 Olivia Wins


Chapter source code:
{if@ variable > 100000}Please start the Game Mode on the right tab under "Score" or click here before navigating back to this chapter.{else}{if Round > 1}{if Winner = 1}Ethan won.
{elseif Winner = 2}Olivia won.
{elseif Winner = 0}This round is a tie.
{endif}
After round {Previous Round}, Ethan has {Points Ethan} {if Points Ethan =1}point{else}points{endif} and Olivia has {Points Olivia} {if Points Olivia =1}point{else}points{endif}.

{endif}{if Points Olivia = 6}Olivia cheers as she won the game after {Previous Round} rounds.

"Do you wanna play another game?"

{elseif Points Ethan = 6}Ethan cheers as he won the game after {Previous Round} rounds.

"Do you wanna play another game?"

{else}{if Round = 1}"Okay, let's start!"{else}"Round {Round},"{endif} Olivia says, "Roll your dice!"

Ethan rolls the dice and gets a {if Result = 0}2{elseif Result = 1}3{elseif Result = 2}4{elseif Result = 3}5{elseif Result = 4}6{elseif Result = 5}3{elseif Result = 6}4{elseif Result = 7}5{elseif Result = 8}6{elseif Result = 9}4{elseif Result = 10}5{elseif Result = 11}6{elseif Result = 12}5{elseif Result = 13}6{elseif Result = 14}6{elseif Result = 15}1{elseif Result = 16}2{elseif Result = 17}3{elseif Result = 18}4{elseif Result = 19}5{elseif Result = 20}6{elseif Result = 21}1{elseif Result = 22}1{elseif Result = 23}1{elseif Result = 24}1{elseif Result = 25}1{elseif Result = 26}2{elseif Result = 27}2{elseif Result = 28}2{elseif Result = 29}2{elseif Result = 30}3{elseif Result = 31}3{elseif Result = 32}3{elseif Result = 33}4{elseif Result = 34}4{elseif Result = 35}5{endif}.
Olivia rolls the dice and gets a {if Result = 0}1{elseif Result = 1}1{elseif Result = 2}1{elseif Result = 3}1{elseif Result = 4}1{elseif Result = 5}2{elseif Result = 6}2{elseif Result = 7}2{elseif Result = 8}2{elseif Result = 9}3{elseif Result = 10}3{elseif Result = 11}3{elseif Result = 12}4{elseif Result = 13}4{elseif Result = 14}5{elseif Result = 15}1{elseif Result = 16}2{elseif Result = 17}3{elseif Result = 18}4{elseif Result = 19}5{elseif Result = 20}6{elseif Result = 21}2{elseif Result = 22}3{elseif Result = 23}4{elseif Result = 24}5{elseif Result = 25}6{elseif Result = 26}3{elseif Result = 27}4{elseif Result = 28}5{elseif Result = 29}6{elseif Result = 30}4{elseif Result = 31}5{elseif Result = 32}6{elseif Result = 33}5{elseif Result = 34}6{elseif Result = 35}6{endif}.{endif}


Notes:
- This chapter is the central hub for this branch, and its content will be adjusted to the current status of the Game of Dice.
- The first part of the chapter shows everything that should be shown to the reader in any but the first round. In any round but the first, it shows who won the current round and the number of points Ethan and Olivia have.
- The second part of the chapter shows whether one of them has won the game, and if so, the reader gets asked whether they want to play again. If none of them has won, this part shows Ethan and Olivia's dice rolls.
- As there is only one variable Result for both dice rolls, the individual results of both dice can't be shown directly. Instead, the dice roll values assigned to the given value of Result need to be taken from the table. That is done in the long If-Statements. (It would be possible to reduce the number of If-Statements for each dice by 10 (or even 15) if ranges are used instead of one statement for each value of Result. As I have rearranged the possible dice rolls in a spreadsheet, I used the concat function to create these if-statements. That way, it might also be easier to read.)
- If you don't need to know the specific number of pips at all, you could skip creating a table and just go with the probabilities. For the given example, Olivia and Ethan each win 5 out of 12 times and tie the remaining 2 times.
- If one of the characters won, this chapter will still calculate dice rolls for them, even though they won't be used.
- The variable Winner is used to indicate who the winner is with 0 = tie, 1 = Ethan won, and 2 = Olivia won.

What's next?

Comments

      More fun
      Want to support CHYOA?
      Disable your Ad Blocker! Thanks :)