[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: computer-go: Sharing Go modules
> -----Original Message-----
> From: owner-computer-go@xxxxxxxxxxxxxxxxx
> [mailto:owner-computer-go@xxxxxxxxxxxxxxxxx]On Behalf Of Magnus Persson
> Sent: Wednesday, May 16, 2001 7:22 PM
> To: computer-go@xxxxxxxxxxxxxxxxx
> Subject: Re: computer-go: Sharing Go modules
>
>
> I use the same way of accessing an one-dimensional array except that
> I have two layers of border data, because I once thought that i would
> need to access a points two spaces away from a given point without
> having to check any boundaries.
>
> In practice I almost never do that (I only look at points one space
> away) so every array I use in my program spends a lot of memory (and
> since all my array big enough to hold 21x21 boards they are rather
> large).
>
In the early days I started out with a 21x21 array too, until I realized it
was a mistake. You get a two-point border at the sides, but only a one-point
border at the top and bottom.
> The only drawback I have experienced is in patternmatching - because
> the way I do it is necessary to work with x,y coordinates, and check
> for boundaries.
>
Yes, pattern-matching is one of those cases where using x,y coordinates is
often more convenient.
>
> --------
> var
> p: boardoffset;
> begin
> for u := 0 to 3 do
> begin
> Inc(p, URDL[u]); // UpRightDownLeft
> DoSomething(p);
> end;
> end;
I'm sure there are a dozen similar implementations in other Go programs.