[Freeciv-Dev] Re: directional system: more magic code cleanups
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
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.
This should be compared to Raimar's latest compute intensive for loop
version, noting that they are both directional system dependent in
that they assume 2-D rectangular coordinate system x,y arguments, and
return one of the 8 possible directions in this type of system.
This one deals with any of the 4 topologies obtained by wrapping one
of the 4 directions, but can be trivially modified to work with a
standard map, either by redefining the has_mapwrap function to return
constant values (compiler should optimize) or removing the appropriate
tests manually.
Cheers,
RossW
=====
At 08:56 PM 01/09/18 -0400, Ross W. Wetmore wrote:
>Both of these are pretty expensive replacements for something that
>takes 4-6 compares and about the same number of arithmetic operations.
>
>I think in the end this will follow the same path as the previously
>submitted patch, modulo how you actually handle the case where the
>two directions are equal. In this case the earlier patch chooses
>diagonal over cartesian, which leaves the most flexibilty for the
>final moves.
[...]
>>I have attached a version which doesn't use float and sqrt. Please
>>review.
>>
>> Raimar
>>--
>> email: rf13@xxxxxxxxxxxxxxxxx
>> Living on earth may be expensive, but it includes an annual free trip
>> around the sun.
straightest_dir.c
Description: Text document
- [Freeciv-Dev] Re: directional system: more magic code cleanups, (continued)
- [Freeciv-Dev] Re: directional system: more magic code cleanups, Gregory Berkolaiko, 2001/09/17
- [Freeciv-Dev] Re: directional system: more magic code cleanups, Raimar Falke, 2001/09/17
- [Freeciv-Dev] Re: directional system: more magic code cleanups, Gregory Berkolaiko, 2001/09/17
- [Freeciv-Dev] Re: directional system: more magic code cleanups, Raimar Falke, 2001/09/17
- [Freeciv-Dev] Re: directional system: more magic code cleanups, Jason Dorje Short, 2001/09/17
- [Freeciv-Dev] Re: directional system: more magic code cleanups, Raimar Falke, 2001/09/17
- [Freeciv-Dev] Re: directional system: more magic code cleanups, Jason Dorje Short, 2001/09/17
- [Freeciv-Dev] Re: directional system: more magic code cleanups, Raimar Falke, 2001/09/18
- [Freeciv-Dev] Re: directional system: more magic code cleanups, Jason Dorje Short, 2001/09/18
- [Freeciv-Dev] Re: directional system: more magic code cleanups, Ross W. Wetmore, 2001/09/18
- [Freeciv-Dev] Re: directional system: more magic code cleanups,
Ross W. Wetmore <=
- [Freeciv-Dev] Re: directional system: more magic code cleanups, Raimar Falke, 2001/09/19
- [Freeciv-Dev] Re: directional system: more magic code cleanups, Raimar Falke, 2001/09/20
- [Freeciv-Dev] Re: directional system: more magic code cleanups, Ross W. Wetmore, 2001/09/20
- [Freeciv-Dev] Re: directional system: more magic code cleanups, Raimar Falke, 2001/09/21
- [Freeciv-Dev] Re: directional system: more magic code cleanups, Ross W. Wetmore, 2001/09/21
- [Freeciv-Dev] Re: directional system: more magic code cleanups, Raimar Falke, 2001/09/23
- [Freeciv-Dev] Re: directional system: more magic code cleanups, Ross W. Wetmore, 2001/09/24
- [Freeciv-Dev] Re: directional system: more magic code cleanups, Raimar Falke, 2001/09/24
- [Freeciv-Dev] Re: directional system: more magic code cleanups, Ross W. Wetmore, 2001/09/25
- [Freeciv-Dev] Re: directional system: more magic code cleanups, Raimar Falke, 2001/09/25
|
|