Everyone Wrote This Program on the Commodore 64
Introduction
There were some programs that seemed almost inevitable on the Commodore 64. If you played Advanced Dungeons & Dragons and knew even a little BASIC, sooner or later you probably tried to write a character generator.
I wrote one myself. The idea seemed obvious. AD&D characters were created by rolling dice, recording numbers and applying rules. The Commodore 64 was sitting nearby with a programming language ready the moment it was switched on. Why keep rolling the dice when the computer could do it for you?
Years later, I found evidence that this was not an isolated idea. In an interview published in the March 2026 print edition of Retro Gamer, Phil King recalled doing some BASIC programming, including an AD&D character generator. That small comment immediately resonated with me. Of course he had written one. Many of us did.
Two Hobbies That Naturally Belonged Together
BASIC programming and fantasy role-playing occupied much of the same cultural territory during the early home-computer era. Both rewarded patience, imagination and an interest in systems.
AD&D presented the player with tables, attributes, modifiers, classes and probabilities. Commodore BASIC offered variables, loops, conditions and random numbers. One system described imaginary people. The other could automate the process of creating them.
Character-generation tables appeared in the AD&D rulebooks, while magazines such as Dragon regularly published optional rules and utilities that inspired home programmers.
The character generator was therefore more than a programming exercise. It was a useful program connected to something the programmer already enjoyed. Instead of printing a greeting or displaying a multiplication table, the computer could produce a fighter, cleric, magic-user or thief ready for an adventure.
The Commodore 64 Invited You to Program
Switch on a Commodore 64 and the machine presented its familiar blue screen,
a flashing cursor and the word READY. There was no separate
development environment to install. Commodore BASIC V2 was already there.
Many readers also learned by typing published listings from magazines into their Commodore 64, correcting mistakes as they went.
A beginner could type a few numbered lines, enter RUN, and see an
immediate result. That directness encouraged experimentation. Programs grew one
idea at a time.
A character generator was an ideal next step after the simplest introductory exercises. It required only a few programming concepts:
- variables to store ability scores;
- loops to roll several dice;
- random numbers to imitate dice throws;
- text labels to identify each attribute; and
- conditional statements for classes, races or bonuses.
The program could start with six numbers and gradually become more ambitious. A young programmer might add character names, alignment, hit points, saving throws, equipment or class restrictions. The rules of the game provided an endless list of possible improvements.
Rolling Three Dice in BASIC
A traditional AD&D ability score could be generated by rolling three six-sided dice and adding the results. On the Commodore 64, the essential idea could be expressed in only a few lines:
10 S=0
20 FOR D=1 TO 3
30 S=S+INT(RND(1)*6)+1
40 NEXT D
50 PRINT S
The expression RND(1) produces a fractional value from zero up to,
but not including, one. Multiplying it by six creates a value between zero and
just under six. INT removes the fractional part, and adding one
produces an integer from one to six.
Run the loop three times, add the results, and the computer has performed the equivalent of rolling three ordinary dice.
This small piece of code taught several lessons at once. It demonstrated a loop, mathematical conversion, accumulation and the use of a pseudo-random number generator. More importantly, it produced something recognisable and useful.
A Simple AD&D Character Generator
The next step was to generate all six familiar ability scores. A compact Commodore 64 BASIC program might look like this:
10 X=RND(-TI)
20 DIM A$(5)
30 A$(0)="STRENGTH"
40 A$(1)="INTELLIGENCE"
50 A$(2)="WISDOM"
60 A$(3)="DEXTERITY"
70 A$(4)="CONSTITUTION"
80 A$(5)="CHARISMA"
90 PRINT CHR$(147)
100 PRINT "AD&D CHARACTER"
110 PRINT
120 FOR A=0 TO 5
130 GOSUB 500
140 PRINT A$(A);": ";S
150 NEXT A
160 END
500 S=0
510 FOR D=1 TO 3
520 S=S+INT(RND(1)*6)+1
530 NEXT D
540 RETURN
This is not a complete implementation of any particular AD&D ruleset. It is the sort of practical foundation from which a home programmer could continue building.
The six labels are stored in a string array. A loop moves through the array,
while a small subroutine rolls three dice and returns the total. The screen is
cleared with CHR$(147), another familiar feature of Commodore
BASIC programming.
The Commodore 64 Random-Number Problem
Random numbers were also one of the details that could puzzle a beginner.
Commodore BASIC V2 did not provide a convenient RANDOMIZE command
like some other BASIC dialects.
The RND function generated pseudo-random numbers. They appeared
random, but they came from a mathematical sequence. If the generator began from
the same starting point, it could produce the same sequence again.
This mattered in a character generator. A program that repeatedly produced familiar combinations of attributes did not feel very random, even when the dice routine itself appeared correct.
One common Commodore technique was to initialise the generator with the system timer:
10 X=RND(-TI)
The variable TI counted the machine's clock ticks since startup.
Passing its negative value to RND gave the pseudo-random generator
a changing starting value. It was not true physical randomness, but it was
generally sufficient for rolling imaginary dice.
Discovering this detail was part of learning the machine. The problem encouraged programmers to consult manuals, magazines, friends and other people's listings. A small obstacle in an AD&D utility became a lesson in how computers actually generate apparent randomness.
Everyone Built a Slightly Different Version
The title of this article is deliberately broad. Not literally every Commodore 64 owner wrote an AD&D character generator. Yet the program was such an obvious meeting point between two popular hobbies that many people arrived at the idea independently.
Each version probably reflected its author. One program rolled six basic attributes. Another selected a class. A more ambitious version checked whether the character qualified as a paladin, ranger or illusionist. Someone else might have added hit points, equipment, names or a routine to save the character to disk.
The program was never truly finished because the rules always offered another feature to automate. It could grow alongside the programmer's knowledge.
That made it an unusually effective learning project. The programmer already understood the desired outcome. The challenge was translating familiar game rules into instructions the computer could follow.
More Than a Dice Roller
Looking back, the character generator represented something larger than its modest BASIC listing. It was often one of the first occasions when a home computer became a personally useful tool.
The program was not supplied by Commodore. It was not purchased from a shop. It existed because the owner had noticed a repetitive task and realised that it could be automated.
That same instinct led Commodore 64 owners to build address books, cassette catalogues, household budgets, quiz games and high-score tables. The programs were simple, but the underlying idea was powerful: the machine could be adapted to the owner's life.
This culture of experimentation is central to the wider story of the Commodore 64. The computer was a games machine, a music synthesiser, a communications terminal and a programming laboratory. Its limitations did not prevent creativity. They gave creativity a clear set of boundaries within which to work.
Explore More Commodore 64 Articles
The AD&D character generator was only one expression of the inventive culture that grew around the Commodore 64. The machine also inspired distinctive music, unusual software, memorable advertising and a generation of users willing to modify almost everything placed in front of them.
Continue exploring with the Commodore 64 games and computing journal, listen to the machine through the High Voltage SID Collection, or revisit the marketing that introduced it to the world in Eight of the Best Commodore 64 Television Commercials.
For a closer look at the culture of experimentation, read The Commodore 64 Had Jailbreakers Before the iPhone. You can also explore the machine's famously slow companion in The Commodore 1541 Disk Drive.
Conclusion
An AD&D character generator was a nearly perfect Commodore 64 project. It joined a popular game to an accessible programming language and turned abstract BASIC commands into something immediately useful.
Phil King's recollection of writing one felt familiar because I had followed the same path. Many other home programmers almost certainly did as well. We were working on different computers in different rooms, yet arriving at remarkably similar programs.
The character generator was small, personal and probably never distributed. That is precisely why it matters. It captures the moment when a Commodore 64 owner stopped being merely a computer user and began telling the machine what to do.
Collector's Market
Commodore 64 games remain widely available on the collectors' market, ranging from inexpensive loose cassettes and disks to boxed releases, cartridges, manuals and complete software bundles. The eBay listings suggest a market with plenty of ordinary titles, but also a steady supply of more desirable items, including original cartridges, large-format game boxes, compilations and games from well-known publishers. Condition makes a considerable difference: tested software with clean packaging, instructions and inserts will usually attract more interest than an unverified loose tape or disk. For buyers, the safest approach is to check the software format, regional compatibility, completeness and seller testing notes before purchasing. For collectors, the appeal is not only in playing the game, but in preserving the artwork, packaging and physical culture that once surrounded the Commodore 64.
Gallery
Curator's Notes
This article began with a small remark in the March 2026 print edition of Retro Gamer. Phil King recalled writing an AD&D character generator in BASIC, and the comment immediately struck a chord with me.
I had written one too.
That was the interesting part. The program was not especially unusual, yet that was precisely why it mattered. AD&D was popular, BASIC was built into the Commodore 64, and character generation depended on dice, numbers and rules. The idea almost suggested itself.
I suspect many young programmers independently arrived at the same solution. We were not trying to create software history. We were simply using the computer to support another hobby we already loved.
The BASIC examples in this article are deliberately small. They are there to show how easily the idea could begin, and how quickly a few lines of code could grow into a genuinely useful home program.
For me, that is one of the enduring pleasures of the Commodore 64. It did not merely run software. It invited its owner to make something.
Looking Back
One of the fascinating aspects of the 8-bit era is that these programming projects were rarely assigned by schools or employers. They emerged naturally from curiosity. A teenager who wanted a better game, a more useful utility or simply to understand how a computer worked often had little choice but to build it themselves. The journey usually began with a simple guessing game or calculator before progressing to adventure games, sprite animation, music players, databases and eventually machine-language programming.
Because the hardware imposed such tight limitations, every project became an exercise in creative engineering. Memory had to be managed carefully, graphics reused wherever possible and algorithms written efficiently. Many professional software engineers trace their problem-solving skills back to these early experiences, where success depended more on ingenuity than processing power.
Although today's computers are vastly more capable, these classic beginner projects remain surprisingly relevant. They teach fundamental programming concepts—logic, data structures, user interaction and debugging—in a way that is approachable and enjoyable. More importantly, they capture an era when the computer was not simply a device to consume software, but an invitation to create it.
Reader Guide
The following material expands on the terminology, historical context, technical concepts, and related reading connected to this article.
Glossary
- BASIC
- Beginner's All-purpose Symbolic Instruction Code, the programming language that introduced millions of people to software development during the 1970s and 1980s. Almost every home computer shipped with BASIC built into ROM, making it the natural starting point for young programmers.
- Home computer
- Affordable personal computers designed for domestic use rather than business or scientific applications. Systems such as the Commodore 64, ZX Spectrum, Atari 8-bit family, BBC Micro and Apple II inspired a generation to write their own software.
- Text adventure
- An interactive game where players type commands such as "GO NORTH" or "TAKE KEY" to explore a fictional world. Writing adventure games taught beginners about program structure, variables and decision making.
- Sprite
- A small movable graphic used to represent characters or objects on the screen. Hardware sprites, available on machines such as the Commodore 64, made action games smoother and more visually impressive.
- High score table
- A ranked list of the best game scores achieved by players. Many young programmers learned how to sort data and save information by adding high score tables to their games.
- Machine code
- The binary instructions executed directly by a computer's processor. As programmers gained confidence, many moved beyond BASIC into machine language or assembly language to achieve greater speed and control.
- Assembly language
- A low-level programming language that uses human-readable mnemonics instead of raw binary instructions. It provided much finer control over hardware and became the preferred language for many commercial games.
- Memory constraints
- The strict limits imposed by computers with as little as 16 KB or 64 KB of RAM. These constraints encouraged efficient programming and creative problem solving rather than relying on abundant hardware resources.
- Demo program
- A non-game program created to showcase graphics, sound, animation or programming skill. Demo programming became a competitive hobby and eventually evolved into the international demoscene.
- Source code
- The human-readable version of a computer program written by the programmer. Many magazines published complete source listings that readers could type into their own computers to learn how software worked.
Frequently asked questions
Why did so many people learn programming on home computers?
Home computers usually included the BASIC programming language when switched on, allowing owners to begin writing software immediately without purchasing additional tools.
What was the first program most beginners wrote?
For many people it was a simple "Hello World" program, followed by number guessing games, quizzes or small calculators before moving on to graphics and games.
Which home computer was best for learning to program?
There was no single best choice. The Commodore 64, BBC Micro, ZX Spectrum, Apple II and Atari 8-bit computers all introduced thousands of people to programming through accessible BASIC interpreters.
Did programmers really type programs from magazines?
Yes. Computer magazines regularly published complete source code listings that readers entered by hand. It was time-consuming but became an excellent way to learn programming techniques.
Why were games such a popular first programming project?
Games provided immediate visual feedback and combined graphics, sound, keyboard input and scoring, making them ideal projects for learning multiple programming concepts at once.
What is the difference between BASIC and machine code?
BASIC is a high-level language that is easy to learn, while machine code consists of instructions executed directly by the processor. Many programmers started with BASIC before progressing to assembly language.
How much memory did these early computers have?
Many popular home computers had between 16 KB and 64 KB of RAM, forcing programmers to write efficient code and make careful use of every byte.
Can these classic programming projects still be recreated today?
Yes. Modern emulators faithfully reproduce vintage computers, allowing newcomers to write BASIC programs and experiment with classic hardware without owning the original machines.
Do these old programming exercises still have educational value?
Absolutely. They teach problem solving, logical thinking, debugging and algorithm design without the complexity of modern software development environments.
What skills did people develop by writing their own programs?
Besides programming itself, hobbyists learned analytical thinking, mathematics, persistence, debugging techniques and an understanding of how computers actually work.
References
The following document was referred to when developing this article.
-
Magazine Craft Phil King
interview, Retro Gamer, March 2026 print edition, page 56
Disclosure
This article is provided for historical, educational, and entertainment purposes. Product names, trademarks, and copyrighted material are acknowledged as the property of their respective owners. Opinions expressed are those of the author based on personal experience and research, and no affiliation with or endorsement by the original creators or rights holders is implied.