And Then It Turned on Me!


SpaceTime-FirstAIAttempt

I talked about the entity controller last week, and this week I’m going to talk about it again. Specifically I’m going to talk about thirty lines of code and a public boolean. That boolean is named “Is Human”

The result is shown in the video above, and despite being very rudimentary it was surprisingly effective at offering fun opposition.  Both my kids played against this first pass A.I. and lost in close games.

I then, for amusements sake, decided to spring this A.I. on the most experienced player of the game other than myself. We often test things out by fighting each other, but this time, when I picked up the controller as normal I didn’t ever bother touching it. Ben was under the impression he was still fighting me, Instead he was taking part in a space battle turing test. Ben fought hard, employing many of the fancy overkill weapons he had created, but alas he was soundly beaten 5-2.  It was only at this point that I revealed I wasn’t playing at all. Ben was as you’d expect both shocked and amused, and then demanded a rematch against Eliza.

Ben lost again, but at least it was 5-3 this time and one of the losses was him blowing himself up by crashing full force into a wall. For the sake of winning I joined in as the second pilot on his ship, manning the turret. We won that game after a glorious battle.

This version of the A.I. is very simple, and would only work on  levels that have no dead ends. The A.I. doesn’t have any pathfinding in the traditional sense, just object avoidance which amounts to : If i’m going to crash, slam on the break  and put as many thrusters as possible in the direction of motion to slow me down. Meanwhile, move into attack range and move around any obstacles that come between me and my target.

Apart from that the A.I. Charges it’s weapon and shoots with a small random inaccuracy, and if close enough engages the turret.

It works surprisingly well being both fairly natural looking and a good challenge. The obvious visual difference to me is that the A.I. is far more comfortable drifting than human players are. When it is moving in a manner it is happy with it stops interfering whereas humans tend to (but not always) fiddle with the direction and the thrust. It’s also simulating two people on the ship which means it is pretty good with the turret.

In future, I’m hoping to move away from single behaviour in A.I. play style and also so that the A.I. will change behaviour depending on the weapon loadout. My current thinking is that this lends itself to a multi delegate pattern which will be a nice challenge. For now however it isn’t anywhere near the top of my priority list so it’ll have to wait.

The week after I did A.I. the coding was mostly about sound,  so I might just skip talking about that partly because it doesn’t lend it’s self to pictures well, and partly because I’ll use all the wrong terminology and just sound like the uneducated buffoon that I am. Until then. Do have a poke at us on the social media. TwitterFacebook, and Youtube. Bye for now.

Comments are closed.