[Freeciv-Dev] AI and effects of techs without buildings
I have a modpack where a lot of effects require only techs, not improvements (For example the knowledge Barter or Pottery reduce waste directly, without the need of any additional building.) AI seems to have trouble coping with that. I searched the code, and as far as I can see, all tech assessment is done for improvements only. Now I'm in doubt if this is a bug in the code or in my search. Can anyone familliar with the code please give me a hint? In case no one can tell me anything, I will open a bug. (Because no-o-o-one knowing anything about this would be a bug by itself ;-) ) Imhotep ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
Re: [Freeciv-Dev] [bug #20577] new parameter gameloss_style in game.ruleset
So I did some cleanup but have some questions (see comments below) Marko Lindqvist wrote: Update of bug #20577 (project freeciv): Category:None = general ___ Follow-up Comment #1: While it still needs some work, it looks promising first version. - In the future, please submit new features as patch and not bug don't know how this happened, I did want to open a patch ... perhaps my instinct suspected it would be more of a bug ;-) - Debug stuff currently just commented out needs to be removed done, but might have missed something - Most log_normal() calls should be made log_debug() if not removed completely done, with one exception, changed to log_verbose instead of log_debug - I don't point out all the individual style issues from this version, please check it against doc/CodingStyle and once you submit updated version I can point out the remaining ones I have tried, and done some, but there sure are issues left. I do indentation automatically via emacs, c-style gnu. I changed this to kr. To check, I ran it on a copy of aiferry.c and compared with the original version. No success. I ran indent -kr -i2 -l77 on aiferry.c and compared with the original version ... it looked completely different. CodingStyle says Declaring variables in the middle of the function body is forbidden which is fairly reasonable because you don't want to look for variable declaration in every odd places. But I'm not sure if it is meant to hold also for variables that are used only inside of blocks. For example, in plrhand.c:kill_player I have if (prebelcapital) { /* try to give the new player a GameLoss unit */ struct unit_type *putype = NULL; int sucount = strlen(game.server.start_units); int i; log_debug(try to give the new player a GameLoss unit); for (i = 0;i sucount; i++) { putype = crole_to_unit_type(game.server.start_units[i], NULL); log_debug(unit has char %c, game.server.start_units[i]); if (utype_has_flag(putype, UTYF_GAMELOSS)) { create_unit_full(prebelplayer, city_tile(prebelcapital), putype, 0, 0, putype-move_rate, putype-hp, NULL); } } } If this rule really is meant to hold literally for such cases, too, then I would prefer to put these blocks into separate functions. Another style question: I have put some snippets inside of braces, so it would be easier to move them if necessary. I didn't find anything in the CodingStyle to ban this, but then again, some things might be so horrible that most sane people wouldn't even be able to imagine. - You should define default value of its own to gameloss_style, not to use RS_DEFAULT_BASE_POLLUTION done - gameloss_style should be documented in ruleset comments In every game.ruleset or is there some global document I am not aware of? ___ Reply to this item at: http://gna.org/bugs/?20577 ___ Message sent via/by Gna! http://gna.org/ ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev Greetings from Imhotep ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
Re: [Freeciv-Dev] [bug #20489] Explorers shouldn't stop exploring
Would it take much time for you to present us (me!) some kind of hello world-like script example, something like take this unit and move it one tile to the north? (With a hint on how to make it go.) That would give a start for experimenting and code inspection. Thanks Imhotep Marko Lindqvist wrote: Follow-up Comment #6, bug #20489 (project freeciv): As of 2.4 there *is* client side scripting support - or at least framework for it. I still have found no time to properly test it myself, but it's said to be quite limited at the moment. ___ Reply to this item at: http://gna.org/bugs/?20489 ___ Message sent via/by Gna! http://gna.org/ ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
[Freeciv-Dev] Mystery of Tilesets
I would like to know about the mystery of tilesets. I have a modpack of my own, derived from Ancients, and heavily modified via blind copypaste to make it work with 2.4.99-dev. Now I don't see any differences between deep and shallow ocean. By a look in the save-file I can see that the generator distinguishes all right, (: for deep ocean and for shallow). But the tile for floor is not found, alt_graph is used instead. When setting alt_graph=-, an error occurs. Comparing with amplio2.tilespec and modifying, hoping for good luck didn't work. Where can I get an understanding of the anatomy of *.tilespec? Thanks Imhotep ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
Re: [Freeciv-Dev] Mystery of Tilesets
Am I guessin correct that 10, 12, "t.l0.floor1" is short for 10, 12, "t.l0.floor_n1e1s1w1" 10, 12, "t.l0.floor_n0e1s1w1" 10, 12, "t.l0.floor_n1e0s1w1" 10, 12, "t.l0.floor_n0e0s1w1" 10, 12, "t.l0.floor_n1e1s0w1" 10, 12, "t.l0.floor_n0e1s0w1" 10, 12, "t.l0.floor_n1e0s0w1" 10, 12, "t.l0.floor_n0e0s0w1" 10, 12, "t.l0.floor_n1e1s1w0" 10, 12, "t.l0.floor_n0e1s1w0" 10, 12, "t.l0.floor_n1e0s1w0" 10, 12, "t.l0.floor_n0e0s1w0" 10, 12, "t.l0.floor_n1e1s0w0" 10, 12, "t.l0.floor_n0e1s0w0" 10, 12, "t.l0.floor_n1e0s0w0" 10, 12, "t.l0.floor_n0e0s0w0" and that is that all those sprites are taken from the 10th row, 12th column (starting count with 0)? Why then, in trident/tile.spec does this ; Rivers (as special type), and whether north, south, east, west ; also has river or is ocean: 19, 0, "tx.s_river_n0e0s0w0" 19, 1, "tx.s_river_n1e0s0w0" 19, 2, "tx.s_river_n0e1s0w0" 19, 3, "tx.s_river_n1e1s0w0" 19, 4, "tx.s_river_n0e0s1w0" 19, 5, "tx.s_river_n1e0s1w0" 19, 6, "tx.s_river_n0e1s1w0" 19, 7, "tx.s_river_n1e1s1w0" 19, 8, "tx.s_river_n0e0s0w1" 19, 9, "tx.s_river_n1e0s0w1" 19, 10, "tx.s_river_n0e1s0w1" 19, 11, "tx.s_river_n1e1s0w1" 19, 12, "tx.s_river_n0e0s1w1" 19, 13, "tx.s_river_n1e0s1w1" 19, 14, "tx.s_river_n0e1s1w1" 19, 15, "tx.s_river_n1e1s1w1" work (note the 19 instead of 8) (I have 2.4.99-dev, revision 22213). Greetings from Imhotep Marko Lindqvist wrote: On 10 February 2013 19:20, Imhotep jmho...@slehr.de wrote: I would like to know about the mystery of tilesets. I have a modpack of my own, derived from Ancients, and heavily modified via blind copypaste to make it work with 2.4.99-dev. Now I don't see any differences between deep and shallow ocean. By a look in the save-file I can see that the generator distinguishes all right, (":" for deep ocean and " " for shallow). But the tile for floor is not found, alt_graph is used instead. When setting alt_graph="-", an error occurs. Comparing with amplio2.tilespec and modifying, hoping for good luck didn't work. Where can I get an understanding of the anatomy of *.tilespec? I don't know if there's better documentation in wiki or somewhere, but doc/README.graphics tries to document it. Unfortunately one person who reworked tilespec handling significantly didn't update any documtentation, so most of the information in that doc is what I figured out by reading the source files - it might have somewhat weird approach to issues that would have more sane explanation from another angle. If you have modified ancients.tilespec and related .spec and gfx files, note that it's based on trident tileset. You would probably do better by comparing changes to trident than to amplio. Unfortunate naming of ocean tiles ("coast" for deep ocean!) comes from halfway cleanup of another mess, this time with not-really-working and unnecessary additional terrain types that lived in our version control for a while. That's something that should be properly addressed, but I've forgotten it over the years. - ML ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
Re: [Freeciv-Dev] [bug #20489] Explorers shouldn't stop exploring
Please excuse that I am fairly new to the code and may well ignore some details but, this request is asking for somethings that could be done by the real player that operates the client instance. So this, like auto-settler and city management, only a goody, not an essential part of the code. Instead of giving in to such requests, I would rather advocate an interface for the client where everyone can put any unit or types of units under the control of some client-side script. The community could develop such scripts for all and every kind of purpose, and the best could be incorporated into the trunk. This would also open a way to improve AI performance without much need of hardcoding. My vision is that I could have a complete set of scripts for every occasion, running these against other players (with other scripts), just laying back and looking what my scripts will do, possibly interfering personally when they run bad, analyzing what went wrong, and later improving them for the next encounter. Yea, that would really be great! Imhotep David Lowe wrote: Follow-up Comment #2, bug #20489 (project freeciv): Patrol requires far too much micromanagement to be useful. The primary issue is that the pathfinder keeps steering the unit onto any available road/river/etc and the unit never gets close to areas that aren't adjacent to such. I second the original poster in that it would be better if we had a mode that would 'pull' units towards tiles that currently aren't seen. ___ Reply to this item at: http://gna.org/bugs/?20489 ___ Message sent via/by Gna! http://gna.org/ ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
Re: [Freeciv-Dev] gameloss_style // no palace
Hello all, playing with the code below, I notice that neither the new AI (created from civil war) nor the barbarians have a palace in any city. I have started to debug but, there is a lot of code and I can waste a lot of time on try and error. Does anyone out there have an inspired guess where I should look first? Thanks Imhotep Imhotep wrote: Marko Lindqvist wrote: On 8 February 2013 22:44, Imhotep jmho...@slehr.de wrote: Hi there, after trying the wiki and the forum, I'm finally trolling here. (Not that I intend to troll but, the reactions (or the lack of) make me feel like that). I have recently managed to make a first version of the gameloss_style parameter. (See my posts on the forum and the wiki.) It's a bit hard to comment on code one doesn't see ;-) That indicates that you want to see it, so here it is (existing functions after my changes): in plrhand.c: /** Murder a player in cold blood. Called from srv_main kill_dying_players() and edit packet handler handle_edit_player_remove(). **/ void kill_player(struct player *pplayer) { bool palace; pplayer-is_alive = FALSE; /* reset player status */ player_status_reset(pplayer); /* Remove shared vision from dead player to friends. */ players_iterate(aplayer) { if (gives_shared_vision(pplayer, aplayer)) { remove_shared_vision(pplayer, aplayer); } } players_iterate_end; cancel_all_meetings(pplayer); /* Show entire map for players who are *not* in a team if revealmap is set * to REVEAL_MAP_DEAD. */ if (game.server.revealmap REVEAL_MAP_DEAD player_list_size(team_members(pplayer-team)) == 1) { map_know_and_see_all(pplayer); } if (!is_barbarian(pplayer)) { notify_player(NULL, NULL, E_DESTROYED, ftc_server, _("The %s are no more!"), nation_plural_for_player(pplayer)); } /* Transfer back all cities not originally owned by player to their rightful owners, if they are still around */ palace = game.server.savepalace; game.server.savepalace = FALSE; /* moving it around is dumb */ city_list_iterate(pplayer-cities, pcity) { if (pcity-original != pplayer pcity-original-is_alive) { /* Transfer city to original owner, kill all its units outside of a radius of 3, give verbose messages of every unit transferred, and raze buildings according to raze chance (also removes palace) */ transfer_city(pcity-original, pcity, 3, TRUE, TRUE, TRUE); } } city_list_iterate_end; /* let there be civil war --- Imhotep */ // if (!is_barbarian(pplayer) (city_list_size(pplayer-cities)=2)) { if ((game.info.gameloss_style 2) city_list_size(pplayer-cities) = GAME_MIN_CIVILWARSIZE) { log_verbose("Civil war strikes the remaining empire of %s", pplayer-name); /* out of sheer cruelty we reanimate the player so he can behold what happens to his empire */ pplayer-is_alive = TRUE; (void) civil_war(pplayer); pplayer-is_alive = FALSE; } else { log_verbose("The empire of %s is too small for civil war, it vanishes without a trace.", pplayer-name); } struct player *barbarians = NULL; if (game.info.gameloss_style 1) { /* if parameter, create a barbarian, if possible */ barbarians = create_barbarian_player_land(); } /* if there are barbarians, the will take the remaining cities */ /* vae victis! */ if (barbarians) { //Imhotep DEBUG adv_data_phase_init(barbarians, TRUE); /* Transfer any remaining cities */ city_list_iterate(pplayer-cities, pcity) { transfer_city(barbarians, pcity, -1, FALSE, FALSE, FALSE); } city_list_iterate_end; game.server.savepalace = palace; /* Destroy all units that are still ours */ unit_list_iterate_safe(pplayer-units, punit) { wipe_unit(punit, ULR_PLAYER_DIED, NULL); } unit_list_iterate_safe_end; resolve_unit_stacks(pplayer, barbarians, FALSE); /* Choose a capital (random). */ city_build_free_buildings(city_list_get(barbarians-cities, fc_rand(city_list_size(barbarians-cities; /* Remove ownership of tiles */ whole_map_iterate(ptile) { if (tile_owner(ptile) == pplayer) { map_claim_ownership(ptile, NULL, NULL); } } whole_map_iterate_end; } else { // Imhotep /* Remove all units that are still ours */ unit_list_iterate_safe(pplayer-units, punit) { wipe_unit(punit, ULR_PLAYER_DIED, NULL); } unit_list_iterate_safe_end; /* Destroy any remaining cities */ city_list_iterate(pplayer-cities, pcity) { remove_city(pcity); } city_list_iterate_end; game.server.savepalace = palace; /* Remove ownership of tiles */ whole_map_iterate(ptile) { if (tile_owner(ptile) == pplayer) { map_cla
[Freeciv-Dev] gameloss_style
Hi there, after trying the wiki and the forum, I'm finally trolling here. (Not that I intend to troll but, the reactions (or the lack of) make me feel like that). I have recently managed to make a first version of the gameloss_style parameter. (See my posts on the forum and the wiki.) Depending on bit 2¹ there is civil war when a GameLoss figure is killed. Depending on bit 2⁰ the remaining cities fall to the barbarians or completely vanish without a trace. (Units go along with their cities, the rest is killed.) That's all for now, because I'm quite new to the code and I want to consolidate what I've coded before I make more extensions (like random benefits for the player that killed the enemy leader or tech losses for the resulting new AI). The code worked on one (and up to now only one) test. (BTW, why can't I copypaste the Messages window?) Now I am quite sure I did some horrible mistakes, first of all using C++-style comments (intended only to find my changes and to be removed before any committing), but there might also be some minor issues, like the code crashing in some circumstances. Or to introduce unnecessary complexity or missing some side effects. For example, to create the barbarians in plrhand.c I had not only to include barbarians.h but also I introduced a new function create_barbarian_player_land() in barbarians.*. The reason I introduced a new function was that the create_barbarian_palyer(enum barbarian_type type) is static, and I have no idea how to find out if this has a solid reason or might be only out of cautiousness, as it is generally a good idea to keep as many functions as possible static. So now, what is the next step? Committing my changes now is very certainly not a good idea. Learning all the rules by heart before coding anything is certainly not a good idea, too. Greetings from Imhotep ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
Re: [Freeciv-Dev] gameloss_style
Marko Lindqvist wrote: On 8 February 2013 22:44, Imhotep jmho...@slehr.de wrote: Hi there, after trying the wiki and the forum, I'm finally trolling here. (Not that I intend to troll but, the reactions (or the lack of) make me feel like that). I have recently managed to make a first version of the gameloss_style parameter. (See my posts on the forum and the wiki.) It's a bit hard to comment on code one doesn't see ;-) That indicates that you want to see it, so here it is (existing functions after my changes): in plrhand.c: /** Murder a player in cold blood. Called from srv_main kill_dying_players() and edit packet handler handle_edit_player_remove(). **/ void kill_player(struct player *pplayer) { bool palace; pplayer-is_alive = FALSE; /* reset player status */ player_status_reset(pplayer); /* Remove shared vision from dead player to friends. */ players_iterate(aplayer) { if (gives_shared_vision(pplayer, aplayer)) { remove_shared_vision(pplayer, aplayer); } } players_iterate_end; cancel_all_meetings(pplayer); /* Show entire map for players who are *not* in a team if revealmap is set * to REVEAL_MAP_DEAD. */ if (game.server.revealmap REVEAL_MAP_DEAD player_list_size(team_members(pplayer-team)) == 1) { map_know_and_see_all(pplayer); } if (!is_barbarian(pplayer)) { notify_player(NULL, NULL, E_DESTROYED, ftc_server, _("The %s are no more!"), nation_plural_for_player(pplayer)); } /* Transfer back all cities not originally owned by player to their rightful owners, if they are still around */ palace = game.server.savepalace; game.server.savepalace = FALSE; /* moving it around is dumb */ city_list_iterate(pplayer-cities, pcity) { if (pcity-original != pplayer pcity-original-is_alive) { /* Transfer city to original owner, kill all its units outside of a radius of 3, give verbose messages of every unit transferred, and raze buildings according to raze chance (also removes palace) */ transfer_city(pcity-original, pcity, 3, TRUE, TRUE, TRUE); } } city_list_iterate_end; /* let there be civil war --- Imhotep */ // if (!is_barbarian(pplayer) (city_list_size(pplayer-cities)=2)) { if ((game.info.gameloss_style 2) city_list_size(pplayer-cities) = GAME_MIN_CIVILWARSIZE) { log_verbose("Civil war strikes the remaining empire of %s", pplayer-name); /* out of sheer cruelty we reanimate the player so he can behold what happens to his empire */ pplayer-is_alive = TRUE; (void) civil_war(pplayer); pplayer-is_alive = FALSE; } else { log_verbose("The empire of %s is too small for civil war, it vanishes without a trace.", pplayer-name); } struct player *barbarians = NULL; if (game.info.gameloss_style 1) { /* if parameter, create a barbarian, if possible */ barbarians = create_barbarian_player_land(); } /* if there are barbarians, the will take the remaining cities */ /* vae victis! */ if (barbarians) { //Imhotep DEBUG adv_data_phase_init(barbarians, TRUE); /* Transfer any remaining cities */ city_list_iterate(pplayer-cities, pcity) { transfer_city(barbarians, pcity, -1, FALSE, FALSE, FALSE); } city_list_iterate_end; game.server.savepalace = palace; /* Destroy all units that are still ours */ unit_list_iterate_safe(pplayer-units, punit) { wipe_unit(punit, ULR_PLAYER_DIED, NULL); } unit_list_iterate_safe_end; resolve_unit_stacks(pplayer, barbarians, FALSE); /* Choose a capital (random). */ city_build_free_buildings(city_list_get(barbarians-cities, fc_rand(city_list_size(barbarians-cities; /* Remove ownership of tiles */ whole_map_iterate(ptile) { if (tile_owner(ptile) == pplayer) { map_claim_ownership(ptile, NULL, NULL); } } whole_map_iterate_end; } else { // Imhotep /* Remove all units that are still ours */ unit_list_iterate_safe(pplayer-units, punit) { wipe_unit(punit, ULR_PLAYER_DIED, NULL); } unit_list_iterate_safe_end; /* Destroy any remaining cities */ city_list_iterate(pplayer-cities, pcity) { remove_city(pcity); } city_list_iterate_end; game.server.savepalace = palace; /* Remove ownership of tiles */ whole_map_iterate(ptile) { if (tile_owner(ptile) == pplayer) { map_claim_ownership(ptile, NULL, NULL); } } whole_map_iterate_end; } /* Ensure this dead player doesn't win with a spaceship. * Now that would be truly unbelievably dumb - Per */ spaceship_init(pplayer-spaceship); send_spaceship_info(pplayer, NULL); send_player_info_c(pplayer, game.est_connections); } --- The other changes ar just minor things to make the main change work, and probably will change in d