Building an AI

I’ve made a start on the AI spell selection code today. I’ve had a look through the old Chaos Funk code and I seem to have mislaid the very latest version, but also the code is such a horrible mess it’s practically unusable. So.. we’ll start again..

The spectrum original had a very simple AI and it had value scores for creatures and other spells precoded into the game. While this makes it easy to pick a good spell, it has the disadvantage that the score can’t be easily manipulated to suit the situation. For example if you have a weak wizard it’s sometimes better to cast something you can ride than a stronger creature that leaves your wizard unprotected.

To code this kind of flexibility you have to break down the stats of the piece that makes up the ‘score’ for each creature spell. In this way you can make rideable creatures become more highly rated if the wizard is not riding anything. This also means it’s easier to add new spells as well in the long run. I’ve just done the first version of this code and although it doesn’t take into account the spell chance, I’m pretty surprised by how well the final score compares against both our own perceived value of a creature and the chance it has of being cast. Here is the list of spells a computer wizard received and they have been pre-sorted alphabetically and then by spell chance:

name: giant_rat – rated: 15
name: orc – rated: 17
name: orc – rated: 17
name: orc – rated: 17
name: dire_wolf – rated: 30
name: goblin – rated: 26
name: goblin – rated: 26
name: horse – rated: 28
name: bat – rated: 29
name: crocodile – rated: 50
name: crocodile – rated: 50
name: eagle – rated: 49
name: gryphon – rated: 58
name: gryphon – rated: 58
name: gryphon – rated: 58
name: lion – rated: 56
name: unicorn – rated: 55
name: giant – rated: 79
name: green_dragon – rated: 94
name: green_dragon – rated: 94

The next step is to adjust the score function to take into account the situation, so making rideable creatures more attractive, or undeads, etc.. This is a bit harder! 🙂

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: