Re: [Freeciv-Dev] (PR#34463) [Bug] Sea barbarians inactive
http://bugs.freeciv.org/Ticket/Display.html?id=34463 > On Thu, 25 Jan 2007, Marko Lindqvist wrote: Seen as global observer: Barbarian boats almost never move. If boat happens to spawn next to land, it almost never unloads units to land. >>> >>> Barbarian leader is in charge of the boat. He wants to go where other >>> barbarians protect him. All the other barbarians are sitting in the >>> same boat - in the same tile - he currently is. So the leader is very >>> happy not to move the boat. >> >> Fix to that particular bug attached. This alone does not fix the >> problem, though. Barbarian boat handling is broken in a number of >> ways. > > Rewritten ai_military_attack_barbarian() for fixing several boat > handling bugs. Now barbarian boats move at least sometimes. > Main remaining issue is that barbarians do not explore. If they don't > already know proper attack target (which is case quite often) they do > absolutely nothing. I suggest giving barbarian players the EFT_REVEAL_MAP effect so that they can see the entire map. - Per "The world owes you nothing. It was here first." -- Mark Twain ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
Re: [Freeciv-Dev] (PR#34463) [Bug] Sea barbarians inactive
On Thu, 25 Jan 2007, Marko Lindqvist wrote: Seen as global observer: Barbarian boats almost never move. If boat happens to spawn next to land, it almost never unloads units to land. Barbarian leader is in charge of the boat. He wants to go where other barbarians protect him. All the other barbarians are sitting in the same boat - in the same tile - he currently is. So the leader is very happy not to move the boat. Fix to that particular bug attached. This alone does not fix the problem, though. Barbarian boat handling is broken in a number of ways. Rewritten ai_military_attack_barbarian() for fixing several boat handling bugs. Now barbarian boats move at least sometimes. Main remaining issue is that barbarians do not explore. If they don't already know proper attack target (which is case quite often) they do absolutely nothing. I suggest giving barbarian players the EFT_REVEAL_MAP effect so that they can see the entire map. - Per "The world owes you nothing. It was here first." -- Mark Twain ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
Re: [Freeciv-Dev] (PR#34463) [Bug] Sea barbarians inactive
http://bugs.freeciv.org/Ticket/Display.html?id=34463 > On 1/26/07, Marko Lindqvist <[EMAIL PROTECTED]> wrote: > On 1/25/07, Marko Lindqvist <[EMAIL PROTECTED]> wrote: > > > > On 1/25/07, Marko Lindqvist <[EMAIL PROTECTED]> wrote: > > > > > > On 1/25/07, Marko Lindqvist <[EMAIL PROTECTED]> wrote: > > > > On 1/24/07, Marko Lindqvist <[EMAIL PROTECTED]> wrote: > > > > > > > > > > Barbarian leader is in charge of the boat. He wants to go where other > > > > > barbarians protect him. All the other barbarians are sitting in the > > > > > same boat - in the same tile - he currently is. So the leader is very > > > > > happy not to move the boat. > > > > > > > > Fix to that particular bug attached. This alone does not fix the > > > > problem, though. Barbarian boat handling is broken in a number of > > > > ways. > > > > > > Forget that patch. That approach is not working. Patch to > > > ai_military_attack_barbarian() is still valid. > > > > Better barbarian leader patch. Also new version of > > ai_military_attack_barbarian() patch, where one compile error is > > fixed. > > One more change to ai_military_attack_barbarian() patch. Changed one > error level log in to debug level, since it is not error at all. S2_1 version of ai_military_attack_barbarian() patch. Same leader patch applies to both trunk and S2_1. - ML diff -Nurd -X.diff_ignore freeciv/ai/aiunit.c freeciv/ai/aiunit.c --- freeciv/ai/aiunit.c 2006-07-17 14:28:36.0 +0300 +++ freeciv/ai/aiunit.c 2007-01-26 17:13:04.0 +0200 @@ -1628,28 +1628,53 @@ struct unit *punit) { struct city *pc; + bool any_continent = FALSE; - if ((pc = dist_nearest_city(pplayer, punit->tile, FALSE, TRUE))) { + if (punit->transported_by != -1) { +/* If we are in transport, we can go to any continent. + * Actually, we are not currently in a continent where to stay. */ +any_continent = TRUE; + } + + if ((pc = dist_nearest_city(pplayer, punit->tile, any_continent, TRUE))) { if (!is_ocean(tile_get_terrain(punit->tile))) { UNIT_LOG(LOG_DEBUG, punit, "Barbarian marching to conquer %s", pc->name); (void) ai_gothere(pplayer, punit, pc->tile); } else { struct unit *ferry = NULL; - unit_list_iterate(punit->tile->units, aunit) { - if (is_boat_free(aunit, punit, 2)) { - ferry = aunit; - break; - } - } unit_list_iterate_end; + if (punit->transported_by != -1) { +ferry = find_unit_by_id(punit->transported_by); + +/* We already are in a boat so it needs no + * free capacity */ +if (!is_boat_free(ferry, punit, 0)) { + /* We cannot control our ferry. */ + ferry = NULL; +} + } else { +/* We are not in a boat yet. Search for one. */ +unit_list_iterate(punit->tile->units, aunit) { + if (is_boat_free(aunit, punit, 1)) { +ferry = aunit; +punit->transported_by = ferry->id; +break; + } +} unit_list_iterate_end; + } + if (ferry) { UNIT_LOG(LOG_DEBUG, punit, "Barbarian sailing to conquer %s", pc->name); (void)aiferry_goto_amphibious(ferry, punit, pc->tile); } else { - UNIT_LOG(LOG_ERROR, punit, "unable to find barbarian ferry"); +/* This is not an error. Somebody else might be in charge + * of the ferry. */ +UNIT_LOG(LOG_DEBUG, punit, "unable to find barbarian ferry"); } } + } else { +UNIT_LOG(LOG_DEBUG, punit, "Barbarian find no target city"); } } ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
Re: [Freeciv-Dev] (PR#34463) [Bug] Sea barbarians inactive
http://bugs.freeciv.org/Ticket/Display.html?id=34463 > On 1/25/07, Marko Lindqvist <[EMAIL PROTECTED]> wrote: > > On 1/25/07, Marko Lindqvist <[EMAIL PROTECTED]> wrote: > > > > On 1/25/07, Marko Lindqvist <[EMAIL PROTECTED]> wrote: > > > On 1/24/07, Marko Lindqvist <[EMAIL PROTECTED]> wrote: > > > > > > > > Barbarian leader is in charge of the boat. He wants to go where other > > > > barbarians protect him. All the other barbarians are sitting in the > > > > same boat - in the same tile - he currently is. So the leader is very > > > > happy not to move the boat. > > > > > > Fix to that particular bug attached. This alone does not fix the > > > problem, though. Barbarian boat handling is broken in a number of > > > ways. > > > > Forget that patch. That approach is not working. Patch to > > ai_military_attack_barbarian() is still valid. > > Better barbarian leader patch. Also new version of > ai_military_attack_barbarian() patch, where one compile error is > fixed. One more change to ai_military_attack_barbarian() patch. Changed one error level log in to debug level, since it is not error at all. - ML diff -Nurd -X.diff_ignore freeciv/ai/aiunit.c freeciv/ai/aiunit.c --- freeciv/ai/aiunit.c 2007-01-25 23:31:33.0 +0200 +++ freeciv/ai/aiunit.c 2007-01-25 23:58:05.0 +0200 @@ -1628,28 +1628,52 @@ struct unit *punit) { struct city *pc; + bool any_continent = FALSE; - if ((pc = dist_nearest_city(pplayer, punit->tile, FALSE, TRUE))) { + if (punit->transported_by != -1) { +/* If we are in transport, we can go to any continent. + * Actually, we are not currently in a continent where to stay. */ +any_continent = TRUE; + } + + if ((pc = dist_nearest_city(pplayer, punit->tile, any_continent, TRUE))) { if (can_unit_exist_at_tile(punit, punit->tile)) { UNIT_LOG(LOG_DEBUG, punit, "Barbarian heading to conquer %s", pc->name); (void) ai_gothere(pplayer, punit, pc->tile); } else { struct unit *ferry = NULL; - unit_list_iterate(punit->tile->units, aunit) { - if (is_boat_free(aunit, punit, 2)) { - ferry = aunit; - break; - } - } unit_list_iterate_end; + if (punit->transported_by != -1) { +ferry = find_unit_by_id(punit->transported_by); + +/* We already are in a boat so it needs no + * free capacity */ +if (!is_boat_free(ferry, punit, 0)) { + /* We cannot control our ferry. */ + ferry = NULL; +} + } else { +/* We are not in a boat yet. Search for one. */ +unit_list_iterate(punit->tile->units, aunit) { + if (is_boat_free(aunit, punit, 1)) { +ferry = aunit; +punit->transported_by = ferry->id; +break; + } +} unit_list_iterate_end; + } if (ferry) { UNIT_LOG(LOG_DEBUG, punit, "Barbarian sailing to conquer %s", pc->name); (void)aiferry_goto_amphibious(ferry, punit, pc->tile); } else { - UNIT_LOG(LOG_ERROR, punit, "unable to find barbarian ferry"); +/* This is not an error. Somebody else might be in charge + * of the ferry. */ + UNIT_LOG(LOG_DEBUG, punit, "unable to find barbarian ferry"); } } + } else { +UNIT_LOG(LOG_DEBUG, punit, "Barbarian find no target city"); } } ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
Re: [Freeciv-Dev] (PR#34463) [Bug] Sea barbarians inactive
http://bugs.freeciv.org/Ticket/Display.html?id=34463 > On 1/25/07, Marko Lindqvist <[EMAIL PROTECTED]> wrote: > > On 1/25/07, Marko Lindqvist <[EMAIL PROTECTED]> wrote: > > On 1/24/07, Marko Lindqvist <[EMAIL PROTECTED]> wrote: > > > > > > On 1/24/07, Marko Lindqvist <[EMAIL PROTECTED]> wrote: > > > > > > > > Seen as global observer: Barbarian boats almost never move. If boat > > > > happens to spawn next to land, it almost never unloads units to land. > > > > > > Barbarian leader is in charge of the boat. He wants to go where other > > > barbarians protect him. All the other barbarians are sitting in the > > > same boat - in the same tile - he currently is. So the leader is very > > > happy not to move the boat. > > > > Fix to that particular bug attached. This alone does not fix the > > problem, though. Barbarian boat handling is broken in a number of > > ways. > > Forget that patch. That approach is not working. Patch to > ai_military_attack_barbarian() is still valid. Better barbarian leader patch. Also new version of ai_military_attack_barbarian() patch, where one compile error is fixed. - ML diff -Nurd -X.diff_ignore freeciv/ai/aiunit.c freeciv/ai/aiunit.c --- freeciv/ai/aiunit.c 2007-01-25 21:58:55.0 +0200 +++ freeciv/ai/aiunit.c 2007-01-25 23:30:04.0 +0200 @@ -2330,6 +2330,39 @@ handle_unit_activity_request(leader, ACTIVITY_SENTRY); return; } + + if (leader->transported_by != -1) { +/* Leader is at boat */ +struct unit *boat = find_unit_by_id(leader->transported_by); + +if (boat->ai.passenger == leader->id) { + /* We are in charge. Of course, since we are the leader... + * But maybe somebody more militaristic should lead our ship to battle! */ + + /* First release boat from leaders lead */ + aiferry_clear_boat(leader); + + unit_list_iterate(leader->tile->units, warrior) { +if (!unit_has_role(unit_type(warrior), L_BARBARIAN_LEADER) +&& get_transporter_capacity(warrior) == 0 +&& warrior->moves_left > 0) { + /* This seems like a good warrior to lead us in to conquest! */ + ai_manage_unit(pplayer, warrior); + + /* If we reached our destination, ferryboat already called + * ai_manage_unit() for leader. So no need to continue here. + * Leader might even be dead. + * If this return is removed, surronding unit_list_iterate() + * has to be replaced with unit_list_iterate_safe()*/ + return; +} + } unit_list_iterate_end; +} + +/* If we are not in charge of the boat, continue as if we + * were not in a boat - we may want to leave the ship now. */ + } + /* the following takes much CPU time and could be avoided */ generate_warmap(tile_get_city(leader->tile), leader); diff -Nurd -X.diff_ignore freeciv/ai/aiunit.c freeciv/ai/aiunit.c --- freeciv/ai/aiunit.c 2007-01-25 23:31:33.0 +0200 +++ freeciv/ai/aiunit.c 2007-01-25 23:32:03.0 +0200 @@ -1628,20 +1628,40 @@ struct unit *punit) { struct city *pc; + bool any_continent = FALSE; - if ((pc = dist_nearest_city(pplayer, punit->tile, FALSE, TRUE))) { + if (punit->transported_by != -1) { +/* If we are in transport, we can go to any continent. + * Actually, we are not currently in a continent where to stay. */ +any_continent = TRUE; + } + + if ((pc = dist_nearest_city(pplayer, punit->tile, any_continent, TRUE))) { if (can_unit_exist_at_tile(punit, punit->tile)) { UNIT_LOG(LOG_DEBUG, punit, "Barbarian heading to conquer %s", pc->name); (void) ai_gothere(pplayer, punit, pc->tile); } else { struct unit *ferry = NULL; - unit_list_iterate(punit->tile->units, aunit) { - if (is_boat_free(aunit, punit, 2)) { - ferry = aunit; - break; - } - } unit_list_iterate_end; + if (punit->transported_by != -1) { +ferry = find_unit_by_id(punit->transported_by); + +/* We already are in a boat so it needs no + * free capacity */ +if (!is_boat_free(ferry, punit, 0)) { + /* We cannot control our ferry. */ + ferry = NULL; +} + } else { +/* We are not in a boat yet. Search for one. */ +unit_list_iterate(punit->tile->units, aunit) { + if (is_boat_free(aunit, punit, 1)) { +ferry = aunit; +punit->transported_by = ferry->id; +break; + } +} unit_list_iterate_end; + } if (ferry) { UNIT_LOG(LOG_DEBUG, punit, "Barbarian sailing to conquer %s", pc->name); @@ -1650,6 +1670,8 @@ UNIT_LOG(LOG_ERROR, punit, "unable to find barbarian ferry"); } } + } else { +UNIT_LOG(LOG_DEBUG, punit, "Barbarian find no target city"); } } ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
Re: [Freeciv-Dev] (PR#34463) [Bug] Sea barbarians inactive
http://bugs.freeciv.org/Ticket/Display.html?id=34463 > On 1/25/07, Marko Lindqvist <[EMAIL PROTECTED]> wrote: > On 1/24/07, Marko Lindqvist <[EMAIL PROTECTED]> wrote: > > > > On 1/24/07, Marko Lindqvist <[EMAIL PROTECTED]> wrote: > > > > > > Seen as global observer: Barbarian boats almost never move. If boat > > > happens to spawn next to land, it almost never unloads units to land. > > > > Barbarian leader is in charge of the boat. He wants to go where other > > barbarians protect him. All the other barbarians are sitting in the > > same boat - in the same tile - he currently is. So the leader is very > > happy not to move the boat. > > Fix to that particular bug attached. This alone does not fix the > problem, though. Barbarian boat handling is broken in a number of > ways. Forget that patch. That approach is not working. Patch to ai_military_attack_barbarian() is still valid. - ML ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
Re: [Freeciv-Dev] (PR#34463) [Bug] Sea barbarians inactive
http://bugs.freeciv.org/Ticket/Display.html?id=34463 > On 1/25/07, Marko Lindqvist <[EMAIL PROTECTED]> wrote: > > On 1/24/07, Marko Lindqvist <[EMAIL PROTECTED]> wrote: > > > > On 1/24/07, Marko Lindqvist <[EMAIL PROTECTED]> wrote: > > > > > > Seen as global observer: Barbarian boats almost never move. If boat > > > happens to spawn next to land, it almost never unloads units to land. > > > > Barbarian leader is in charge of the boat. He wants to go where other > > barbarians protect him. All the other barbarians are sitting in the > > same boat - in the same tile - he currently is. So the leader is very > > happy not to move the boat. > > Fix to that particular bug attached. This alone does not fix the > problem, though. Barbarian boat handling is broken in a number of > ways. Rewritten ai_military_attack_barbarian() for fixing several boat handling bugs. Now barbarian boats move at least sometimes. Main remaining issue is that barbarians do not explore. If they don't already know proper attack target (which is case quite often) they do absolutely nothing. - ML diff -Nurd -X.diff_ignore freeciv/ai/aiunit.c freeciv/ai/aiunit.c --- freeciv/ai/aiunit.c 2007-01-25 12:08:09.0 +0200 +++ freeciv/ai/aiunit.c 2007-01-25 13:59:31.0 +0200 @@ -1628,20 +1628,40 @@ struct unit *punit) { struct city *pc; + bool any_continent = FALSE; - if ((pc = dist_nearest_city(pplayer, punit->tile, FALSE, TRUE))) { + if (punit->transported_by != -1) { +/* If we are in transport, we can go to any continent. + * Actually, we are not currently in a continent where to stay. */ +any_continent = TRUE; + } + + if ((pc = dist_nearest_city(pplayer, punit->tile, any_continent, TRUE))) { if (can_unit_exist_at_tile(punit, punit->tile)) { UNIT_LOG(LOG_DEBUG, punit, "Barbarian heading to conquer %s", pc->name); (void) ai_gothere(pplayer, punit, pc->tile); } else { struct unit *ferry = NULL; - unit_list_iterate(punit->tile->units, aunit) { - if (is_boat_free(aunit, punit, 2)) { - ferry = aunit; - break; - } - } unit_list_iterate_end; + if (punit->transported_by != -1) { +ferry = find_unit_by_id(punit->transported_by); + +/* We already are in a boat so it needs no + * free capacity */ +if (!is_boat_free(ferry, punit, 0)) { + /* We cannot control our ferry. */ + ferry = NULL; +} + } else { +/* We are not in a boat yet. Search for one. */ +unit_list_iterate(punit->tile->units, aunit) { + if (is_boat_free(aunit, punit, 1)) { +ferry = aunit; +punit->transported_by = ferry->id; +break; + } +} unit_list_iterate_end; + } if (ferry) { UNIT_LOG(LOG_DEBUG, punit, "Barbarian sailing to conquer %s", pc->name); @@ -1650,6 +1670,8 @@ UNIT_LOG(LOG_ERROR, punit, "unable to find barbarian ferry"); } } + } else { +UNIT_LOG(LOG_DEBUG, "Barbarian find no target city"); } } ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
Re: [Freeciv-Dev] (PR#34463) [Bug] Sea barbarians inactive
http://bugs.freeciv.org/Ticket/Display.html?id=34463 > On 1/24/07, Marko Lindqvist <[EMAIL PROTECTED]> wrote: > > On 1/24/07, Marko Lindqvist <[EMAIL PROTECTED]> wrote: > > > > Seen as global observer: Barbarian boats almost never move. If boat > > happens to spawn next to land, it almost never unloads units to land. > > Barbarian leader is in charge of the boat. He wants to go where other > barbarians protect him. All the other barbarians are sitting in the > same boat - in the same tile - he currently is. So the leader is very > happy not to move the boat. Fix to that particular bug attached. This alone does not fix the problem, though. Barbarian boat handling is broken in a number of ways. - ML diff -Nurd -X.diff_ignore freeciv/ai/aiunit.c freeciv/ai/aiunit.c --- freeciv/ai/aiunit.c 2006-07-25 13:42:32.0 +0300 +++ freeciv/ai/aiunit.c 2007-01-25 12:01:03.0 +0200 @@ -2308,6 +2308,21 @@ handle_unit_activity_request(leader, ACTIVITY_SENTRY); return; } + + if (leader->transported_by != -1) { +struct unit *boat = find_unit_by_id(leader->transported_by); + +if (boat->ai.passenger == leader->id) { + /* We are in charge. Of course, since we are the leader... + * ...but no, we don't want to be. We just want to + * go where other barbarians protect us, and currently + * it means we don't want to move. Let some more + * militaristic unit that might head to conquest control + * the boat. */ + aiferry_clear_boat(leader); +} + } + /* the following takes much CPU time and could be avoided */ generate_warmap(tile_get_city(leader->tile), leader); ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
Re: [Freeciv-Dev] (PR#34463) [Bug] Sea barbarians inactive
http://bugs.freeciv.org/Ticket/Display.html?id=34463 > On 1/24/07, Marko Lindqvist <[EMAIL PROTECTED]> wrote: > > Seen as global observer: Barbarian boats almost never move. If boat > happens to spawn next to land, it almost never unloads units to land. Barbarian leader is in charge of the boat. He wants to go where other barbarians protect him. All the other barbarians are sitting in the same boat - in the same tile - he currently is. So the leader is very happy not to move the boat. - ML ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
[Freeciv-Dev] (PR#34463) [Bug] Sea barbarians inactive
http://bugs.freeciv.org/Ticket/Display.html?id=34463 > Seen as global observer: Barbarian boats almost never move. If boat happens to spawn next to land, it almost never unloads units to land. - ML ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev