# NICE DICE

by BOB ALBRECHT and GEORGE FIREDRAKE

**DragonSmoke** poses problems for you to ponder, questions for you to answer, programs for you to write, and other mischief for you to create.

**GAME MASTER'S APPRENTICE**

In fantasy role-playing games, names are important. If you read fantasy, perhaps you know some of these names.

FRODO GANDALF ARAGORN GIMLI ELROND CONAN ELRIC GED

If you aquire a character to play in a game, you usually get to choose the name of your chracter. You may choose any name, including your own name or the name of a friend. Any name is okay.

You might want to give a character a name different from the names you are used to, a name that "sounds like" the kind of being (human or otherwise) your character is. Or, use your ATARI to create random names. When you see or hear:

ROKAR BARAK KUMAN MORAB

What do you think about them? What kind of characters might they be? How about:

LOSAS SOMAL RAMOS MIKOS

Without any additional information, pick three of the above as people to go adventuring with.

All of the above names have the form:

CONSONANT VOWEL CONSONANT VOWEL CONSONANT

We challenge you to write a program to create and display five-letter names consisting of: CONSONANT, VOWEL, CONSONANT, VOWEL, CONSONANT. We suggest your program should display several names, then say "FOR MORE NAMES, PRESS SPACE". If someone presses the space bar, you see one more line of names.

Think ahead. Anticipate what we might ask next. For example:

NAMESTRUCTURE? CVCVC Consonant, Vowel, Consonant, Vowel, Consonant

HOW MANY NAMES? 20

20 names printed here

TO DO AGAIN, PRESS SPACE

We write down any names we want to remember, then press the space bar.

NAME STRUCTURE? VCCVC Vowel, Consonant,Consonant, Vowel, Consonant

HOW MANY NAMES? 16

16 names appear on the screen.

TO DO AGAIN, PRESS SPACE

This time, names such as ELRIC, ALKAR, etc. are possible. But don't limit your program to names with five letters. When the computer asks NAME STRUCTURE?, try VCCVCC or CVCVCV or CVCVCCVC or whatever you want.

**GAME MASTER'S DICE**

Most-role playing game systems use dice to determine the outcomes of events. Dice are rolled to find out whether something happened or didn't happen. Did a character find the hidden treasure, or open the secret door, or hear the monster sneaking up behind her! Did the character solve the puzzle that unlocks the magic chest or read the cryptic runes? Who won the melee between the good guys and the bad guys? How much damage did our character take when he fell out of the tree? Roll dice to find out.

Dice are used to determine success or failure in using weapons. If a weapon attack is successful, dice are used to determine how much damage is inflicted. If a character can use magic, dice are rolled to determine if a spell is cast successfully and what its effect are. In playing a game, you spend much time rolling dice and interpreting the results of a roll. Fantasy role playing, like life itself, is part skill and part luck.

GAME MASTER'S DICE come in many shapes, from tetrahedrons (4 sides) to icosahedrons (20 sides). We assume you are already acquainted with ordinary six-sided dice. We use the abbreviation D6 to mean one six-sided die.

We also use less familiar dice, such as:

D4 is a tetrahedron, with sides numbered 1 to 4. The number rolled is the one that is right side up after you throw the die.

D8 is an octahedron, with eight sides numbered 1 to 8.

D12 is a dodecahedron, with twelve sides numbered 1 to 12.

D20 is an icosahedron, with twenty sides numbered 1 to 20.

A digit die (DD) can be a ten-sided die, with sides numbered 0 to 9, or an icosahedron with twenty sides numbered 0 to 9 (each number appears twice).

D6 is one six-sided die

1D6 is one six-sided die

2D6 are two six-sided dice

3D6 are three six-side and so on.

We use a digit die (DD) to roll a decimal digit from 0 to 9. However, sometimes we want to roll D10, a number from 1 to 10. Easy -- roll a DD and use 0 to mean 10.

REMEMBER: A digit die (DD) is a 10 or 20-sided die whose faces are numbered 0 to 9.

D100 is a percentage roll, also called a percentile roll, with numbers from 00 to 99. To make a percentage roll, use a DD (digit die), roll it twice. The first roll is the ten's digit; the second roll is the one's digit. If you roll a 13 the first time and a 7 the second time, the number is 37.

Or use two digit dice of different colors. One color (silver? gold? yellow?) is the ten's digit and the other (white? copper?) is the one's digit.

