Capstone: Final

Improved Letter Bank Generation

Before tackling the game’s AI, I noticed a subtle issue with how the Letter Banks generated letters. Not all Letter Banks were guaranteed to spell a valid word. Before, I generated a small list of random words and weighted each of the 26 possible letters based on their frequency in the list. The lists in question ranged from 3 to 10 words long. With larger word counts, it would be more likely that not all words in the list can be spelled using the possible letter candidates and would confuse what letters should be prioritized. The former approach would be problematic for AI later, so I decided to take a more efficient approach. I scrapped the possible word list functionality when defining what letters to spawn, and just had the computer pick one word at a time. Each time a word is picked, the number of absent letters are added to the Letter Bank ONLY if they do not exceed the number of empty slots in the Letter Bank. The process continues until there are no more empty slots in the Letter Bank. Here is an example of this concept, assuming that the Letter Bank is currently empty:

Word: READ, Missing Letters: 4, Letter Bank: R E A D _ _ _

Word: BEARD, Missing Letters: 1, Letter Bank: R E A D B _ _

Word: BREAD, Missing Letters: 0

Word: KIND, Missing Letters: 3, INVALID WORD, TOO MANY MISSING LETTERS

Word: JARS, Missing Letters: 2, R E A D B J S

I also added a feature that allows the player to see what letters each wizard has.

Improving Wizard Art

The wizards looked a bit basic and uninteresting at first, so I wanted to give a rough change to each wizard’s design. So, I worked on more detailed sprites for the hero and enemy wizards. The final results in this step looked like this:

Adding Juice to Letter Pieces

I felt that clicking on a Letter Piece was rather abrupt when transferring from and to banks. So, I added a smooth transition animation using linear interpolation (lerp) when each Letter Piece transfers. Also, I applied that same animation technique to when a word is spelled to cast an action. A video demonstrating these changes is below:

Enemy Wizard AI

Since the player can spell words, I wanted the enemy wizards to do the same. With the new approach I took in the previous step and making a script that made a list of possible words that any wizard can spell, all I had to do was have the enemy pick a number of random words from that list and intelligently select which word to spell. Then, the enemy selects a target based on a combination of two checks: hit point loss ratio and random chance. I got it to work the way I expect, and some footage demonstrating this is below:

Next Wave of Tweaks

I made two changes to the game up to this point:

  1. I decided to change how a wizard’s health is displayed to the player. Displaying each wizard’s health via text was merely a placeholder. I have now added health bars for each wizard, to more clearly convey to the player the relationship (ratio) between a wizard’s current health and max health. Text is still maintained to display the current health ONLY.
  2. I have added functionality for custom weights in which letter types are selected and created for any Letter Bank. I create and store a weights array for each Letter Bank in which each entry represents a new array which stores the following: Letter Type, Weight. EXAMPLE: [ [NEUTRAL, 60], [DEF+, 20], [POISON, 20] ]. The total weight of all entries are calculated and a letter type is selected based on RNG and its weight. Now that I can define custom weights for possible letters in each Letter Bank, I can assign any combination of letter weights to any one wizard before its Letter Bank is created. This gives me more design flexibility as specific wizards behave differently and their letter generation patterns can reflect their theme, character, or skills.