Code Project – JavaScript +AI – TIAI Quest I

On the last episode of TWIT, Harry McCracken, a fairly regular panelist and The Technologizer, was a guest and mentioned he had used Claude Code to update an old game he had made in BASIC as a web version using Claude Code. He wrote about it here.

Anyway, It gave me the idea of basically, doing the same, for the little RPG thing I had made for my TI-85 Calculator in High School.  It was interesting enough that I had distributed it a bit to other people in school who played it as well, which was tricky of course because you had to have a cable to do a communication link up to copy these things.   They did make a cable that would let you connect your TI calculator to a PC and dump it’s memory, but I didn’t acquire one until after leaving High School.  Which leads me tot he main difference between my project and Harry McCracken’s project.  I don’t have the original code to use as a base, just, the memory of what the game was.

Fortunately, the game was pretty simple, mostly due to memory constraints of the TI-85. You leave town, fight a monster (The first game only had two), earn experience and gold, buy better weapons, and at level 20, you can optionally face the Dragon Lord to win the game.  Actually in the original you had to face the Dragon Lord I think, in this version, it’s optional.  You can keep grinding levels killing Goblins and Bats if you want.  

For this updated version, I described the basic game play loop and built on it from there.

Decades ago in high school I made a simple text rpg on the TI calculator. I would like to recreate a web version. Unfortunately I do not have the old code so its just being build from scratch. The basic game play loop to build on.

Player is in The Town.

Player can rest and restore HP in town.

Player starts with a Wooden Sword, but can but better swords, Iron, Steel, Silver, in town, for increasing cost.

Player can leave the town.

Leaving just starts a random encounter with either a bat (easy) or a goblin (harder). Battles award some gold a d experience based on difficulty.

For now, battles are simple, attack, run (return to town). Running has a low chance to fail. Attack does random damage based on the equipped weapon. The enemy.should then retaliate with some random amount of damage to the player.

If the player reaches zero health, its game over.

Lets start with that and.build from there.

That was the initial prompt, with follow ups.

Ok, lets add levels with experience needs on a sliding scale, starting at 5xp. Each level should increase player HP a bit.

Ok, Can we swap the Rest and Leave Town buttons, because it would make gameplay smoother.

Ok, I’d also like to add a “Days” counter. It doesn’t really do anything at the moment but count up. Each time you leave town or rest, it should increment by one. Also, can we increase the rest HP to 20 (I believe it’s currently 10)

That third iteration adding the days counter, was mostly to create a sort of “score” mechanism.  Because you can basically just fight and rest and even though it doesn’t do anything, it sort of adds fake urgency of “Boy I’ve been doing this for 200 days and the townsfolk are still in need.  I also made it a bit more meaningful later by adding an Inn mechanic, which is mostly useful for saving days at the cost of gold.  Anyway, just for the record or whatever, the follow up prompting was… 

So for this version, which sort of simulates the original one, at level 20, you would go fight the Dragon Lord end boss. Let’s add that. It should be harder, but not impossible to win by level 20.

It spit out a bunch of math about levels and HP here to figure out a good power level for the Dragon Lord.  Which ended up being way too strong, so I later manually nerfed the power level, because even pushing up to level 25 meant losing that fight.

Ok, it gets a little dull after level 10, which i around when you get th Silver Sword. Can we adjust the overall experience spread so that level 20 occurs around where level 12 does now.

Another QOL improvement.  You would end up with enough gold to buy the strongest weapon at level 10, but the scaling experience level made getting to level 20 a slog.  The game play is not THAT compelling.  It spit out a bunch more math as well, for how much experience the player would have at level 20, and what a good algorithm would be to determine needed experience to get to level 20.  This was also where I added the Inn mechanic, which heals you fully, at a cost of 1 gold per 2 HP.  And only costs a day, as opposed to simply resting, which always heals 20 HP, and takes one day per 20 HP, but it’s free.  FWIW, I will probably change this a bit manually so it heals 1 HP for 2 gold, because you still end up with way more gold than you need, and I’d like to have a bit of a gold sink.  