Sometimes, zero zero (00) is a fumble. If you roll a fumble . . . alas . . . your character may trip on his sword, drop the chest of gold on his foot, fall out of the tree in which he is hiding, or suffer another calamity gleefully prescribed by the GAME MASTER. (GAME MASTERS love it when you fumble.)

If you browse the literature of role-playing games, you may encounter other dice abbreviations.

D3 Roll a D6 and read the results as follows:

1 or 2 is 1 The possible values for D3 are 1, 2, or 3.

3 or 4 is 2

5 or 6 is 3

D6+1 Roll a D6 and add one to the result. Possible values are 2 to 7 (2, 3, 4, 5, 6, or 7).

3D4 Roll three four-sided dice and add them. Possible values are 3 to 12. The values are not equally probable.

D6 + D4 Roll one D6 and one D4, then add the results. Possible values are 2 to 10.

Another way to roll D3 is to roll D4. If you get 4 ignore it and roll again. If you don't have the proper dice, improvise!

Or, use your ATARI to roll dice. First, we challenge you to write a program to roll N dice, each with S sides. Yes, if you want, you can roll two-sided dice, or even seven-sided dice, or 13-sided dice, or whatever imaginary dice you create. Hmmm . . . if you do, think about what they may look like. Send us our designs for fair dice with 2, 7, 13, (and so on) sides.

Yup, we wrote a program to roll dice. Here is a RUN of our program.

DICE? 3D6

12

DICE? 2D7

6

DICE? DD We used DD to mean "Digit Die." We used P to mean "Percentile" roll.

4

DICE? P

73

DICE? (Same as 1D20)

16

DICE? and so on.

Next time, we will show you our first GAME MASTER'S DICE program. In the meantime, keep on rolling.

**POSITIVE, NEGATIVE, OR ZERO**

Here again is our simple program to tell whether a number is positive, negative, or zero.

100 REM ** POSITIVE, NEGATIVE, OR ZERO

110 DIM YN$(15),N$(8),Z$(4), P$(8)

120 YN$ = "YOUR NUMBER IS "

130 N$ = "NEGATIVE"

140 Z$ = "ZERO"

150 P$ = "POSITIVE"

200 REM ** TELL WHAT TO DO

210 PRINT CHR$(125)

220 PRINT "ENTER A NUMBER AND I'LL TELL"

230 PRINT "YOU WHETHER YOUR NUMBER IS"

240 PRINT "POSITIVE, NEGATIVE, OR ZERO."

300 REM ** ASK FOR A NUMBER

310 PRINT

320 PRINT "YOUR NUMBER";: INPUT X

400 REM ** TELL ABOUT NUMBER

410 IF X<0 THEN PRINT YN$; N$

420 IF X=0 THEN PRINT YN$; Z$

430 IF X>0 THEN PRINT YN$; P$

500 REM ** GO FOR ANOTHER NUMBER

510 GOTO 310

Last time we asked you to rewrite the program without using IF statements. Here are two ways in which only block 400 is changed and block 500 is deleted. Blocks 100, 200, and 300 remain unchanged.

METHOD #2

400 REM ** TELL ABOUT NUMBER

410 W = SGN(X) + 2

420 ON W GOTO 430, 440, 450

430 PRINT YN$; N$: GOTO 310

440 PRINT YN$; Z$: GOTO 310

450 PRINT YN$; P$: GOTO 310

METHOD #3

400 REM REM ** TELL ABOUT NUMBER

410 W = SGN(X) + 2

420 ON W GOSUB 440, 450, 460

430 GOTO 310

440 PRINT YN$;N$:RETURN

450 PRINT YN$; Z$: RETURN

460 PRINT YN$; P$: RETURN

For both of the above, lines 500 and 510 of the original program are unnecessary -- delete them.

We have three ways to write this program. Now, without using IF statements or ON . . . GOTO or ON . . . GOSUB, you write block 400 to complete the fourth program.

METHOD #4

100 REM ** POSITIVE, NEGATIVE, OR ZERO

110 DIM YN$(15), NZP$(24)

120 YN$ = "YOUR NUMBER IS "

130 NZP$ = "NEGATIVEZERO POSITIVE"

200 REM ** TELL WHAT TO DO

210 PRINT CHR$(125)

220 PRINT "ENTER A NUMBER AND I'LL TELL"

230 PRINT "YOU WHETHER YOUR NUMBER IS"

240 PRINT "POSITIVE, NEGATIVE, OR ZERO."

300 REM ** ASK FOR A NUMBER

