示例#1
0
 public MiniBoard(MiniBoard board)
 {
     this.rows = board.rows;
     this.cols = board.cols;
     this.b1   = board.b1;
     this.b2   = board.b2;
 }
            public BFSNode MoveDown(int partition)
            {
                MiniBoard b     = new MiniBoard(board);
                int       index = (empty_row * db.cols) + empty_col;
                UInt64    tile  = b.Get(index + db.cols); b.Set(index + db.cols, b.Get(index)); b.Set(index, tile);
                int       dist  = distance + ((db.partitioning[tile] == partition) ? 1 : 0);

                return(new BFSNode(db, b, empty_row + 1, empty_col, dist, Direction.DOWN));
            }
 private BFSNode(PatternDatabase db, MiniBoard board, int empty_row, int empty_col, int distance, Direction direction)
 {
     this.db        = db;
     this.empty_row = empty_row;
     this.empty_col = empty_col;
     this.board     = board;
     this.distance  = distance;
     this.direction = direction;
 }
            public BFSNode MoveLeft(int partition)
            {
                MiniBoard b     = new MiniBoard(board);
                int       index = (empty_row * db.cols) + empty_col;
                UInt64    tile  = b.Get(index - 1); b.Set(index - 1, b.Get(index)); b.Set(index, tile);
                int       dist  = distance + ((db.partitioning[tile] == partition) ? 1 : 0);

                return(new BFSNode(db, b, empty_row, empty_col - 1, dist, Direction.LEFT));
            }
 public BFSNode(PatternDatabase db)  // initial state --> the empty tile is in the bottom right corner
 {
     this.db        = db;
     this.empty_row = db.rows - 1;
     this.empty_col = db.cols - 1;
     this.direction = Direction.NONE;
     this.board     = new MiniBoard(db.rows, db.cols);
     this.distance  = 0;
 }