Ejemplo n.º 1
0
 /// <summary>Returns (pos, isOnContradiction)</summary>
 /// <remark>Uses minimum weigh heuristics to minimize the risk of contradiction</summary>
 static (Vec2i, bool) selectNextCellToDecide(ref CellHeap heap, State state)
 {
     while (heap.hasAnyElement())
     {
         var cell = heap.pop();
         if (state.entropies[cell.x, cell.y].isDecided)
         {
             continue;
         }
         return(new Vec2i(cell.x, cell.y), false);
     }
     return(new Vec2i(-1, -1), true);  // contradicted
 }
Ejemplo n.º 2
0
        public Solver(Vec2i gridSize, State state)
        {
            this.heap       = new CellHeap(gridSize.area);
            this.nUnSolved  = gridSize.area;
            this.propagator = new Propagator();

            // make all the cells pickable
            for (int y = 0; y < gridSize.y; y++)
            {
                for (int x = 0; x < gridSize.x; x++)
                {
                    this.heap.add(x, y, state.entropies[x, y].entropyWithNoise());
                }
            }
        }