April's Program: RMS

Are there any D&D folks in the audience? Come on, you know who you are…

RMS, 1983Are there any D&D folks in the audience? Come on, you know who you are. Past or present doesnít matter, just if you know what Iím talking about. Why, you ask? Because RMS, Aprilís program of the month, will use your ZX81 to build monsters. Any fledgling DM could then use these creatures in their latest campaign. Elves and humans will cringe at your originality and cruelty.

Kidding and dragons aside, RMS or Random Monster Statistics, was one of my attempts at using the ZX81 for things not related to computers. I always enjoyed playing D&D and tended to buy up all the books and modules I could. Naturally, this would eventually bleed over into my programming habit. RMS is just that, a way to generate monster characteristics that theoretically could be used in a game of D&D.

Of course, I never actually used these. The statistics are pretty crude and seriously arenít very useful. You still have to enter in the names yourself, which seems odd that I required there. From there you get the AC (armor class) modifier, HD (hit dice although I think itís really hit points or HP), color, AT (number of attacks), and attack damage (primary and alternate). These are purely random numbers and, in the end, there is no logic or relationship. You can fill the screen with monsters, then copy the statistics to the printer, start over, or quit. I guess you could do this until you found something that looked good, but ultimately without a description, random monster statistics really isnít that valuable.

As a program, though, there is some interesting stuff going on under the hood. Although I said there was no logic, there is some logic in how the program generates the monsters. RMS generates all of the statistics using a FOR loop and a single variable assignment. Using the ZX81ís Boolean logic, I modified the random number based on the value of B. It is an interesting method to generate 7 variables when writing seven lines of code would have been just as short, and probably easier to read. Itís hard to believe that at 13 I would use such a complex routine. But I did and it works.

It works so well, youíll find me using it over and over. I used it to set the color and size of the monster. When printing the statistics, I used it to format the output. In fact, the only place I didnít use it was when dealing with the key press at the end of the routine.

One other cool think I used was string splicing on static strings. A static string is just a bit of text in quotes. Generally, you would use the ZX81ís splicing routines against variables. However, there is nothing to prevent you from do it with a static string. In line 100, youíll find this code: "--+-"(INT (RND*4+1)). Basically, this prints a negative or positive sign in front of the AC statistic. Since there are three minus, 75% of the time it is negative. I have to admit it threw me at first when typing this in since I donít normally do that in programs today. However, it is actually a pretty good solution to the problem.

Although RMS isnít a very useful if you wanted to play D&D. It is a good experiment with the ZX81ís interesting math routines. Although some programing languages today have similar functions, I wouldnít recommend using them. Although interesting and perhaps a good choice when writing tight code on the ZX81, it is horrible to read. In modern languages, it is better to write readable code.

Comments on this article:

No comments so far.

Write a comment:

Type The Letters You See.
[captcha image][captcha image][captcha image][captcha image][captcha image][captcha image]
not case sensitive