Re: [Freeciv-Dev] (PR#40570) [Patch] marine explorers try to violate peace treaties and thus are stoped
URL: http://bugs.freeciv.org/Ticket/Display.html?id=40570 On Monday 24 November 2008, Madeline Book wrote: 1) it doesn't work for non_allied_unit_tiles that have only allied units on them I may be mistaken but, do you mean that the explorer can move to a tile in territory it cannot enter (by peace treaty) if there are allied units on that tile (and presumably the owner of those units is allowed to enter that territory)? As far as I know, allied units cannot be used in this way to sneak past borders (but a demonstrating savegame would convince me). You are right, below the situation I was observing - but notice that A's units are NonMil... A and B are at peace. A and C are allies without map sharing. B and C aren't at peace. C's unit - and only C's unit - is on one of B's tiles. At least A's Engineers and Settlers can access that tile. 2) fails for units that ignore controll zones (e.g. Diplomats) This confuses me, since zones of control (zoc) do not have anything to do with allowing units to enter a territory. Rather, they prevent non-ally units from moving into tiles in each others' zones of control (to summarise crudely). Maybe what you mean is that non-military units (unit flag NonMil) can enter peaceful territory, while military units cannot? So a unit with the non-military flag set to explore should consider peaceful territory allowed for the purpose of exploration? Actually Partisans aren't NonMil and still can enter peace tiles. Well, if the unit is a diplomat or spy, the other player could interpret the move as some kind of provocation, since they cannot see the 'X' showing that the unit is just there to explore. So I'm not sure that allowing the explorer AI to do that is such a good idea. I guess it is debatable, and I would accept a patch that has this behaviour. Atleast Explorer should be allowed to auto explore peace tiles. The really interresting case are diplomatic lanes - see the sea lane bug and substitute trimes with diplomats. 3) explorer_desirable doesn't check no_fights 4) explorer_desirable fails to handle allied cities Hmm, are you sure that explorer_desirable is called on tiles for which no_fights returns TB_IGNORE? I mean the tiles that are passed into explorer_desirable are read from the path finding map which uses no_fights already to prune away those tiles, it would seem to me. If so, this pruning was introduced after the 2.1.6 release (haven't checked). Well, in any case perhaps best is to make a new tb function structured specifically for explorers and put it in common/aicore/pf_tools.c. This function should be used in ai_fill_unit_param (instead of having to be set after the call and clobbering the existing get_TB pointer), and also in explorer_desirable (if indeed it is the case that it considers tiles that might have to be ignored) so that the checking code is not duplicated in more than one place. Yes. One problem with the no_fight change is what happens to ai units on a tile that just become a peace tile. Can they still move (2.1.6) or are they frosen? ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
Re: [Freeciv-Dev] (PR#40570) [Patch] marine explorers try to violate peace treaties and thus are stoped
URL: http://bugs.freeciv.org/Ticket/Display.html?id=40570 On Friday 21 November 2008, Madeline Book wrote: I did some more investigating in the code and it would seem that there is a much simpler way to fix the problem. The attached patch makes a one line addition to the tile behaviour parameter function no_fights() to make it ignore tiles that are part of a territory the player cannot enter by treaty. As far as I can tell, this makes auto-explore work exactly the same as your patch. I will test it some more (as I hope you and others will too) to see if there are not any bad side-effects in the AI code, since no_fights is used for more than just exploring. Your no_fights appoach is nice but insufficent. 1) it doesn't work for non_allied_unit_tiles that have only allied units on them 2) fails for units that ignore controll zones (e.g. Diplomats) 3) explorer_desirable doesn't check no_fights 4) explorer_desirable fails to handle allied cities Sample for a pedestrian(? unknown, ~ water, = land, C allied city): ??? ~C~ === ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
[Freeciv-Dev] (PR#40570) [Patch] marine explorers try to violate peace treaties and thus are stoped
URL: http://bugs.freeciv.org/Ticket/Display.html?id=40570 Marine explorers stop if they try to travel to or trhough a marine tile who's owner is at peace with the unit's owner. As a consequence the units are stoped and require player interaction even though there are still unexplored reacheable tiles. The attached patch should fixe this issue in the vast majority of cases. Only if ai_manage_explorer's best_title isn't reacheable does the explorer stop, even if there are still other unexplored reachable tiles. diff -ur freeciv-2.1.6/ai/aiexplorer.c freeciv-2.1.6-marine-explorer/ai/aiexplorer.c --- freeciv-2.1.6/ai/aiexplorer.c 2008-08-10 14:56:15.0 +0200 +++ freeciv-2.1.6-marine-explorer/ai/aiexplorer.c 2008-11-18 14:30:08.0 +0100 @@ -107,6 +107,51 @@ } } +/* + * Explorers shouldn't try to break a peace treaty and thus cause + * player interaction. + */ +static bool ai_may_explore(const struct tile * ptile, +const struct player * pplayer, const bv_flags unit_flags) +{ + if(! BV_ISSET(unit_flags, F_IGZOC)){ +// don't invade unless there are only allied troops on the tile +if(players_non_invade(ptile-owner, pplayer)){ + if(!is_allied_unit_tile(ptile, pplayer)){ +return FALSE; + } +} + } + + // don't attack + if(is_non_allied_unit_tile(ptile, pplayer)){ +return FALSE; + } + + return TRUE; +} + +enum tile_behavior ai_explorer_tb(const struct tile *ptile, enum known_type k, +struct pf_parameter * param) +{ + if(!ai_may_explore(ptile, param-owner, param-unit_flags)){ +return TB_IGNORE; + } + return TB_NORMAL; +} + +static bool ai_explorer_goto(struct unit *punit, struct tile *ptile) +{ + struct pf_parameter parameter; + struct ai_risk_cost risk_cost; + + ai_fill_unit_param(parameter, risk_cost, punit, ptile); + parameter.get_TB = ai_explorer_tb; + + UNIT_LOG(LOG_DEBUG, punit, ai_explorer_goto to %d,%d, ptile-x, ptile-y); + return ai_unit_goto_constrained(punit, ptile, parameter); +} + /** Return a value indicating how desirable it is to explore the given tile. In general, we want to discover unknown terrain of the opposite kind to @@ -170,6 +215,11 @@ return 0; } + /* Enforce diplomatic realtions. */ + if(! ai_may_explore(ptile, punit-owner, unit_type(punit)-flags)){ + return 0; + } + /* What value we assign to the number of land and water tiles * depends on if we're a land or water unit. */ if (is_ground_unit(punit)) { @@ -345,7 +395,7 @@ if (best_tile != NULL) { /* TODO: read the path off the map we made. Then we can make a path * which goes beside the unknown, with a good EC callback... */ -if (!ai_unit_goto(punit, best_tile)) { +if (!ai_explorer_goto(punit, best_tile)) { /* Died? Strange... */ return MR_DEATH; } ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev