[Freeciv-Dev] (PR#11610) Two fairness issues with techlevel>0 and techco
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=11610 >
> [saywhat@xxxxxxxxxxxx - Sun Dec 19 23:14:43 2004]:
> Problem 2:
>
> The second fairness problem with techlevel relates to teams.
> Here's an example: assume techlevel=1. I play against four teamed
> AIs. I get Bronze Working as my free tech. AI1 gets Warrior Code.
> AI2 gets Alphabet. AI3 gets Masonry. AI4 gets Bronze Working.
>
> Since AI1 through AI4 are all on the same team, they all share
> their free techs. So effectively, they start the game with 4 free
> techs each while I only get 1.
>
> In human vs. AI games, this isn't a big deal. It's just an
> another (albeit undocumented?) handicap for the human player. But
> in team play amongst human players, it could provide a significant
> advantage for one side or another.
>
> The solution I would suggest is to create an option to allocate
> free techs to teams rather than to individual players.
>
> What do you think?
>
> Eddie
>
Actually it doesn't happen (in HEAD), but this is due to a bug. The
attached patch cleans the code and gives the the techlevel techs only
once to the team.
Index: server/barbarian.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/barbarian.c,v
retrieving revision 1.102
diff -u -r1.102 barbarian.c
--- server/barbarian.c 4 Sep 2005 04:31:18 -0000 1.102
+++ server/barbarian.c 16 Sep 2005 12:24:23 -0000
@@ -168,7 +168,8 @@
barbarians->ai.barbarian_type = SEA_BARBARIAN;
}
set_ai_level_directer(barbarians, game.info.skill_level);
- init_tech(barbarians, game.info.tech);
+ init_tech(barbarians);
+ give_initial_techs(barbarians);
/* Ensure that we are at war with everyone else */
players_iterate(pplayer) {
Index: server/plrhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/plrhand.c,v
retrieving revision 1.423
diff -u -r1.423 plrhand.c
--- server/plrhand.c 13 Sep 2005 08:43:32 -0000 1.423
+++ server/plrhand.c 16 Sep 2005 12:24:27 -0000
@@ -1470,7 +1470,8 @@
* FIXME: could we use map_is_empty here? */
if (server_state == RUN_GAME_STATE || !game.info.is_new_game) {
pplayer->nation = nation;
- init_tech(pplayer, 0);
+ init_tech(pplayer);
+ give_initial_techs(pplayer);
map_know_and_see_all(pplayer);
}
Index: server/savegame.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/savegame.c,v
retrieving revision 1.276
diff -u -r1.276 savegame.c
--- server/savegame.c 3 Sep 2005 09:58:59 -0000 1.276
+++ server/savegame.c 16 Sep 2005 12:24:57 -0000
@@ -1682,7 +1682,8 @@
}
/* Add techs from game and nation, but ignore game.info.tech. */
- init_tech(plr, 0);
+ init_tech(plr);
+ give_initial_techs(plr);
if (is_barbarian(plr) && plr->nation == NO_NATION_SELECTED) {
plr->nation = pick_barbarian_nation();
Index: server/srv_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/srv_main.c,v
retrieving revision 1.292
diff -u -r1.292 srv_main.c
--- server/srv_main.c 5 Sep 2005 15:55:47 -0000 1.292
+++ server/srv_main.c 16 Sep 2005 12:24:57 -0000
@@ -1806,10 +1806,37 @@
players_iterate(pplayer) {
player_map_allocate(pplayer);
- init_tech(pplayer, game.info.tech);
+ init_tech(pplayer);
player_limit_to_government_rates(pplayer);
pplayer->economic.gold = game.info.gold;
} players_iterate_end;
+
+ players_iterate(pplayer) {
+ give_initial_techs(pplayer);
+ } players_iterate_end;
+
+ players_iterate(pplayer) {
+ int i;
+ bool free_techs_already_given = FALSE;
+
+ players_iterate(eplayer) {
+ if (players_on_same_team(eplayer, pplayer) &&
+ eplayer->player_no < pplayer->player_no) {
+ free_techs_already_given = TRUE;
+ break;
+ }
+ } players_iterate_end;
+
+ if (free_techs_already_given) {
+ break;
+ }
+
+ for (i = 0; i < game.info.tech; i++) {
+ give_random_initial_tech(pplayer);
+ }
+ } players_iterate_end;
+
+
if(game.info.is_new_game) {
/* If we're starting a new game, reset the rules.max_players to be the
* number of players currently in the game. But when loading a game
Index: server/techtools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/techtools.c,v
retrieving revision 1.26
diff -u -r1.26 techtools.c
--- server/techtools.c 13 Sep 2005 08:43:32 -0000 1.26
+++ server/techtools.c 16 Sep 2005 12:24:57 -0000
@@ -583,15 +583,9 @@
/****************************************************************************
Initializes tech data for the player.
-
- The 'tech' parameter gives the number of random techs to assign to the
- player.
****************************************************************************/
-void init_tech(struct player *plr, int tech_count)
+void init_tech(struct player *plr)
{
- int i;
- struct nation_type *nation = get_nation_by_plr(plr);
-
tech_type_iterate(i) {
set_invention(plr, i, TECH_UNKNOWN);
} tech_type_iterate_end;
@@ -599,6 +593,21 @@
get_player_research(plr)->techs_researched = 1;
+ /* Mark the reachable techs */
+ update_research(plr);
+ if (!choose_goal_tech(plr)) {
+ choose_random_tech(plr);
+ }
+}
+
+/****************************************************************************
+ Gives initial techs to the player
+****************************************************************************/
+void give_initial_techs(struct player* plr)
+{
+ struct nation_type *nation = get_nation_by_plr(plr);
+ int i;
+
/*
* Give game wide initial techs
*/
@@ -606,7 +615,7 @@
if (game.rgame.global_init_techs[i] == A_LAST) {
break;
}
- set_invention(plr, game.rgame.global_init_techs[i], TECH_KNOWN);
+ found_new_tech(plr, game.rgame.global_init_techs[i], FALSE, TRUE);
}
/*
@@ -616,20 +625,22 @@
if (nation->init_techs[i] == A_LAST) {
break;
}
- set_invention(plr, nation->init_techs[i], TECH_KNOWN);
- }
-
- for (i = 0; i < tech_count; i++) {
- update_research(plr);
- choose_random_tech(plr); /* could be choose_goal_tech -- Syela */
- set_invention(plr, get_player_research(plr)->researching, TECH_KNOWN);
+ found_new_tech(plr, nation->init_techs[i], FALSE, TRUE);
}
+}
- /* Mark the reachable techs */
- update_research(plr);
- if (!choose_goal_tech(plr)) {
- choose_random_tech(plr);
- }
+/****************************************************************************
+ Gives a player random tech, which he hasn't researched yet.
+ Returns the tech. This differs from give_random_free_tech - it doesn't
+ apply free cost
+****************************************************************************/
+Tech_type_id give_random_initial_tech(struct player* pplayer)
+{
+ Tech_type_id tech;
+
+ tech = pick_random_tech(pplayer);
+ found_new_tech(pplayer, tech, FALSE, TRUE);
+ return tech;
}
/****************************************************************************
Index: server/techtools.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/techtools.h,v
retrieving revision 1.7
diff -u -r1.7 techtools.h
--- server/techtools.h 3 Jul 2005 06:53:18 -0000 1.7
+++ server/techtools.h 16 Sep 2005 12:24:57 -0000
@@ -24,7 +24,7 @@
void found_new_tech(struct player *plr, Tech_type_id tech_found,
bool was_discovery, bool saving_bulbs);
void update_tech(struct player *plr, int bulbs);
-void init_tech(struct player *plr, int tech_count);
+void init_tech(struct player *plr);
void choose_tech(struct player *plr, Tech_type_id tech);
void choose_random_tech(struct player* plr);
void choose_tech_goal(struct player *plr, Tech_type_id tech);
@@ -33,4 +33,7 @@
Tech_type_id give_random_free_tech(struct player *pplayer);
Tech_type_id give_immediate_free_tech(struct player *pplayer);
+void give_initial_techs(struct player* plr);
+Tech_type_id give_random_initial_tech(struct player* pplayer);
+
#endif
- [Freeciv-Dev] (PR#11610) Two fairness issues with techlevel>0 and techcoststyle=1,
Mateusz Stefek <=
|
|