[Freeciv-Dev] Re: [Patch] Exploring triremes getting lost (PR#961)
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
On Mon, Sep 17, 2001 at 06:47:13PM +0100, Gregory Berkolaiko wrote:
> --- Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx> wrote:
> > On Mon, Sep 17, 2001 at 05:12:49PM +0100, Gregory Berkolaiko wrote:
> > > anyway I don't know how to properly check the path for
> > > trireme-compliance...
> >
> > I said "an ideal solution". Mhh nevertheless a new exploring agent is
> > on my todo list. A working (for land units and sea units) agent for
> > goto planning already exists. And it is not a mess like the current
> > code. So I have hope for the future.
>
> ok attached is a patch which does not implement the ideal solution, but
> implements a solution.
>
> Exploring triremes belonging to human will never sink. At most (if there
> is nothing safe in sight to explore) it will ask you for guidance and
> will have enough movepoints to get back to land.
>
> Under ai the behaviour is much more safe than it is now, but instead of
> asking for human help it will continue moving towards possibly unsafe
> destination. With possibly tragic consequences. Again, this happens
> very rarely, so in any case it is an improvement.
>
> I considered asking trireme to return to the nearest port, but it
> involves changing a lot of unfamiliar code.
> +static int find_nearest_friendly_port(struct unit *punit);
??
> + int unknown, most_unknown = 0;
> + /* unknown is the composite weight for a tile, taking into account the
> + number of unknown tiles around and distance to it */
> int threshold = THRESHOLD * move_rate;
> + /* threshold is how far we would venture */
Comments should be above the things they describe.
> if (unknown) {
> - if (is_sailing_unit(punit))
> + if (is_sailing_unit(punit)) {
> unknown += 9 * (threshold - warmap.seacost[x1][y1]);
> - else
> + if (afraid_of_sinking && !is_coast_seen(x1,y1,pplayer))
> + unknown = 0; /* we want destination near a cost */
^^^^
You mean coast?
> @@ -334,8 +344,20 @@
> do_unit_goto(punit, GOTO_MOVE_ANY, 0);
> if (punit->moves_left) {
> if (punit->x != best_x || punit->y != best_y) {
Why and when does this case happen?
> - handle_unit_activity_request(punit, ACTIVITY_IDLE);
> - return 1; /* Something wrong; what to do but return? */
> + if (afraid_of_sinking /* Trireme is a bit lost
> but */
> + && !is_coastline(punit->x, punit->y)) {/* should still have
> movepoints */
> + if (pplayer->ai.control) {
> + do_unit_goto(punit, GOTO_DONT_KEEP_TO_SHORE, 0);
> + /* push on into the unknown */
> + } else {
> + handle_unit_activity_request(punit, ACTIVITY_IDLE);
> + return 0; /* Ask for human help */
> + }
> + handle_unit_activity_request(punit, ACTIVITY_IDLE);
> + }
> + return 1; /* Something wrong; what to do but return? 1 means reset
> X-mode */
> + /* Happens also when trireme doesn't want to leave the shore with */
> + /* less than full movepoints */
> } else
> return ai_manage_explorer(punit);
> } else {
> diff -ur -X./freeciv_mod/diff_ignore freeciv/common/unit.h
> freeciv_mod/common/unit.h
> --- freeciv/common/unit.h Sun Sep 16 11:38:08 2001
> +++ freeciv_mod/common/unit.h Mon Sep 17 16:42:51 2001
> @@ -55,7 +55,8 @@
> enum goto_move_restriction {
> GOTO_MOVE_ANY,
> GOTO_MOVE_CARDINAL_ONLY, /* No diagonal moves. */
> - GOTO_MOVE_STRAIGHTEST
> + GOTO_MOVE_STRAIGHTEST,
> + GOTO_DONT_KEEP_TO_SHORE /* Overrides trireme behaviour */
> };
>
> enum goto_route_type {
> Only in freeciv_mod/: rfile
> diff -ur -X./freeciv_mod/diff_ignore freeciv/server/gotohand.c
> freeciv_mod/server/gotohand.c
> --- freeciv/server/gotohand.c Sat Sep 15 17:31:26 2001
> +++ freeciv_mod/server/gotohand.c Mon Sep 17 19:16:57 2001
> @@ -957,10 +957,12 @@
> {
> int k, d[8], x, y, n, a, best = 0, d0, d1, h0, h1, u, c;
> struct tile *ptile, *adjtile;
> - int nearland;
> struct city *pcity;
> struct unit *passenger;
> struct player *pplayer = unit_owner(punit);
> + int afraid_of_sinking = (unit_flag(punit, F_TRIREME)
> + && !player_owns_active_wonder(pplayer, B_LIGHTHOUSE)
> + && !(restriction == GOTO_DONT_KEEP_TO_SHORE));
>
> if (map_get_terrain(punit->x, punit->y) == T_OCEAN)
> passenger = other_passengers(punit);
> @@ -1026,11 +1028,8 @@
> if (ptile->special&S_ROAD) d[k] += 10; /* in case we change directions
> */
> if (ptile->special&S_RAILROAD) d[k] += 10; /* next turn, roads are
> nice */
>
> - nearland = 0;
> - if (!pplayer->ai.control && !map_get_known(x, y, pplayer)) nearland++;
> for (n = 0; n < 8; n++) {
> adjtile = map_get_tile(x + DIR_DX[n], y + DIR_DY[n]);
> - if (adjtile->terrain != T_OCEAN) nearland++;
> if (!((adjtile->known)&(1u<<punit->owner))) {
> if (punit->moves_left <= c) d[k] -= (d[k]/16); /* Avoid the
> unknown */
> else d[k]++; /* nice but not important */
> @@ -1047,16 +1046,27 @@
> } /* end this-tile-is-seen else */
> } /* end tiles-adjacent-to-dest for */
>
> - if (unit_flag(punit, F_TRIREME) && !nearland) {
> - if (punit->moves_left < 6) d[k] = -1; /* Tired of Kaput!! -- Syela */
> - else if (punit->moves_left == 6) {
> - for (n = 0; n < 8; n++) {
> - if ((warmap.vector[x][y]&(1<<n))) {
> - if (is_coastline(x + DIR_DX[n], y + DIR_DY[n])) nearland++;
> + if (afraid_of_sinking && !is_coast_seen(x, y, pplayer)) {
> + if (punit->moves_left < (unit_move_rate(punit)+3)/2) {
s/3/SINGLE_MOVE/ ?!
Raimar
--
email: rf13@xxxxxxxxxxxxxxxxx
reality.sys corrupt. Reboot Universe? (y,n,q)
- [Freeciv-Dev] Re: [Patch] Exploring triremes getting lost (PR#961), (continued)
- [Freeciv-Dev] Re: [Patch] Exploring triremes getting lost (PR#961), Gregory Berkolaiko, 2001/09/17
- [Freeciv-Dev] Re: [Patch] Exploring triremes getting lost (PR#961), Raimar Falke, 2001/09/17
- [Freeciv-Dev] Re: [Patch] Exploring triremes getting lost (PR#961), Gregory Berkolaiko, 2001/09/17
- [Freeciv-Dev] Re: [Patch] Exploring triremes getting lost (PR#961), Raimar Falke, 2001/09/17
- [Freeciv-Dev] Re: [Patch] Exploring triremes getting lost (PR#961), Gregory Berkolaiko, 2001/09/17
- [Freeciv-Dev] Re: [Patch] Exploring triremes getting lost (PR#961), Niels Weber, 2001/09/17
- [Freeciv-Dev] Re: [Patch] Exploring triremes getting lost (PR#961), Raimar Falke, 2001/09/17
- [Freeciv-Dev] Re: [Patch] Exploring triremes getting lost (PR#961), Gregory Berkolaiko, 2001/09/17
- [Freeciv-Dev] Re: [Patch] Exploring triremes getting lost (PR#961), Raimar Falke, 2001/09/17
- [Freeciv-Dev] Re: [Patch] Exploring triremes getting lost (PR#961), Gregory Berkolaiko, 2001/09/17
- [Freeciv-Dev] Re: [Patch] Exploring triremes getting lost (PR#961),
Raimar Falke <=
- [Freeciv-Dev] Re: [Patch] Exploring triremes getting lost (PR#961), Gregory Berkolaiko, 2001/09/18
- [Freeciv-Dev] Re: [Patch] Exploring triremes getting lost (PR#961), Raimar Falke, 2001/09/18
- [Freeciv-Dev] Re: [Patch] Exploring triremes getting lost (PR#961), Gregory Berkolaiko, 2001/09/18
- [Freeciv-Dev] Re: [Patch] Exploring triremes getting lost (PR#961), Ross W. Wetmore, 2001/09/17
- [Freeciv-Dev] Re: [Patch] Exploring triremes getting lost (PR#961), Gregory Berkolaiko, 2001/09/18
- [Freeciv-Dev] Re: [Patch] Exploring triremes getting lost (PR#961), Tony Stuckey, 2001/09/18
[Freeciv-Dev] Warmap optimization (was Re: Exploring triremes getting lost), Gregory Berkolaiko, 2001/09/17
|
|