[Freeciv-Dev] (PR#10221) a server option to make maps fairer
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://rt.freeciv.org/Ticket/Display.html?id=10221 >
I warn you: it's merely the _start_ of the patch. I don't have the time or
inclination to finish it. I think it's a good idea however, and would like
to see it in CVS, rather than just as a pubserver add-on.
The idea is to alter the map itself after the map has been initially
generated _and_ the starting positions have been chosen. An additional
pass is made over the map changing specials and/or terrain near the start
positions. Each player will then see the same number of good tiles at the
same distance as every other player. The server glue is done. The make_fair
function is not. In fact it doesn't work at all. You can safely obliterate
everything in that function and be better off probably.
I would like somebody to take this patch and run with it. I know that the
better players complain that the map is the deciding factor... Perhaps some
of those players can chime in on ways to go about making this patch.
Maybe more tweaking than simply a bool option is wanted? Whatever. Enjoy.
-mike
? depcomp
? undep.sh
Index: common/map.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/map.c,v
retrieving revision 1.197
diff -u -r1.197 map.c
--- common/map.c 20 Sep 2004 16:42:30 -0000 1.197
+++ common/map.c 21 Sep 2004 03:56:18 -0000
@@ -211,6 +211,7 @@
map.have_specials = FALSE;
map.have_rivers_overlay = FALSE;
map.have_huts = FALSE;
+ map.make_fair = FALSE;
}
/**************************************************************************
Index: common/map.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/map.h,v
retrieving revision 1.217
diff -u -r1.217 map.h
--- common/map.h 20 Sep 2004 16:42:30 -0000 1.217
+++ common/map.h 21 Sep 2004 03:56:18 -0000
@@ -173,6 +173,7 @@
int num_start_positions;
bool have_specials;
bool have_huts;
+ bool make_fair;
bool have_rivers_overlay; /* only applies if !have_specials */
int num_continents;
int num_oceans; /* not updated at the client */
Index: server/settings.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/settings.c,v
retrieving revision 1.5
diff -u -r1.5 settings.c
--- server/settings.c 20 Sep 2004 16:42:31 -0000 1.5
+++ server/settings.c 21 Sep 2004 03:56:18 -0000
@@ -359,6 +359,14 @@
N_("Amount of huts (minor tribe villages)"), "", NULL,
MAP_MIN_HUTS, MAP_MAX_HUTS, MAP_DEFAULT_HUTS)
+ GEN_BOOL("makefair", map.make_fair,
+ SSET_MAP_GEN, SSET_GEOLOGY, SSET_RARE, SSET_TO_CLIENT,
+ N_("Attempt to make the map more fair"),
+ N_("1 = do an extra pass after start positions have been "
+ "selected to redistribute specials and terrain in an "
+ "attempt to make the map more fair; 0 = leave map as-is"),
+ NULL, FALSE)
+
/* Options affecting numbers of players and AI players. These only
* affect the start of the game and can not be adjusted after that.
* (Actually, minplayers does also affect reloads: you can't start a
Index: server/srv_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/srv_main.c,v
retrieving revision 1.197
diff -u -r1.197 srv_main.c
--- server/srv_main.c 17 Sep 2004 08:35:14 -0000 1.197
+++ server/srv_main.c 21 Sep 2004 03:56:19 -0000
@@ -1809,6 +1809,11 @@
provides them. -- Gudy */
if(map.num_start_positions == 0) {
create_start_positions();
+
+ /* do an extra pass over the map to make it fairer */
+ if (map.make_fair) {
+ map_make_fair();
+ }
}
}
Index: server/generator/mapgen.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/generator/mapgen.c,v
retrieving revision 1.8
diff -u -r1.8 mapgen.c
--- server/generator/mapgen.c 21 Sep 2004 00:34:18 -0000 1.8
+++ server/generator/mapgen.c 21 Sep 2004 03:56:19 -0000
@@ -2149,3 +2149,76 @@
free(height_map);
height_map = NULL;
}
+
+enum {
+ HAS_SPECIAL_1,
+ HAS_SPECIAL_2,
+ HAS_NOSPECIAL,
+ HAS_SPECIAL_NUM
+};
+
+/**************************************************************************
+ Attempt to make the map fair. Explain the methodology here.
+
+ FIXME: This code could actually do something.
+**************************************************************************/
+void map_make_fair(void)
+{
+ int dist_out = 3; /* something nice */
+ int i, j, k;
+ int counts[map.num_start_positions][game.terrain_count][HAS_SPECIAL_NUM];
+
+ /* zero out our count array */
+ for (i = 0; i < map.num_start_positions; i++) {
+ for (j = 0; j < game.terrain_count; j++) {
+ for (k = 0; k < HAS_SPECIAL_NUM; k++) {
+ counts[i][j][k] = 0;
+ }
+ }
+ }
+
+ /* get some statistics */
+ for (i = 0; i < map.num_start_positions; i++) {
+ int x = map.start_positions[i].x;
+ int y = map.start_positions[i].y;
+ struct tile *ptile;
+
+ iterate_outward(x, y, dist_out, xitr, yitr) {
+ ptile = map_get_tile(xitr, yitr);
+
+ for (j = 0; j < game.terrain_count; j++) {
+ if (ptile->terrain == j) {
+ switch (ptile->special) {
+ case S_SPECIAL_1:
+ counts[i][j][HAS_SPECIAL_1]++;
+ break;
+ case S_SPECIAL_2:
+ counts[i][j][HAS_SPECIAL_2]++;
+ break;
+ default:
+ counts[i][j][HAS_NOSPECIAL]++;
+ break;
+ }
+ }
+ }
+ } iterate_outward_end;
+ }
+
+ /* printout: XXX remove before committing */
+ for (i = 0; i < map.num_start_positions; i++) {
+ for (j = 0; j < game.terrain_count; j++) {
+ printf("%s: ", get_terrain_name(j));
+ for (k = 0; k < HAS_SPECIAL_NUM; k++) {
+ printf("%d ", counts[i][j][k]);
+ }
+ printf("\n");
+ }
+ printf("\n");
+ }
+
+ /* jason's idea: for each tile, calculate the goodness. then if the
+ * tile is "in range" of the starting island, reduce this by
+ * a factor based on some more numbers. to be truly fair you want the
+ * sums to be equal for all starting positions, no matter what the
+ * range of iteration is. pille's "numbers" play a role here. */
+}
Index: server/generator/mapgen.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/generator/mapgen.h,v
retrieving revision 1.2
diff -u -r1.2 mapgen.h
--- server/generator/mapgen.h 16 Sep 2004 09:53:11 -0000 1.2
+++ server/generator/mapgen.h 21 Sep 2004 03:56:19 -0000
@@ -14,5 +14,6 @@
#define FC__MAPGEN_H
void map_fractal_generate(bool autosize);
+void map_make_fair(void);
#endif /* FC__MAPGEN_H */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#10221) a server option to make maps fairer,
Mike Kaufman <=
|
|