Also, I don’t know what the current ratio of Bats to Goblin spawns is, but can it be adjusted to be a function of level. Like at low levels, you will much more likely enounter bats, but by level 18-19 and beyond, you will encounter almost entirely Goblins

Another QOL improvement, and it sort of give the “feeling” of progression when playing.  I’ll discuss the sequel game a bit later, but it’s a mechanic that I believe was in the sequel as well.  Basically. at early levels, you cannot defeat Goblins, at all.  They hit too hard, you hit too soft.  So you just end up running from them.  And at high levels, there is an opposite problem, you one shot the bats, for basically no experience.  With only two enemies, it’s not perfect, but this new mechanism bases encounter rates on your level, so at low levels, you get more bats (but can still get a Goblin), and at high levels, it’s almost all Goblins.  This mechanic will work better in the sequel game, which I’ll discuss later here.

These last couple of prompts broke some of the functionality, so I had to do some debugging.  The buttons stopped working, the shop stopped loading, there was some missing syntax.  Also while troubleshooting this, I got a funny bug where the shop would grow larger every round.  Which resulted in an amusing prompt of “Ok, now it keeps adding swords to the shop.”

After fixing these bugs, the game pretty much ended int he state is is now, and was complete.  I didn’t want to get too ambitious adding features for a few reasons.  One, I wanted to replicate the original calculator game experience as much as possible.   This version does this, though it looks “prettier”.  The original was black and white pixels on  small calculator screen, mostly, the enemies were hand drawn pixel graphics, and cost a ton of storage, which is why there were only two enemies and the end boss.  The game also ran off the 5 Function keys across the bottom of the screen to issue commands. 

So on the game name, before I talk about the sequel, which is not available yet, but I plan to recreate it as well.  The original game was called Dragon Quest.  Because “Dragon Warrior is cool, I want to reference that.”  The irony here is, and I didn’t know this at the time when I was like, 13 or 14 or whatever, in High School, in Japan, Dragon Warrior, is called Dragon Quest.  So, I am not making a commercial release here, but now that I know better, I want to give it a better name.  So after a bit of thinking, I went with TIAI Quest, pronounced “Tee Eye Quest”.  For the TI in TI-85.  BUT It’s also a reference to TI (Calculator) + AI (as in it’s made by AI).  

See, it’s it clever and stupid?

So the sequel, which originally would have just been, “I kept iterating on the first game”.  I dumped the graphics, because they were costly on space, which was a problem for this game, but this also wasn’t the only thing I had on my calculator.  I had some other simple games I or others had made, and a fake “Windows” program I’d made.  So without the graphics, that made space to add more to the game itself.  The biggest change was more monsters.  I think there were like 20, and some would not appear until higher levels.  I’d also added a potions mechanic, to heal in battle, and to restore MP because the sequel also had a simple magic system.  I believe it also had mini boss Dragons every 5 levels.  I want to say there was also armor to buy that would increase defense.

I hope to iterate on this base game, now that I have the “engine”, and add a lot of this functionality.

Maybe all of this will spur some ambition and I’ll actually make/finish the third game in the series, that I had started on in college.  Instead of being on the TI-85 Calculator, it was written in C++.  Being on a PC removed all the memory constraints and the third game had an actual map to explore.  I have code around somewhere for the base map, which you can move around using simple directional commands N/North, S/South, etc.  It played a lot like an Interactive Fiction game with random RPG style encounters, all in text.  I actually briefly a few years ago started adapting this code to Python instead of C++.  Having a map also meant being able to add actual points of interest with bosses and items to gather.

Anyway, after all that rambling, I should probably point you to the game, which is playable here:

TIAI Quest I

Leave a Comment

Comments

No comments yet. Why don’t you start the discussion?

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    This site uses Akismet to reduce spam. Learn how your comment data is processed.