On 4/10/2016 12:19 AM, Jean-Francois Romang wrote:
Hello to everyone ; I'm a newcomer in this list and computer go programming. I have a chess programming background, but I want to start something new. :-) I'm currently in the early phases of developing GTP compatible go engine ; now it's time for me to choose a board representation : are there some articles or tips on this ?

i've only fooled around with this a /little/, bit at the lowest level, but i would start with something like below.

i suspect there is a lot more stuff that can be precalculated for a particular board size.

thanks

public class Go {
    enum Color {
    black,white,vacant,edge; // edge can be useful
    }
    enum Direction {
    n,s,e,w,ne,nw,se,sw
    }
    class Neighbors {
    Neighbors(int width,int depth) {
        this.width=width;
        this.depth=depth;
        this.size=(width+2)*(depth+2);
        n=new int[size];
        s=new int[size];
        e=new int[size];
        w=new int[size];
        ne=new int[size];
        nw=new int[size];
        se=new int[size];
        sw=new int[size];
// lots more init required, but it this is constant for any width and depth
    }
    final int width,depth,size;
    int[] n,s,e,w,ne,nw,se,sw; // index of neighbor
    }
    class Board {
    Board(Neighbors neighbors) {
        this.neighbors=neighbors;
        colors=new Color[neighbors.size];
    }
    final Color[] colors;
    final Neighbors neighbors;
    }
}

--
Honesty is a very expensive gift. So, don't expect it from cheap people - 
Warren Buffett
http://tayek.com/

_______________________________________________
Computer-go mailing list
Computer-go@computer-go.org
http://computer-go.org/mailman/listinfo/computer-go

Reply via email to