Monthly Archives: January 2012

Fighter AI and afterburners

Meanwhile… while working on the AI I added the potential for AI ships to evade their attackers or switch to target them. The evade maneuver had an issue, it needed a power boost, so I added in afterburners (been meaning to add these for a long time). The result – much more fun, both in terms of seeing the AI use these in combat and in terms of using them in combat myself. Obviously afterburners have a variety of uses, close in on a target, run away from a target, boost to reach the new gravity drive speed threshold, do a 180 then engage burners to slow the ship down :) Lots of fun. Combat feels more tactical and engaging now that there is an added ship function.

Have been running through a lot of fighter versus fighter scenarios in a small asteroid field, and its a lot of fun, very happy about this, the AI now has about 4 potential “attack patterns” sometimes it chose them at random and sometimes it somewhat intelligently (very small decision criteria) decides the best one out of the available options. Battles are much more dynamic with this and seeing the AI use afterburners as well.

Still a lot of work to do on the new AI initiative. I want to make larger ships more interesting in combat as well, plus I have to add in “dynamic speed” settings for ships, basically having the AI intelligently speed up or slow down to reach a target, based on distance and target’s velocity.

AI work – obstacle avoidance and turning

The big news is that I greatly enhanced obstacle avoidance, something I’ve been struggling with for years now. Did I ever tell you the time about my super crappy implementations of this? no.. well.. let me tell you they were super crappy. The previous method was (when an obstacle was in a ship’s path) was to simply tell the ship to go to a position above or below (depending on if the ship was nearer to the “bottom” or “top” of the obstacle) the obstacle until it could look at the destination without any obstruction, this worked most of the time unless the destination was positioned in such a way that looking at it from the above/below was impossible, in which case the ship would fly off into space. Pretty dumb and not anywhere close to release worthy.

Needless to say path finding is a huge issue and was a huge worry, this new system takes into account what is in the ship’s path, and intelligently plots a course to avoid it – based on math – figuring out the perpendicular to a vector, then projecting that vector outwards to find a safe position. Somehow the crazy thing works, even though my math skills are embarrassing.

The other neat thing that I worked on was giving larger ships different turning and speed parameters when their AI is active. Basically the larger the ship the more it will turn to face its destination before engaging its engines, also during these turns the larger ships will turn more so than pitch up or down, this makes them more very much different from small fighters and corvettes, further distinguishing them, giving them a more epic feel.

Lotsa happenings – gravity drive

Its funny because the more stuff is happening the less I update this blog. But I have to make a effort, at the very least for myself because I enjoy reading this stuff, its motivational and I go “ooh I remember when I did that… yeah…”

Recent work: re-wrote the “gravity drive” – prior to this gravity drive only functioned via autopilot, this is of course very lame, also the whole gravity drive process was pretty bland – select far away target, press auto pilot button, ship would stop, face target, and then accelerate. Another awesome thing here is that the new code is sooo much simpler than the old, and the old code was mix of AI and acceleration, very lame, it was some off the earliest code I’ve written and it shows.

Now you can manually “engage” gravity drive – first you select a “valid hop” – a large object that allows for the gravity drive to function, meaning that the map turns into sort of islands in the void, enabling for strategic/choke points, meaning much more interesting map design. You can still fly to any spot via the standard engines, but to quickly travel from spot to spot that’s why there’s the gravity drive. So anyway you select a valid hop, then you “initialize” the gravity drive (via keyboard or hud) and now you have to travel at three times the cruise speed to “engage” the gravity drive, at this point you accelerate 20 times the normal factor – until you reach your destination at which point the gravity drive disengages and you rapidly decrease your momentum, if the ship veers off course (you are still allowed any maneuver you want) and you get further away from your hop, then the gravity drive disengages.

The other limitation of the gravity drive is that it only works on the “nearest” hop, so you may have to jump to a hop nearer to your final destination, meaning that that intermediate hop is able to become more strategic.

