Complete.Org: Mailing Lists: Archives: freeciv-dev: May 2000:
[Freeciv-Dev] Re: goto cleanup
Home

[Freeciv-Dev] Re: goto cleanup

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: goto cleanup
From: Falk Hueffner <falk.hueffner@xxxxxxxxxxxxxxxxxxxxxxxx>
Date: 24 May 2000 00:23:00 +0200

Thue Janus Kristensen <thue@xxxxxxx> writes:

> On Tue, 23 May 2000, Falk Hueffner wrote:
> > I wonder if it wouldn't be easier to simply add a small constant to
> > the move costs on every move (with maxMoves * constant < 1). That
> > would also have the nice effect that for costwise equivalent paths, it
> > would choose the one with the least number of moves. This could be
> > implemented either with floats or by pre-shifting the move costs by,
> > say, 16 and using 1 as constant.
>
> Yes, that would actually be a nice simple solution. 16 would be a
> bit much since the warmap use chars for movecosts and therefore have
> a maximum of 255. (it would be nice for GOTOs to be longer than 20
> tiles max...) We could use a smaller constant or change the warmap
> to use shorts. Since changing to shorts in the case of a maximally
> sized 200x100 map would only take 20KB I propose we do that.

I would even suggest to take ints or floats, since they're faster.
Floats seem easiest, no need to scale the movement costs before adding
the constant[1]. There's only ever one warmap, right? so it doesn't
really matter with regard to memory.

> I guess this will also remove some calculation in dir_ok(), also
> nice!

I'm not sure if there's any need for dir_ok() ar all with this
method...

> Will you make an updated patch or shall I?

Uhm, you're more into the code I think... If you don't get around, I
could do it, though.

A disadvantage, btw, is that the AI will have less paths for
evaluation. I don't know what it acutally does with the set of
optimal paths, seems it optimizes for least unit stacking or
something. That mechanism would suffer. I still think it would be
worth it (and it would allow a 100% optimal solution to be found much
easier).

        Falk


[1] Folks without FPUs please raise your hands, since currently I
assume you don't really exist.




[Prev in Thread] Current Thread [Next in Thread]