Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2002:
[Freeciv-Dev] [RFC] Caching AI values
Home

[Freeciv-Dev] [RFC] Caching AI values

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Raimar Falke <rf13@xxxxxxxxxxxxxxxxxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] [RFC] Caching AI values
From: Gregory Berkolaiko <Gregory.Berkolaiko@xxxxxxxxxxxx>
Date: Tue, 19 Mar 2002 13:39:34 +0000 (GMT)

While doing flying stuff, AI computes a few values which should be cached 
(like the number of air targets around a city).  I can see 2 approaches to 
such caching:

1. Compute these values at the start of the AI player's turn.

2. Compute these values as needed and then record them into a struct 
together with the time they were computed.

I favour the second approach greatly.  First, you don't have to trace the
spagetti AI calls to see to it that the values are initialized before
being accessed.  Second, you don't have to decide beforehand if you should
waste CPU initializing them at all or it's too earely in the game to do
that (doesn't make much sense to count the number of air targets before
you discover Flight): in approach 2 they would be initialized as needed.

But to execute 2nd approach efficiently, one has to have the "time"  
concept.  I remember Raimar and Co talking about game.turn variable or
somethign like this.  My time has to be a bit more precise, I think: there
are two AI movement phases per turn and "time" should distinguish
between "turn 10 start-turn" and "turn 10 end-turn".

Please provide me with insightful remarks and great suggestion on these 
matters.

G.



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