Complete.Org: Mailing Lists: Archives: freeciv-dev: April 2000:
[Freeciv-Dev] Goto for airplanes
Home

[Freeciv-Dev] Goto for airplanes

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Goto for airplanes
From: Thue Janus Kristensen <thue@xxxxxxx>
Date: Fri, 21 Apr 2000 01:02:51 +0200

This patch makes airplanes on goto automatically use cities and airbases
as waypoints.
It can handle both fighters and bombers, as well as planes with more
moveturn (fuel) (there isn't any in the current ruleset).
It does not handle helicopters, but could maybe be modified to do so I
think (by artificially setting the helicopter fuel to the number of
turns it can fly without dieing).

It basically works by planing a route between cities/airbase and then
using the ordinary do_unit_goto/find_the_shortest_path. (do_unit_goto has
been modified).
Also, because the planes sometimes stop in cities with movement points
left they do not lose focus in the client. So I added a
PACKET_ADVANCE_UNIT_FOCUS to do this.
If there exist alternate routes of equal length the algoritm chooses the
one with the most waypoint.
It is fairly efficient I think, though trying to do an impossible goto
will cause it a good deal of calculation. But as long as it is only used
juring the player turn this should not make a noticeable difference.
Having this goto is a good deal of the work required to make the AI using
airplanes.

I also made a little modification so that a unit on goto which completes
an attack will be put on ACTIVITY_IDLE . (very practical with bombers)

Though the airplane always completes the goto in the shortest
possible amount of turns, it will sometimes take funny routes and/or
choose a route so it will have less surplus moves at the end of the goto
than it could have had. This is not very serious, and does not stop this
patch from being a clear improvement.
See further comments in the code.

-Thue

ps: Those who made the old goto algoritms and failed to comment them
skulle have tæsk med en våd søndagsberlinger!

Attachment: airplane_goto-Apr-20.diff.bz2
Description: Binary data


[Prev in Thread] Current Thread [Next in Thread]