310 PRINT

320 PRINT "YOUR NUMBER";: INPUT X

400 REM ** TELL ABOUT NUMBER

You do this.

500 REM ** GO FOR ANOTHER NUMBER

510 GOTO 310

Hint: In line 130, NEGATIVE is in character positions 1 through 8 of the string NZP$. ZERO plus four spaces is in positions 9 through 16. POSITIVE is in positions 17 through 24.

Now suppose we change block 100 as follows:

METHOD #5

100 REM ** POSITIVE, NEGATIVE, OR ZERO

110 DIM YN$(15), NZP$(8)

120 YN$ = "YOUR NUMBER IS "

130 DATA NEGATIVE

140 DATA ZERO

150 DATA POSITIVE

Rewrite block 400 to use the above information. Hmmm . . . five ways so far, more to come later. We will also show some solutions in Atari Microsoft BASIC.

**TWO-DIGIT NUMBER SPLITTER**

Last time we asked you to "split" a two-digit number and print the digits separately, like this:

TWO-DIGIT NUMBER? 23

TENS DIGIT = 2

ONES DIGIT = 3

TWO-DIGIT NUMBER? etc.

We defined a two-digit number as a whole number in the range 10 to 99, inclusive.

Our first solution uses arithmetic to compute the ones digit. It is similar to doing it by long division.

Let's see now. First, we divide our two-digit number by 10. The whole number quotient is the tens digit. Then, we multiply the tens digit by 10 and subtract it from the two-digit number. The result is the ones digit. In the following program, we use T for the tens digit and U for the ones digit. We don't use O (Oh) because it looks too much like zero (0).

100 REM ** TWO-DIGIT NUMBER SPLITTER

110 DIM 00P$(32)

120 OOP$ = "MUST BE A WHOLE NUMBER, 10 TO 99"

200 REM ** CLEAR THE SCREEN

210 PRINT CHR$(125)

300 REM ** ASK FOR 2-DICIT NUMBER, X

310 PRINT

320 PRINT "TWO-DIGIT NUMBER, PLEASE";INPUT X

400 REM ** IF NUMBER IS OK, GO ON

410 IF INT(X)=X AND X =10 AND X =99 THEN 510

420 PRINT OOP$: GOTO 310

500 REM ** SPLIT THE NUMBER

510 T = INT(X/10)

520 U = X-10*U

600 REM ** PRINT THE DIGITS

610 PRINT "TENS DIGIT = "; T

620 PRINT "ONES DIGIT = "; U

700 REM ** DO IT AGAIN

710 GOTO 310

It seems that a simple thing for a person is difficult for a computer! After all, anyone can look at 37 and tell you immediately that the tens digit is 3 and the ones digit is 7. How? By relative position in the number. The 3 is to the left of the 7 which, of course, is to the right of the 3. Or, look at 88. The left 8 is the tens digit; the 8 on the right is the ones digit.

Let's teach our ATARI to "think" that way. First, we will do it, then try to explain it. Rewrite blocks 500 and 600, as follows.

500 REM ** SPLIT THE NUMBER

510 X$ = STR$(X)

520 T$ = X$(1,1)

530 U$ = X$(2,2)

600 REM ** PRINT THE DIGITS

610 PRINT "TENS DIGIT = "; T

620 PRINT "ONES DIGIT = "; U$

Also change line 110 like this:

110 DIM 00P$(32), X$(2), T$(1),U$(I)

Okay, for those of you who are not used to working with string functions, here is how it goes.

- First, remember that X is a two-digit number. It is positive and has a tens digit and a ones digit.

- In line 510, the STR$ function creates a string two characters long consisting of the tens

digit of X and the ones digit of X. For example, suppose X is 37. Then,

X$ = STR$(X) = STR$(37) = "37"

- Line 520 picks out the first character of X$ and assigns it to T$.

- Line 520 picks out the second character of X$ and assigns it to U$.

Which method do you prefer? Which method is easter to extend to splitting a three-digit number (100 to 999)? Try both methods in programs to split a three-digit number into its hundreds, tens, and ones digits.

**YOUR TURN**

What would you like to see in DragonSmoke? Would you like solutions in both Atari BASIC and Atari Microsoft BASIC? Send requests to George & Bob, P.O. Box 310, Menlo Park, CA 94025.

If you want a reply, enclose a Self-Addressed, Stamped Envelope(SASE).

Copyright @ 1982 DragonQuest, PO. Box 310, Menlo Park, CA 94025