Complete.Org: Mailing Lists: Archives: freeciv-dev: September 1999:
Re: [Freeciv-Dev] Unit fog of war
Home

Re: [Freeciv-Dev] Unit fog of war

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Freeciv Dev <freeciv-dev@xxxxxxxxxxxx>
Cc: Artur Biesiadowski <abies@xxxxxxxxx>
Subject: Re: [Freeciv-Dev] Unit fog of war
From: Peter Schaefer <schaefer@xxxxxx>
Date: Thu, 02 Sep 1999 14:18:49 +0200

Hello Artur,

Question 1:
        This means fog of war would change only at end of turn.
        What happens during the turn ?
        You write turn/move. If you talk about about doing this
        for every move, the following scheme might be faster;
        uses memory.

Scheme 2:
        Data: For every player, for every tile, there is a visibility counter,
        for all types of visibility 
        (see_ground, see_ground_stealth, see_sea, see_sea_stealth, see_air,
        see_air_stealth, see_space, see_space_stealth).

        When a unit moves off a tile, then on each tile it had been seeing, it 
        decreases the counter.
        This includes disbanding the unit, and other forms of disappearance.

        When a unit moves onto a tile, then on each tile it can see from there, 
it 
        increases the counter.
        This same is done when placing the unit, or other forms of appearance.

        When the map is rebuilt or initialized, it is filled with visibility 
        values of 0. After that, all units are "placed" on the map, i.e. they 
add       
        their scanning value.
        One might wish to call this routine once every turn, since programming 
        bugs can easily break this scheme.

Features 3:
        You could easily introduce a "scanning" value; for example, a scout may 
        have a scanning value of 2,
        which adds up with the values of other units; You would be able to see 
        stealth units if you stacked
        enough units atop each other, because their scanning values would add;  
        Normal units would have a stealth
        value of 1; Units with stealth value 0 would be seen always.
        The visibility counter, now named "scanning" counter would be at least 
two 
        bytes then, so you can add up scanning values.

Question 4:
        What happens if a unit moves several tiles in one move ?
        It would be more efficient to remove the unit from the start tile,
        and place it on the end tile for scanning calculation,
        but the rules of the game (I'm talking freeciv mode, okay?)
        would need tweaking for this.

Question 5:
        Does it makes sense to use a mask in this case, i.e. 
        if a unit moves diagonal to upper right, decrease only the 
        scanning on the left and bottom rows, and increase on the
        top and right rows. The other scanning values stay the same.
        This gives a big boost if the scanning range is greater than 2,
        but it is a bit tricky.

        


Artur Biesiadowski wrote:
> 
> This subject was mentioned few times, so sorry if I'm repetitive in some
> ideas.
> 
> Here is proposed way to implement it.
> 
> Every unit has a field last_seen, which is bitfield for each player that
> specify if unit was seens by that player last turn/move. After move,
> before packets are send following tests are performed
> 
> for each tile in max_visibility_radius from unit.x,unit.y
>   for each ounit on this tile
>     if can_see(ounit, unit)
>       ounit.owner can see unit
>     if can_see(unit, ounit) and not ounit.last_seen by unit.owner
>       send add packet about ounit to unit.owner
>   if city on this tile
>     if can_see(city, unit)
>       city.owner can see unit
>     if can_see(unit,city)
>       send city info to unit.owner
>   // maybe also
>   //if specific improvement on this tile
>   // ? I'm thinking about radar towers from CCTP, but maybe
>   // they can be made as special units that do not move etc ?
> 
> send remove/add unit packets to unit.owner
> 
> for each other player
>   if ( player can see unit now )
>   {
>     send remove/add unit packets to player
>     last_seen |= player
>   }
>   else
>   {
>     if ( player last_seen unit )
>       send shadow unit packet
>     last_seen -= player
>   }
> 
> Shadow unit packet is special packet that informs client that unit has
> moved from last position, but player do not know where. It is up to
> client (maybe configurable) if it want's to show this unit with some
> special outline/greyed out, or plainly remove it.
> 
> Problems: when player x moves his unit A so he do not longer see unit B,
> unit B is not shadowed for as long as it moves. So even with such fog of
> war, players knows if not visible unit is still on old place. This could
> be avoided by adding another check for for fields that was previously
> visible by moving unit - for each stack/unit there check would be
> performed if there is a player unit in max_visibilty radius that can see
> it. I'm not sure if it is worth the effort - it at least doubles the
> time and gives only small improvement.
> 
> Of course can_see_unit_unit, can_see_city_unit etc could be done as
> scripts :)
> 
> Artur

-- 
Peter Schäfer - mailto:schaefer@xxxxxx, schaefer@xxxxxx
You know things look bad when .. 
        Your wingman says: Oh, no - I've lost my wingman.

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