public static void CreateMatrix(int width, int height,Pieceboard.Chesstypes CT,PanelReplacement Grid) { if (Main!=null) { Main.clear(); Main = null; } grid = Grid; Main= new Pieceboard(width, height) { Thistype = CT }; Main.GridBlocked = new short[height][]; for (var y = 0; y < height; y++) { Main.GridBlocked[y] = new short[width]; for (var x = 0; x < width; x++) { var TB = new Button(); TB.Size = new Size(20, 20); TB.Click += piecechange; TB.Name = GetName(x, y); TB.Font = new Font("Microsoft Sans Serif", 8.25F, FontStyle.Bold, GraphicsUnit.Point, ((0))); grid.AddControl(TB, x != (width - 1)); } } Main.GridPieces = MatrixOps.CreateMatrix<Pieceboard.Chesstypes>(width, height); ApplyColour(); }
public static void ApplySolve(Pieceboard.Chesstypes ct) { var ret = Main.solveH(ct); if (ret.Count == 0) return; Main = null; Main = ret[0]; ApplyColour(); }
private bool isOptimum(Pieceboard pb) { var fs = pb.getFreeSpotCount(); return pb.PieceCount >= pb.BestScore && fs == 0; }
public Pieceboard clone() { var ret = new Pieceboard(Width, Height) { PieceCount = PieceCount, BestScore = BestScore, Thistype = Thistype }; ret.GridBlocked = MatrixOps.CloneMatrix(GridBlocked, Width, Height); ret.GridPieces = MatrixOps.CloneMatrix(GridPieces, Width, Height); return ret; }
public static void ChangeType(Pieceboard.Chesstypes ct) { Main.Thistype = ct; OverlayPossibleMoves(); }