Specifically, I am talking about programming for this contest: <http://www.nodewar.com/about>

The contest involves you facing other teams with a swarm of spaceships in a two dimensional world. The ships are constrained by a boundary (if they exit they die), and they must continually avoid moons (who pull the ships in with their gravity). The goal is to kill the opposing queen.

I have attempted to program a few, relatively basic techniques, but I feel as though I am missing something fundamental.

For example, I implemented some of the boids behaviours (<http://www.red3d.com/cwr/boids/>), but they seemed to lack a... goal, so to speak.

Are there any common techniques (or, preferably, combinations of techniques) for this sort of game?

**EDIT**

I would just like to open this up again with a bounty since I feel like I'm still missing critical pieces of information. The following is my NodeWar code:

```
boundary_field = (o, position) ->
  distance = (o.game.moon_field - o.lib.vec.len(o.lib.vec.diff(position, o.game.center)))
  return distance

moon_field = (o, position) ->
  return o.lib.vec.len(o.lib.vec.diff(position, o.moons[0].pos))

ai.step = (o) ->
  torque = 0;
  thrust = 0;
  label = null;

  fields = [boundary_field, moon_field]

  # Total the potential fields and determine a target.
  target = [0, 0]
  score = -1000000
  step = 1
  square = 1

  for x in [(-square + o.me.pos[0])..(square + o.me.pos[0])] by step
    for y in [(-square + o.me.pos[1])..(square + o.me.pos[1])] by step
      position = [x, y]
      continue if o.lib.vec.len(position) > o.game.moon_field
      value = (fields.map (f) -> f(o, position)).reduce (t, s) -> t + s
      target = position if value > score
      score = value if value > score

  label = target

  { torque, thrust } = o.lib.targeting.simpleTarget(o.me, target)  
  return { torque, thrust, label }

```

I may have implemented potential fields incorrectly, however, since all the examples I could find are about discrete movements (whereas NodeWar is continuous and not exact).

The main problem being my A.I. never stays within the game area for more than 10 seconds without flying off-screen or crashing into a moon.