Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2004:
[Freeciv-Dev] Re: (PR#9610) autosettler "territory" and danger maps
Home

[Freeciv-Dev] Re: (PR#9610) autosettler "territory" and danger maps

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: jdorje@xxxxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#9610) autosettler "territory" and danger maps
From: "Per I. Mathisen" <per@xxxxxxxxxxx>
Date: Thu, 5 Aug 2004 14:52:25 -0700
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=9610 >

On Thu, 5 Aug 2004, Jason Short wrote:
> In server/settlers.c there is a variable "territory" that is used as a
> rough approximation of a danger map. It's not very good (it doesn't
> consider terrain or roads) and it cheats horribly (even for human
> players). There's no way to fix the cheating without changing the
> design since the same map is used for all players.
>
> Surely this is something that, if implemented properly, would have value
> to all AI activities?

Yes. At least to city defense and bodyguard code as well.

> Is this already implemented globally?

No.

> Can we remove the territory map and replace it with a global function
> call?

Here is my preliminary idea for a "movemap":

A mapsize array of struct {
  struct unit_list 1_turn_reach;
  struct unit_list 2_turn_reach;
} movemap;

These unit lists contain all the units that can reach the tile in one or
two turns. You can now iterate over all possibly dangerous units that can
reach a given tile quickly.

To set up this cache, run through all units once, and use pf to mark tiles
in the movemap. For ferries, for each ferry { make pf map; for each tile {
for each passenger { pf backtrace from tile and see if we can overlap with
the ferry's pf map, if so mark tile } } }.

This is expensive, but doing ferries properly is a real pain in the ***,
any way you do it.

Setting up the cache will consume some CPU, and has to be recalculated
each turn for each player, but will not cost much more CPU than a
pf-converted city danger code, I think.  The city danger code will have to
(well, should) do these calculations anyway.

  - Per




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