I think that this new take on “warp” or “hyperspace” mechanic in space sims is pretty neat. There’s a few limitations that add to the game play, and allow for greater strategy (the need to go towards a valid object), but still allows for rapid travel between positions, no need to fly through boring empty space too much. It isn’t the tired “jump” mechanic where a ship disappears and reappears in a different spot instantaneously, while really convenient this is somewhat boring.

In other news: the AI work continues, and is progressing well, the light is at the end of the tunnel. Today I finished up basic target selection and order commands for the combat AI.

Happenings

Did an interview with True PC Gaming, you can check it out here. It was a bit harder than I thought putting my thoughts in writing. The interview also features new screen shots, showing the new art style. I’ve also added them to the media page on the main website here.

It was about a year ago that I first made the project public via this blog and the website. Its been a good year, hopefully this year will bring even more to the project.

AI work

I’ve started working on the new/enhanced AI. The primary goal is to give the AI the ability remember more than one task, as you can probably guess, the old AI could only remember one. This lead to a few problems mainly being that the AI was very inflexible, and that whatever task I gave it had to be complete in and of itself.

First up the inflexibility – say for example the player orders one of his/her ships to attack a object that is 1000 distance units away, but while the ship is flying towards that object it is attacked. Because the old AI only remembers one task at a time if the AI responded to the attacker it would forget the original order, because I want to give the player the ability of absolute command over ships in their arsenal, this meant that I had to tell the AI to ignore any attacker (the turret’s would defend the ship, but the ship itself wouldn’t respond) under these conditions (where the player directly orders a ship to perform an action, the ship would ignore everything else around it and try to do that action). But! If the AI can remember more than one thing, it can respond to things – in this example defend itself, and then afterwards continue onto the target that the player commanded it to. So giving the AI some memory is of clear benefit here.

The second issue is that the tasks had to be complete in and of themselves – this is actually an internal coding thing, so technically invisible to the player, however having each task be complete in itself means that AI tasks are prone to bugs, they are hard to save (for saving/loading), and that they are hard to add. So the new state of the AI is that it will be built up of small and reusable tasks that form larger ones.

For example this is how I stared coding what I called in code “AI Nodes”:
Idle node – set ship speed to 0
Wait node – use idle node until a timer expires
Turn to position mode – turn ship towards a specified point in space
Go to position node – use the turn to position node, and set the ship speed so that it can travel to the position
Go to object node – use the go to position node and update the position based on the go to object’s position
Follow object node – use the go to object node, when within distance of the follow object switch to the idle node.
Formation follow object node – like the follow object node, but instead of idling when near use the turn to position node to align with the followed ship, with some speed matching.

As you can see the go to position node uses the turn to position node. This very simple example shows how I can create more complex behaviors, eventually giving me the ability to set complex tasks, that are easy to arrange and create. For example: go to position abc, destroy this ship, pick up that object, and then return to position xyz. This could be useful for pirate raids, for civilian traffic, for trading ships, for scripted events, for boss battles, for cutscenes and other story elements – anything really.

The very very flight basics are in, what I’m currently working on now is the gravity drive changes for the AI and player controlled ships. All along I’ve been planning on not having the standard “warp” or “hyperspace” type mechanism in this project, instead what I call a “gravity drive” – a method of traveling at a high rate of speed, but not the boring already seen mechanics, instead ships can use the gravity drive to pull themselves (or as I like to think of it fall towards) large objects, making them choke points and giving them strategic value. These objects will be asteroid bases, large rocks, and potentially special “gravity field generating” stations and even maybe some special ships. So the player can either use standard engines to travel to a position, or can use the gravity drive to hop along from nearby large object to nearby large object until they get to their destination. So it basically calls for some basic distance comparison based mapping, which I’ve coded in tonight.

Next up more logic, the pull mechanism of the gravity drive, and better obstacle avoidance, then off to combat, and then off to intelligent node selection/addition/removal/management.