Complete.Org: Mailing Lists: Archives: freeciv-dev: May 2003:
[Freeciv-Dev] Re: (PR#4107) Client crash on start.
Home

[Freeciv-Dev] Re: (PR#4107) Client crash on start.

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: rf13@xxxxxxxxxxxxxxxxx, ChrisK@xxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#4107) Client crash on start.
From: "Gregory Berkolaiko" <Gregory.Berkolaiko@xxxxxxxxxxxx>
Date: Fri, 2 May 2003 09:37:18 -0700
Reply-to: rt@xxxxxxxxxxxxxx

On Fri, 2 May 2003, Per I. Mathisen wrote:

> On Thu, 1 May 2003, Gregory Berkolaiko wrote:
> > Believe it or not, the cause of this bug is the resent change to AI
> > government evaluation.
> ...
> > #0 send_unit_info (dest=0x813608c, punit=0x82e52e8) at unittools.c:2005
> > #10x080970a2 in city_support (pcity=0x833e668) at city.c:2070
> > #20x08097113 in generic_city_refresh (pcity=0x833e668,
> >   refresh_trade_route_cities=true) at city.c:2091
> > #30x080bc9ee in ai_best_government (pplayer=0x813608c) at aihand.c:360
> > #40x080bb955 in ai_data_turn_init (pplayer=0x813608c) at aidata.c:256
> ...
> > I think the best solution is to remove (or at least move) the
> > assess_danger_player from srv_loop. The comment says it will confuse the
> > AI, but I don't see why, as it will not _do_ anything, just do some
> > advisory stuff.
> 
> Right. This is the simplest solution. I couldn't find any problems with
> it, so I'll commit that so that cvs will be fine.

There is.  AI will move units with danger uninitialized so the defenders 
will leave the cities.  So, for now, we need a function init_ai_player in 
aihand.c which calls assess_danger and other initializing stuff.

But ideally, AI should execute all its actions in the end of the turn 
(see below) and do its initializations then too.  That doesn't mean that 
there will never be something that needs initialization once per session, 
so a init_ai_player will still be useful.

> However, there are more problems here. What happened above shouldn't be a
> problem, but it is because generic_city_refresh() sends packets.
> 
> Why is a function (or set of functions) in common/ when they send packets
> to the client? These should either be generalised or moved to server/. One
> way to generalising them, and presumably save some network traffic, would
> be to instead mark units as "dirty" when they need updating on the client,
> and then actually only do the send_unit_infos later.

I agree but not sure how to implement it.

> Also, we should start to discuss the way the AI is structured. At present
> we invoke it once for data initialization and units except settlers in the
> beginning of the turn, and then once at the end of the turn for units
> (again) and everything else.
> 
> This means we can't use static data buffers initialized in the
> initialization step for use in the end-of-turn AI step, since other AIs
> may have been controlled meanwhile and the world has changed. So we need
> to either save the data per player, even though we only need it for one
> turn, or we recalculate it twice per turn.
> 
> Instead we should, I think, do all AI stuff at the same time, and while
> the human players move their mouses and click their keyboards on their
> clients and the server is otherwise idle - ie right after turn start. On
> turn end the server will be busy processing end of turn stuff and human
> players will be waiting for the server to react, so that is a bad time to
> do AI processing.

I agree AI should do everything at the same time, but I disagree on 
timing.  I think AI has a right to adjust it's production when it sees 
human units coming next to their cities.  The only way to do it is to do 
it before end-turn.  So everything else should be done then too.

> Uhm, this post got way too long.

But these are very important issues.

G.





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