Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2001:
[Freeciv-Dev] Re: directional system: more magic code cleanups
Home

[Freeciv-Dev] Re: directional system: more magic code cleanups

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: rf13@xxxxxxxxxxxxxxxxxxxxxx
Cc: "Ross W. Wetmore" <rwetmore@xxxxxxxxxxxx>, jdorje@xxxxxxxxxxxxxxxxxxxxx, freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: directional system: more magic code cleanups
From: "Ross W. Wetmore" <rwetmore@xxxxxxxxxxxx>
Date: Thu, 20 Sep 2001 20:29:12 -0400

At 10:46 AM 01/09/20 +0200, Raimar Falke wrote:
>On Tue, Sep 18, 2001 at 11:57:06PM -0400, Ross W. Wetmore wrote:
>> Attached is a copy of straightest_dir with yet another explanation 
>> of the algorithm embedded as comments in hopes that repetition will
>> eventually penetrate those that still haven't got it :-).
>> 
>> Note that to choose one of 8 directions, the absolute minimum work
>> is 3 binary compares, so there is still room for improvement in the
>> attached algorithm.
>
>[ The following mail is off topic and a negative example that you can
>optimize too much. It just shows that I like a good problem. ]
>
>The fastest version I can think of goes like this:

Unfortunately, I think the corecleanup algorithm actually had fewer 
instructions, certainly compares, and no multiplication or division, 
plus it was more general.

It is also better to put the Direction enums in an easily replaceable
array, than to hardcode them into code.

But at least this is an O(0) solution instead of the fully fledged
O(n) one you started with.

We are getting there! even if by process of elimination :-)

>       Raimar
>-- 
> email: rf13@xxxxxxxxxxxxxxxxx
> "There are three ways to get something done. Do it yourself, hire someone
>  to do it for you or forbid your kids to do it."

Cheers,
RossW
=====




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