DragonSmoke poses problems for you to answer, programs for you to write, and whatever other mischief we might cunningly contrive. As time goes on, and as issue follows issue, we will answer some of the problems we create. Better yet, you answer.
Game Master's Apprentice
by George Firedrake & Bob Albrecht
Have you heard of Dungeons and Dragons, Runequest, Tunnels and Trolls or Worlds of Wonder? These are fantasy role-playing games. For information, write to the following publishers.
Dungeons and Dragons (D&D) from TSR Hobbies, P.O., Box 756, Lake Geneva, WI 53147.
Runequest (RQ) and Worlds of Wonder from Chaosium, P.O. Box 6302, Albany, CA 94706.
Tunnels and Trolls (T&T) from Flying Buffalo, Inc. P.O. Box 1467, Scottsdale, AZ 85252.
To play any of these games, you must create one or more characters, then guide your character(s) through adventures in a universe created by a game master. To create a character, you will roll three six-sided dice several times. We will use Runequest as an example.
A Runequest character has seven characteristics: strength (STR), constitution (CON), size (SIZ), intelligence (INT), power (POW), dexterity (DEX), and charisma (CHA).
These characteristics determine a character's ability to use weapons, fight, learn and use magic, sustain damage, solve problems, lead others, and so on.
Each characteristic is determined by rolling three six-sided dice. Or, in the jargon of role-playing games, you roll 3D6.
When you roll 3D6, you get a number in the range, 3 to 18.
We wrote a program to roll and display the seven basic characteristics for a Runequest character. Here is the first run of our program.
STR 17 We call him Barostan. CON 17 He is big and strong, SIZ 13 but not too bright. He INT 8 is good to have on your POW 7 side in a fight, if someone DEX 15 will tell him who to hit. CHA 6 He acts first, then thinks later, if at all. TO DO AGAIN, PRESS SPACE BAR
We record the information on the screen on a sheet of paper, then press the space bar. The computer immediately rolls another character, whom we name Joleen.
STR 13 Joleen is a clown, mime, acrobat, CON 11 dancer, or whatever else might SIZ 7 entertain an audience. She wants INT 13 to travel with a troupe of POW 8 wandering entertainers, and perform DEX 17 at fairs and festivals. She will CHA 13 charm you. TO DO AGAIN, PRESS SPACE BAR
Now write a program to roll and display the seven characteristics for a Runequest character, as shown above. Follow this outline of REM statements.
100 REM ** RUNEQUEST CHARACTER
300 REM ** ROLL & DISPLAY 7 CHARACTERISTICS
500 REM ** TELL HOW TO DO AGAIN
900 REM ** SUBROUTINE TO ROLL 3D6
IMPORTANT! In block 500, the computer prints "TO DO AGAIN, PRESS SPACE BAR" then waits until someone presses the space bar. When someone presses the space bar, the computer starts at the top and rolls another character.
For all you word game fans, here is our program to compute simple scrabble scores.
In SCRABBLE, each letter has a letter score (LS), as follows:
A = 1 G = 2 B =3 H =4 C =3 I =1 D =2 J =8 E =1 K =5 F =4 L =1
We will put these 26 letter scores into an array of subscripted variables, as follows.
LS(1) = Letter Score for A = 1
LS(2) = Letter Score for B = 3
LS(3) = Letter Score for C = 3
LS(4) = Letter Score for D = 2
LS(5) = Letter Score for E = 1, and so on, down to:
LS(26) = Letter Score for Z = 10
Here is the first part of the program.
100 REM ** WORD SCORES 110 DIM LS(26),WORD$(50),L$(1) 200 REM ** CLEAR SCREEN 210 PRINT CHR$(125); 300 REM ** READ LETTER SCORES INTO ARRAY LS 310 FOR K=1 TO 26 320 READ LS:LS(K)=LS 330 NEXT K 340 DATA 1,3,3,2,1,4 350 DATA 2,4,1,8,5,1 360 DATA 3,1,1,3,10,1 370 DATA 1,1,1,4,4,8 380 DATA 4,10
Next we will ask for a word, find out how long it is, and initialize the word score to zero.
400 REM ** ASK FOR A WORD 410 PRINT: PRINT "YOUR WORD"; 420 INPUT WORD$ 500 REM ** WL IS LENGTH OF WORD 510 WL=LEN(WORD$) 600 REM ** START WORD SCORE AT ZERO 610 WS=0
The word score is the sum of the letter scores in a word. If a word contains stuff other than letters, we want to ignore it and use only letters. Here is the part of the program that computes the word score. Lines 730 and 740 tell the computer to ignore characters that aren't letters.
700 REM ** COMPUTE WORD SCORE 710 FOR L=1 TO WL 720 L$=WORD$(L,L) 730 IF ASC(L$)<65 THEN 770 740 IF ASC(L$)>90 THEN 770 750 K=ASC(L$)-64 760 WS=WS+LS(K) 770 NEXT L
D2 R1 A1 G2 O1 N1
W4 I1 Z10 R1 D2 H4 B3 B3 I1 T1
Lines 720 through 760 are done for L = 1, L = 2, L = 3, and so on up to L = WL. Remember, WL is the length of the word.
Lines 720, 730, and 740 pick out the L character of the word and check to see if it is a letter. If not, lines 750 and 760 are skipped.
If the character is a letter, its ASCII code will be a number from 65 (for A) to 90 (for Z). Thus, in line 750, K will have a value from 1 (for A) to 26 (for Z).
In line 760, the value of K is used to add the appropriate letter score from the array LS to the old word score to obtain the new word score.
All that's left to do is print the word score and tell the computer to report back for more work.
800 REM ** PRINT THE WORD SCORE 810 PRINT "THE SCRABBLE SCORE IS ";WS 900 REM ** GO FOR ANOTHER WORD 910 GOTO 410
Suppose, instead of the letter scores used in Scrabble, you want a different set of letter scores. Easy-just put the letter scores you want in the DATA statements in lines 340 through 380.
A variation. Assign letter scores as follows.
M=41 S=67 Y=97 N=43 T=71 Z=101 O=47 U=73 P=53 V=79 Q=59 W=83 R=61 X =89
Do you recognize the numbers? They are the first 26 prime numbers. Now, modify the program so the word (WS) is the product of the letter scores. For example,
Word Score for CAB = 5 x 2 x 3 = 30
Word Score for DOG = 7 x 47 x 17 = 5563
A number greater than 1 is either a prime number or a composite number. A composite number can always be written as a product of prime numbers. for example,
60 = 2 x2 x3 x5
175 = 5 x5 x7
The first ten composite numbers are 4, 6, 8, 9, 10, 12, 14, 15, 16, and 18. For these, or any larger composite number, can you find a dictionary word (not an abbreviation) whose word score is equal to the composite number? Here are some examples.
NUMBER WORD WORD SCORE 6 ab 2 x 3 = 6 12 baa 3 x 2 x 2 = 12 14 ad 2 x 7 = 14
Carry on! Remember, no abbreviations. Can you find a word for every composite number up to 100? How close can you get to 1000? To 10,000? To 100,000? To 1,000,000?
MUSIC FROM WORDS
Make music from words or from any string of letters We challenge you to write a program to:
(1) Assign 26 pitch numbers to P(1), P(2), P(3), through P(26). Each pitch number must be a whole number from 0 to 255.
(2) Ask for a word or phrase. When someone enters a word, phrase, or any string, put it in WORD$.
(3) For each letter of WORD$, play the pitch that corresponds to the letter. For A, play P(1); for B, play P(2); for C, play P(3); and so on-for Z, play P(26).
(4) Ignore spaces. In fact, ignore everything except letters.
(5) After playing a tone for each letter, go back and ask for another word or phrase. Or, play the same stuff again and again until people yell, "Turn that BLEEP thing off!"
Is your name musical? Is MATHEMATICS melodious? Can you contrive some tuneful talk?
What would you like to see in DragonSmoke? Send requests to George and Bob, P.O. Box 310, Menlo Park, CA 94025. If you want a reply, enclose a self-addressed, stamped envelope.