Complete.Org: Mailing Lists: Archives: freeciv-dev: May 2004:
[Freeciv-Dev] Re: (PR#725) Order of end/new-turn activities
Home

[Freeciv-Dev] Re: (PR#725) Order of end/new-turn activities

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: ChrisK@xxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#725) Order of end/new-turn activities
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 15 May 2004 10:24:30 -0700
Reply-to: rt@xxxxxxxxxxx

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

andrearo@xxxxxxxxxxxx wrote:

> What is the reason for begin_turn() and end_turn() in a game with phases
> (alternating unit movement)?  I don't think there's a need for it, instead
> put put all activities for starting a players turn in begin_player_turn().

At some point you have to advance the year.  There may also be other 
things to do here.  But all player actions should be done in the 
player_turn.

I thought about what actions should come in the beginning of the turn 
and what should come at the end.  It might seem that this doesn't 
matter, but when you have synchronous unit movement it does.  The player 
presses "turn done" at the end of his turn; this is the only timing 
action he controls.  So almost all player actions (city production 
particularly) should come at the end of the turn.  Then the player can 
start dealing with cities (he can change production during other players 
turns) and has until the end of his next turn to do it.

goto should be executed at the beginning of the player turn.  The player 
can set up gotos during other players turns but they won't be executed 
immediately.

All in all this sounds quite playable.

> The current simultaneous moves could be described like this:
> 
>  do {
>     players_iterate {
>       begin_player_turn();
>     }
>     players_iterate {
>       do_player_turn();
>     }
>     players_iterate {
>       end_player_turn();
>     }
>  }

Yes, except some actions need to be more atomic.  So it should become

   do {
     begin_turn();

     players_iterate {
       player_restore_unit_hp();
     }
     players_iterate {
       do_player_goto();
     }
     /* ...etc... */

     do_allplayers_turn();

     players_iterate {
       player_calc_research();
     }
     players_iterate {
       player_calc_production();
     }
     /* ...etc... */
   }

my idea is to replace this players_iterate with a loop that iterates 
over either one or all players, depending on the mode and turn. 
do_allplayers_turn won't change but there will be checks in functions 
like handle_move_unit to disallow out-of-turn movement.

> I agree that the player order should be shuffled once. As pointed out in
> PR#576, if you shuffle every turn, then one player can get two turns in a 
> row, which is
> unfair.

Yes, though the alternative is that one player is always half a turn 
ahead of the other.  It could be a server option.

jason




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