Pre-post edit: Wall of text.
Fair warning.Could you actually code a Perplexicon-playing AI? (In theory.)
That depends, to make an NPC-like AI for a melee orientated character would be easier. Have it roam, possibly offer "an alliance" (either no-violence or aid-on-trouble) to the first mage to discover a ("safe") material word and a weapon word, then have it target players based on a perceived "weakness" (injuries/stats/has weapon?) and then either just use the basic "attack random body part" sort of system most of us do anyway or maybe have it develop preferences, maybe based on "of all the battles it has perceived, what attacks ended it the quickest in the attackers favor?" (a sort of weighted database sampling at it's core, but avoids the "
local maxima" problem of some learning algorithms. Would have it use the most effective method discovered. Have it occasionally use random moves and it might even develop a better strategy!
Magic on the other hand, requires some more hard-coding behavior. Like "teaching" it how to "science". How to discern material/form/effect/targeting words. It would need to have a hard-coded understanding of what kind of words are "offensive", like fire or black holes. Possibly each with a weight to show what's better than what (fire /= all-consuming-void!). An understanding of what targeting words can be used to target an opponent, and what can be used to augment, or defend one's self. That sort of thing.
We have this knowledge (mostly) by virtue of our education and learning as we grew up, but fortunately the AI only needs a relatively small subset of this to operate effectively, albeit simply.
I'd love the challenge actually. I also would LOVE to put in some form of computer controlled NPC/Ai profile system into my toolkit, and have planned to for a while, just have to put in everything else first
new Spell mySpell;
ForEach(PoolAvailable) {
mySpell.AddToSpell(ChooseRandomWord());
}
Cast(myspell);
*shudders*
...
On first impressions that was... I code in Java so that was immediately painful, but honestly not too bad a way of doing it I guess.
I started to write a function below:
public void randomScience() {
// Lets code in Java! (This is a comment)
for (int i = 0 ; i < me.getPool() ; i ++) {
// This is a for loop, increment a variable called "i" from zero until we have looped over all of our pool points we have to spend.
Spell spellVariable = new Spell();
// Make a new "Spell object" of type "Spell" (duh), and lets call it spellVariable.
...
Until I realised I was just basicly going to do what you were doing.
Then wanted to add code to check if word was already known, and to only science new ones, but not loop forever if no unknown words exist, and to evaluate the spell result to determine what it was (even if incomplete, as in you know it is a form word, but not which one...
...
Yea.