• entries
271
969
• views
190028

# AI is... working... better

101 views

Hey everyone!

Sorry I have been neglecting my daily journal posts, I was just informed a few days ago that I was actually hired full-time at my job rather than part-time, so now by law I'm required to work at least 40 hours a week, which means an 8 hour day, which means not much programming is going on, but a lot of planning has been going on in my head, so when I do program, it's pretty sraightforward[grin]

AI (Part II)
In my previous AI entry, I described in vivid detail the AI engine of Angels 22, but in this one, I'll describe the results of implementing that system. Anyways, I implemented the system pretty much the same way I described in that entry, with a few minor modifcations (which are boring, so I'll leave them out). As it turns out, the system works pretty well, although in my haste to get something working, I ended up writing hacked up code like in the snippet below:

if(currentstate != TAKEOFF && currentstate != LANDING){for(int i = -20; i < 20; i ++){bool check = true;if((int)((plane->xpos)/32)+i<0)check = false;if((int)((plane->xpos)/32)+i >= plane->terrain.size())check = false;if(check && plane->terrain[(int)((plane->xpos)/32)+i] > plane->ypos -128){waypointy = plane->terrain[(int)((plane->xpos)/32)+i]+256;if(i < 0 && plane->angle > 90 && plane->angle < 270)waypointx = plane->xpos- 512;if(i > 0 && plane->angle < 90 || i < 0 && plane->angle > 270)waypointx = plane->xpos+ 512;PushState(PULLOUT);}}}

I can't even decipher what I wrote that code for, but judging by the pushing of the PULLOUT state at the bottom, I assume it's some sort of terrain avoidance thing I thought up late last night[grin] Anyways, it's going to take some time to get rid of that kind of stuff, but in the process I'm finding lots of tweaks that add performance and believability to the AI.

Visual Cues
Initially, I was having some trouble interpreting what the AI was thinking(ie. what state was it in, where was it heading, etc) when it did something stupid, so I coded up a quick visualization of the AI_Pilot's state, which is drawn above the AI airplane as you can see in the screeny below:

In this screen you can see me (lower right) flying with my wingman (upper left) flying in formation. The text above the AI plane tells it's currentstate, and the blue line shows it's current waypoint, which, in the FORMATIONFLYING state, is equal to 64 pixels above the player's position. I haven't gotten order giving to work yet, so the AI is locked to the orders it's given on initialization, so you can't tell him what to do yet, but if you let him loose with a ATTACKALL order, he'll rip up the level without much difficulty.

As you can see, I've been focusing on the AI as of late, so not many cool new visual features, but hopefully spending this much time focusing on AI will give the player a much more cohesive experience, and besides, what's an airplane game without player/wingman chatter?

Anyways, thats all for now, let us know what you guys think of the project so far, and we'll talk to you guys later! Peace Out!

Cool.

Can we get a demo now? [grin]

i know what you mean about the work... i try to blame my not programming on work :P i haven't programmed in 3 or 4 weeks, even though there have been times when i've had time

so in other words, don't slack (like me) and keep working hard, luving what you got!

Quote:
 Can we get a demo now?

All in due time.....[grin]

Quote:
 i know what you mean about the work... i try to blame my not programming on work :P i haven't programmed in 3 or 4 weeks, even though there have been times when i've had time so in other words, don't slack (like me) and keep working hard, luving what you got!

Yeah, sometimes I just get home and lack the willpower to sit down and code stuff.

## Create an account

Register a new account

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.