simulator (Re: [Icfp04-discuss] three liberal arts)

Laurent Desnogues laurent.desnogues at wanadoo.fr
Fri Jun 11 01:20:32 EDT 2004


Alex Shinn wrote:
>
> This is what I did, but it's not quite so simple in a hex map.  On
> both a square map and a hex map, moving left/right is an offset of
> -/+1, but whereas in the square map moving up/down is -/+N and
> diagonals are consistently +/-N+/-1, in a hex map the offset depends
> on whether you're in an even or odd row.  If you have to pass and
> check the row number, you're probably not gaining much over passing x
> and y together.
> 
> However, if you artificially expand the column size to some 2^k > N,
> then the index of a cell has the k-th bit set iff the cell is in an
> even row, so you can quickly determine if you're in an even row just
> from the index.

Make x the most significant part of your integer and
you only have to check againt least significant bit.
And this only requires width to be even.


		Laurent



More information about the Icfp04-discuss mailing list