Complete.Org: Mailing Lists: Archives: freeciv-ai: November 2002:
[freeciv-ai] Re: patch/rfc: wrap activity
Home

[freeciv-ai] Re: patch/rfc: wrap activity

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: "Per I. Mathisen" <per@xxxxxxxxxxx>
Cc: freeciv-ai@xxxxxxxxxxx
Subject: [freeciv-ai] Re: patch/rfc: wrap activity
From: Gregory Berkolaiko <Gregory.Berkolaiko@xxxxxxxxxxxx>
Date: Wed, 27 Nov 2002 15:47:20 +0000 (GMT)

On Mon, 18 Nov 2002, Per I. Mathisen wrote:

> This is the essential wrapper for retaining fortification status, taken
> from massive ai patch. Shout if you think this is wrong, otherwise I will
> commit along with the necessary wrapping changes elsewhere in the code.

I like it.  But that doesn't mean it's good.  So I will list bad points 
about it:

1. Only in 1% of the time (if that) it will be called with fortifying 
task.  So 99% of the time the check is a CPU waste.

2. It will not solve the fortification problem.  It won't even _help_ to 
solve it.  The fortification problem comes from aiunit.c
2271   if (punit->activity != ACTIVITY_IDLE)
2272     handle_unit_activity_request(punit, ACTIVITY_IDLE);
and then later
2312     } else if (punit->activity == ACTIVITY_IDLE) {
2313       handle_unit_activity_request(punit, ACTIVITY_FORTIFYING);
If the first 2 lines are removed, the last two lines make perfect sense 
and need no wrappers.

On the other hand, although I am against moving AI to client, there should
be good separation between AI and the game engine.  This wrapper provides
another layer of this separation.  But maybe handle_unit_activity_request
is enough of a separation?

G.

>   - Per
> 
> diff -u -r1.62 aitools.c
> 
> +/**************************************************************************
> +  Gate all changes to unit activities through here to enforce sanity
> +
> +  FIXME: packetify request
> ++**************************************************************************/
> +void ai_unit_new_activity(struct unit *punit, enum unit_activity task)
> +{
> +  if (punit->activity == task) {
> +    return; /* useless */
> +  }
> +  if (punit->activity == ACTIVITY_FORTIFIED && task == ACTIVITY_FORTIFYING) {
> +    return; /* worse than useless */
>    }
> +  handle_unit_activity_request(punit, task);
>  }
> 
> 
> 
> 



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