Example #1
0
            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));
            }
Example #2
0
            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));
            }
Example #3
0
            public UInt32 GetHashKey(int partition)
            {
                UInt32 hash = 0;
                int    pos;

                for (int index = 0, im = db.rows * db.cols; index < im; index++)
                {
                    pos = db.partitions[partition][board.Get(index)];
                    if (pos >= 0)                                        // correct partition? (including the empty tile)
                    {
                        hash |= ((UInt32)index) << (pos * BITS_PER_POS); // then save the current index to the default tile position
                    }
                }
                return(hash);
            }