Thursday, September 12, 2013

Year 13 - Day 255

Still lots of combat work going on.  I'm doing some code refactoring as well while I'm working on the Retargeting Algorithm.  So far it works like this:

1.  Ship needs a new target.
2.  Is there only one ship left on the opposing side?  Choose that ship as target.  End.
3.  Get a list of all opposing ships.
4.  Sort the list by distance ascending.  Multiple ships at the same distance are sorted randomly.
5.  Pick the closest ship as the first "potential" new target.
6.  Check targeting preference for ship.  Does it prefer to target Armed or Unarmed.
7.  Check potential target vs. targeting preference.  If it does not match, choose next ship in list.  If it does match, set this ship as the Final target.
8.  After all ships are checked and none match preference,  set the original potential target as the Final target.

What this means is if the ship prefers to target Armed opponents, then if the closest ship is Unarmed it will go to the next closest ship and see if it's Armed.