public void updateMove(Cell cell1, Cell cell2, CellRow[] board) { if ((Mathf.Abs(cell2.getCol() - cell1.getCol()) == 2) && (Mathf.Abs(cell2.getRow() - cell1.getRow()) == 2)) { CellRow cr = board[cell1.getRow() + 1]; Cell c; if (cell2.getCol() - cell1.getCol() == 2) { cell2.setType(cell1.getType()); cell1.setType(1); cr.getCell(cell1.getCol() + 1).setType(1); } else { cell2.setType(cell1.getType()); cell1.setType(1); cr.getCell(cell1.getCol() - 1).setType(1); } } else { if ((Mathf.Abs(cell2.getCol() - cell1.getCol()) == 1) && (Mathf.Abs(cell2.getRow() - cell1.getRow()) == 1)) { cell2.setType(cell1.getType()); cell1.setType(1); } } }
public AllowedValueEnumerator(Sudoku sudoku, Random rnd) { _sudoku = sudoku; // determine best cell to process _cell = GetNextCell(_sudoku); // create enumerator for possible value var values = Util.BitRegister[_cell.AllowedValues]; _valueEnumerator = rnd == null?values.Cast <int>().GetEnumerator() : values.Randomize(rnd).GetEnumerator(); }
private void row_EndingEdit(object sender, System.ComponentModel.CancelEventArgs e) { // Todo: Xceed.Grid 不能插入空行 if (m_grid.DisplayManager.InBatchOperation) { return; } CellRow row = sender as CellRow; if (row is Xceed.Grid.InsertionRow) { if (!m_isInInsertRowEdit) { return; } e.Cancel = !DoValidateRow(row, e); if (!e.Cancel) { if (RowSaving != null) { RowSaving(sender, e); } if (!e.Cancel) { m_isInInsertRowEdit = false; } } } else if (row is Xceed.Grid.DataRow) { if (!m_isInDataRowEdit) { return; } e.Cancel = !DoValidateRow(row, e); if (!e.Cancel) { if (RowSaving != null) { RowSaving(sender, e); } // 保存成功否? if (!e.Cancel) { m_isInDataRowEdit = false; } } } }
private void InitCellButtonAdjacencyList() { foreach (List <CellViewModel> CellRow in this.UICellAdjajencyList) { // create a list of the buttons from the current row in order List <Button> ButtonsInRow = CellRow.Select(Cell => Cell.Button).ToList(); // add buttons to the button adj. list this.CellButtonAdjacencyList.Add(ButtonsInRow); } }
public int[,] makeItEasy(CellRow[] board) { int[,] intBoard = new int[8, 8]; for (int i = 0; i < 8; i++) { CellRow cr = board[i]; for (int k = 0; k < 8; k++) { Cell c = cr.getCell(k); intBoard[i, k] = c.getType(); } } return(intBoard); }
private void SetupBoard() { for (int r = 0; r < Rows; r++) { var cellRow = new CellRow(); Cells.Add(cellRow); for (int c = 0; c < Columns; c++) { var cell = new Cell(r, c, Rows, Columns); cellRow.Add(cell); } } }
//yeet CellRow[] copyCR(CellRow[] ogboard) { CellRow[] copy = new CellRow[8]; for (int l = 0; l < 7; l++) { CellRow ori = ogboard[l]; CellRow currentCR = copy[l]; for (int k = 0; k < 7; k++) { Cell toCopy = ori.getCell(k); int toCopyType = toCopy.getType(); Cell hi = new Cell(toCopyType, l, k); copy[k] = hi; } } return(copy); }
protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state) { PropertyDescriptor property = context.DataContext.GetProperties()[ExcelCreate.GetExcelAppTag]; Excel::Application excelApp = property.GetValue(context.DataContext) as Excel::Application; try { Int32 cellColumn = CellColumn.Get(context); Int32 cellRow = CellRow.Get(context); string cellName = CellName.Get(context); string sheetName = SheetName.Get(context); Excel::_Worksheet sheet; if (sheetName == null) { sheet = excelApp.ActiveSheet; } else { sheet = excelApp.ActiveWorkbook.Sheets[sheetName]; } object cellContent = null; if (cellName == null) { cellContent = sheet.Cells[cellRow, cellColumn].Value2; } else { cellContent = sheet.Range[cellName].Value2; } CellContent.Set(context, cellContent); System.Runtime.InteropServices.Marshal.ReleaseComObject(sheet); sheet = null; GC.Collect(); } catch (Exception e) { SharedObject.Instance.Output(SharedObject.enOutputType.Error, "EXCEL获取单元格内容出错", e.Message); new CommonVariable().realaseProcessExit(excelApp); } m_Delegate = new runDelegate(Run); return(m_Delegate.BeginInvoke(callback, state)); }
public void crownMeBitch(CellRow[] board) { CellRow cr0 = board[0]; CellRow cr7 = board[7]; for (int i = 0; i < 7; i++) { if (cr0.getCell(i).getType() == 4) { cr0.getCell(i).setType(5); } } for (int i = 0; i < 7; i++) { if (cr7.getCell(i).getType() == 2) { cr7.getCell(i).setType(3); } } }
static void Main(string[] args) { int seed; bool isValidSeed = CheckSeed(args, out seed); if (isValidSeed) { //Create a instance of CellRow & pass the seed value CellRow cellRow = new CellRow(seed); for (int i = 0; i < GENERATIONS; i++) { //Print the States of the current Cellline then produce new Generation cellRow.PrintRow(i); cellRow.NewGeneration(i); } //Print the Final Hash value of the last generation. cellRow.FinalHash(); } else CellRow.ErrorMessage(); }
public void codeToGUI(CellRow[] board) { for (int i = 0; i < 8; i++) { CellRow cr = board[i]; for (int k = 0; k < 8; k++) { Cell c = cr.getCell(k); int cellType = c.getType(); switch (cellType) { case 1: c.transform.GetChild(0).gameObject.SetActive(false); break; case 2: c.transform.GetChild(0).gameObject.SetActive(true); c.transform.GetChild(0).gameObject.GetComponent <MeshRenderer>().material = materials[0]; break; case 3: c.transform.GetChild(0).gameObject.SetActive(true); c.transform.GetChild(0).gameObject.GetComponent <MeshRenderer>().material = materials[1]; break; case 4: c.transform.GetChild(0).gameObject.SetActive(true); c.transform.GetChild(0).gameObject.GetComponent <MeshRenderer>().material = materials[2]; break; case 5: c.transform.GetChild(0).gameObject.SetActive(true); c.transform.GetChild(0).gameObject.GetComponent <MeshRenderer>().material = materials[3]; break; } } } }
private static CellRow GetNextCell(Sudoku sudoku) { CellRow best = null; var minCount = 10; foreach (var cell in sudoku._model.CellTable) { if (cell.Value == 0) { var bitCount = Util.BitCountRegister[cell.AllowedValues]; // 2 is the best possible result - 0 is prevented by CellValidator and 1 by AutoComplete() if (bitCount == 2) { return(cell); } if (bitCount < minCount) { best = cell; minCount = bitCount; } } } return(best); }
public bool validPlayerKill(Cell cell1, Cell cell2, CellRow[] board) { //for reg piece if (cell1.getType() == 2) { if (cell2.getType() == 1) { //for single jump else if ((Mathf.Abs(cell2.getCol() - cell1.getCol()) == 2) && (cell2.getRow() - cell1.getRow() == 2)) { CellRow cr = board[cell1.getRow() + 1]; Cell c; if (cell2.getCol() - cell1.getCol() == 2) { c = cr.getCell(cell1.getCol() + 1); } else { c = cr.getCell(cell1.getCol() - 1); } if (c.getType() == 4 || c.getType() == 5) { return(true); } else { return(false); } } return(false); } else { return(false); } }
private void row_EditCanceled(object sender, EventArgs e) { CellRow row = sender as CellRow; ClearError(row); }
/// <summary> /// Init Board with all InActive cells /// </summary> /// <param name="rows">number of rows on the board</param> /// <param name="columns">Number of columns on the board</param> private void Init(int rows, int columns) { if (rows <= 0 || columns <= 0) throw new ArgumentOutOfRangeException("out of range"); Cells = new List<CellRow>(); for (int i = 0; i < rows; i++) { CellRow row = new CellRow(); for (int j = 0; j < columns; j++) { Cell cell = new Cell(false); //InActive cells row.Add(cell); } Cells.Add(row); } }