[Freeciv-Dev] Re: (PR#9147) researchcost proposal
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: |
undisclosed-recipients: ; |
Subject: |
[Freeciv-Dev] Re: (PR#9147) researchcost proposal |
From: |
"Per Inge Mathisen" <per@xxxxxxxxxxx> |
Date: |
Mon, 12 Jul 2004 13:14:19 -0700 |
Reply-to: |
rt@xxxxxxxxxxx |
<URL: http://rt.freeciv.org/Ticket/Display.html?id=9147 >
This is an updated patch. If you do not have a tech goal set, and you can
research multiple techs in a turn, you can now select which techs you want
to research in the science dialog.
There is an occasional (rare) bug: Sometimes when selecting a tech to
research immediately from the science dialog, you get the tech seemingly
for free. That is not the case, though - it is just the science dialog
that didn't update properly - it updated the tech but not the bulbs. I
cannot figure out why. The client does receive all the info it should.
Please test if it has the desired behaviour now.
- Per
Index: client/civclient.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/civclient.c,v
retrieving revision 1.190
diff -u -r1.190 civclient.c
--- client/civclient.c 25 Jun 2004 23:35:55 -0000 1.190
+++ client/civclient.c 12 Jul 2004 20:06:42 -0000
@@ -396,6 +396,7 @@
if (client_state == CLIENT_GAME_RUNNING_STATE) {
load_ruleset_specific_options();
create_event(-1, -1, E_GAME_START, _("Game started."));
+ precalc_tech_data();
update_research(game.player_ptr);
role_unit_precalcs();
boot_help_texts(); /* reboot */
Index: client/gui-gtk-2.0/repodlgs.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/repodlgs.c,v
retrieving revision 1.50
diff -u -r1.50 repodlgs.c
--- client/gui-gtk-2.0/repodlgs.c 11 May 2004 17:52:25 -0000 1.50
+++ client/gui-gtk-2.0/repodlgs.c 12 Jul 2004 20:06:46 -0000
@@ -446,6 +446,11 @@
/* work around GTK+ refresh bug. */
gtk_widget_queue_resize(science_current_label);
+ if (game.player_ptr->research.researching == A_UNSET) {
+ item = gtk_menu_item_new_with_label(advances[A_NONE].name);
+ gtk_menu_shell_append(GTK_MENU_SHELL(popupmenu), item);
+ }
+
/* collect all techs which are reachable in the next step
* hist will hold afterwards the techid of the current choice
*/
Index: common/tech.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/tech.c,v
retrieving revision 1.72
diff -u -r1.72 tech.c
--- common/tech.c 12 Jul 2004 17:22:03 -0000 1.72
+++ common/tech.c 12 Jul 2004 20:06:46 -0000
@@ -18,6 +18,7 @@
#include <assert.h>
#include <stdlib.h> /* exit */
#include <string.h>
+#include <math.h>
#include "fcintl.h"
#include "game.h"
@@ -34,6 +35,8 @@
server/ruleset.c (for the server)
client/packhand.c (for the client) */
+static int techcoststyle1[A_LAST];
+
static const char *flag_names[] = {
"Bonus_Tech", "Boat_Fast", "Bridge", "Railroad", "Fortress",
"Watchtower", "Population_Pollution_Inc", "Trade_Revenue_Reduce",
@@ -123,7 +126,6 @@
{
int counter;
- //if(goal==0) freelog(LOG_NORMAL, "foobar %d",get_invention(pplayer, goal));
BV_CLR_ALL(pplayer->research.inventions[goal].required_techs);
if (get_invention(pplayer, goal) == TECH_KNOWN) {
@@ -348,8 +350,9 @@
tech_cost_style:
0 - Civ (I|II) style. Every new tech add game.researchcost to the
cost of the next tech.
- 1 - Cost of technology is (1+num_parents)*researchcost, where
- num_parents == number of requirement for tech, counted recursively.
+ 1 - Cost of technology is
+ MAX((1 + parents) * (researchcost / 2) * sqrt(1 + parents),
researchcost)
+ where num_parents == number of requirement for tech, counted recursively.
2 - Cost are read from tech.ruleset. Missing costs are generated by
style 1.
@@ -386,7 +389,7 @@
cost = pplayer->research.techs_researched * game.researchcost;
break;
case 1:
- cost = advances[tech].num_reqs * game.researchcost;
+ cost = techcoststyle1[tech];
break;
case 2:
cost = (advances[tech].preset_cost * game.researchcost) /
@@ -530,6 +533,13 @@
memset(counted, 0, sizeof(counted));
advances[tech].num_reqs = precalc_tech_data_helper(tech, counted);
} tech_type_iterate_end;
+
+ tech_type_iterate(tech) {
+ techcoststyle1[tech] = MAX((advances[tech].num_reqs + 1)
+ * sqrt(advances[tech].num_reqs + 1)
+ * (game.researchcost / 2),
+ game.researchcost);
+ } tech_type_iterate_end;
}
/**************************************************************************
Index: data/civ1/game.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/civ1/game.ruleset,v
retrieving revision 1.14
diff -u -r1.14 game.ruleset
--- data/civ1/game.ruleset 12 Jul 2004 17:22:03 -0000 1.14
+++ data/civ1/game.ruleset 12 Jul 2004 20:06:46 -0000
@@ -53,8 +53,10 @@
; Method of calculating technology costs
; 0 - Civ (I|II) style. Every new tech add researchcost to cost of next tech.
-; 1 - Cost of technology is (1+num_parents)*researchcost, where
-; num_parents == number of requirement for tech, counted recursively.
+; 1 - Cost of technology is
+; MAX((1+parents) * (researchcost/2) * sqrt(1+parents), researchcost)
+; where num_parents == number of requirement for tech, counted
+; recursively.
; 2 - Cost are read from tech.ruleset. Missing costs are generated by
; style 1.
tech_cost_style = 0
Index: data/civ2/game.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/civ2/game.ruleset,v
retrieving revision 1.14
diff -u -r1.14 game.ruleset
--- data/civ2/game.ruleset 12 Jul 2004 17:22:03 -0000 1.14
+++ data/civ2/game.ruleset 12 Jul 2004 20:06:46 -0000
@@ -53,8 +53,10 @@
; Method of calculating technology costs
; 0 - Civ (I|II) style. Every new tech add researchcost to cost of next tech.
-; 1 - Cost of technology is (1+num_parents)*researchcost, where
-; num_parents == number of requirement for tech, counted recursively.
+; 1 - Cost of technology is
+; MAX((1+parents) * (researchcost/2) * sqrt(1+parents), researchcost)
+; where num_parents == number of requirement for tech, counted
+; recursively.
; 2 - Cost are read from tech.ruleset. Missing costs are generated by
; style 1.
tech_cost_style = 0
Index: data/default/game.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/default/game.ruleset,v
retrieving revision 1.17
diff -u -r1.17 game.ruleset
--- data/default/game.ruleset 12 Jul 2004 17:22:03 -0000 1.17
+++ data/default/game.ruleset 12 Jul 2004 20:06:46 -0000
@@ -53,16 +53,13 @@
; Method of calculating technology costs
; 0 - Civ (I|II) style. Every new tech add researchcost to cost of next tech.
-; 1 - Cost of technology is (1+num_parents)*researchcost, where
-; num_parents == number of requirement for tech, counted recursively.
+; 1 - Cost of technology is
+; MAX((1+parents) * (researchcost/2) * sqrt(1+parents), researchcost)
+; where num_parents == number of requirement for tech, counted
+; recursively.
; 2 - Cost are read from tech.ruleset. Missing costs are generated by
; style 1.
-; Note that style 1 will make techs overall cheaper. With researchcost
-; set to 10 and using 1.12.0 default rules, style 0 requires 38280 bulbs
-; while style 1 requires only 21120. If you set researchcost to 20, then
-; total bulb cost for style 1 increases to 42240, which is more in line
-; with previous tech progression.
-tech_cost_style = 0
+tech_cost_style = 1
; Technology leak from other civilizations
; 0 - No reduction of the technology cost.
Index: data/history/game.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/history/game.ruleset,v
retrieving revision 1.5
diff -u -r1.5 game.ruleset
--- data/history/game.ruleset 19 Apr 2004 12:17:15 -0000 1.5
+++ data/history/game.ruleset 12 Jul 2004 20:06:48 -0000
@@ -53,15 +53,12 @@
; Method of calculating technology costs
; 0 - Civ (I|II) style. Every new tech add researchcost to cost of next tech.
-; 1 - Cost of technology is (1+num_parents)*researchcost, where
-; num_parents == number of requirement for tech, counted recursively.
+; 1 - Cost of technology is
+; MAX((1+parents) * (researchcost/2) * sqrt(1+parents), researchcost)
+; where num_parents == number of requirement for tech, counted
+; recursively.
; 2 - Cost are read from tech.ruleset. Missing costs are generated by
; style 1.
-; Note that style 1 will make techs overall cheaper. With researchcost
-; set to 10 and using 1.12.0 default rules, style 0 requires 38280 bulbs
-; while style 1 requires only 21120. If you set researchcost to 20, then
-; total bulb cost for style 1 increases to 42240, which is more in line
-; with previous tech progression.
tech_cost_style = 0
; Technology leak from other civilizations
Index: server/plrhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/plrhand.c,v
retrieving revision 1.312
diff -u -r1.312 plrhand.c
--- server/plrhand.c 17 Jun 2004 19:50:41 -0000 1.312
+++ server/plrhand.c 12 Jul 2004 20:06:50 -0000
@@ -277,6 +277,7 @@
&& get_invention(plr, tech_found) != TECH_KNOWN)
|| tech_found == A_FUTURE);
assert(tech_is_available(plr, tech_found) || tech_found == A_FUTURE);
+ assert(plr->research.researching != A_UNSET);
plr->got_tech = TRUE;
plr->research.techs_researched++;
@@ -337,9 +338,7 @@
}
if (tech_found == plr->research.researching && next_tech == A_NONE) {
- /* need to pick new tech to research */
-
- int saved_bulbs = plr->research.bulbs_researched;
+ /* try to pick new tech to research */
if (choose_goal_tech(plr)) {
notify_player_ex(plr, -1, -1, E_TECH_LEARNED,
@@ -349,15 +348,20 @@
advances[plr->research.researching].name,
advances[plr->ai.tech_goal].name);
} else {
- choose_random_tech(plr);
- if (!is_future_tech(plr->research.researching)
- || !is_future_tech(tech_found)) {
+ if (plr->ai.control || !was_discovery) {
+ choose_random_tech(plr);
+ } else {
+ plr->research.researching = A_UNSET;
+ }
+ if (plr->research.researching != A_UNSET
+ && (!is_future_tech(plr->research.researching)
+ || !is_future_tech(tech_found))) {
notify_player_ex(plr, -1, -1, E_TECH_LEARNED,
_("Game: Learned %s. Scientists "
"choose to research %s."),
advances[tech_found].name,
get_tech_name(plr, plr->research.researching));
- } else {
+ } else if (plr->research.researching != A_UNSET) {
char buffer1[300];
char buffer2[300];
@@ -368,17 +372,20 @@
get_tech_name(plr, plr->research.researching));
notify_player_ex(plr, -1, -1, E_TECH_LEARNED, "%s%s", buffer1,
buffer2);
+ } else {
+ notify_player_ex(plr, -1, -1, E_TECH_LEARNED,
+ _("Game: Learned %s. Scientists "
+ "do not know what to research next."),
+ advances[tech_found].name);
}
}
- if (saving_bulbs) {
- plr->research.bulbs_researched = saved_bulbs;
- }
} else if (tech_found == plr->research.researching && next_tech > A_NONE) {
/* Next target already determined. We always save bulbs. */
plr->research.researching = next_tech;
- if (plr->research.bulbs_researched > 0) {
- plr->research.bulbs_researched = 0;
- }
+ }
+
+ if (!saving_bulbs && plr->research.bulbs_researched > 0) {
+ plr->research.bulbs_researched = 0;
}
if (bonus_tech_hack) {
@@ -390,6 +397,9 @@
"world join your civilization: you get "
"an immediate advance."));
}
+ if (plr->research.researching == A_UNSET) {
+ choose_random_tech(plr); /* always random tech here */
+ }
tech_researched(plr);
}
@@ -490,8 +500,12 @@
get_nation_name_plural(plr->nation), plr->future_tech);
}
+ /* Deduct tech cost */
+ plr->research.bulbs_researched =
+ MAX(plr->research.bulbs_researched - total_bulbs_required(plr), 0);
+
/* do all the updates needed after finding new tech */
- found_new_tech(plr, plr->research.researching, TRUE, FALSE, A_NONE);
+ found_new_tech(plr, plr->research.researching, TRUE, TRUE, A_NONE);
}
/**************************************************************************
@@ -517,10 +531,11 @@
excessive_bulbs =
(plr->research.bulbs_researched - total_bulbs_required(plr));
- if (excessive_bulbs >= 0) {
+ if (excessive_bulbs >= 0 && plr->research.researching != A_UNSET) {
tech_researched(plr);
- plr->research.bulbs_researched += excessive_bulbs;
- update_tech(plr, 0);
+ if (plr->research.researching != A_UNSET) {
+ update_tech(plr, 0);
+ }
}
}
@@ -531,9 +546,6 @@
{
int sub_goal;
- if (plr->research.bulbs_researched > 0) {
- plr->research.bulbs_researched = 0;
- }
if (plr->ai.control) {
ai_next_tech_goal(plr); /* tech-AI has been changed */
}
@@ -611,6 +623,9 @@
plr->research.changed_from = -1;
}
plr->research.researching=tech;
+ if (plr->research.bulbs_researched > total_bulbs_required(plr)) {
+ tech_researched(plr);
+ }
}
void choose_tech_goal(struct player *plr, int tech)
@@ -1452,7 +1467,8 @@
assert(server_state != RUN_GAME_STATE
|| ((tech_exists(plr->research.researching)
&& plr->research.researching != A_NONE)
- || is_future_tech(plr->research.researching)));
+ || is_future_tech(plr->research.researching)
+ || plr->research.researching == A_UNSET));
assert((tech_exists(plr->ai.tech_goal) && plr->ai.tech_goal != A_NONE)
|| plr->ai.tech_goal == A_UNSET);
}
Index: server/srv_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/srv_main.c,v
retrieving revision 1.172
diff -u -r1.172 srv_main.c
--- server/srv_main.c 10 Jul 2004 14:25:45 -0000 1.172
+++ server/srv_main.c 12 Jul 2004 20:06:51 -0000
@@ -522,6 +522,12 @@
* see them. --dwp
*/
before_end_year();
+ players_iterate(pplayer) {
+ if (pplayer->research.researching == A_UNSET) {
+ choose_random_tech(pplayer);
+ update_tech(pplayer, 0);
+ }
+ } players_iterate_end;
/* Freeze sending of cities. */
nocity_send = TRUE;
|
|