public GameTable Pop() { int last=gameTableList.Count-1; if(last<0) return null; GameTable work=gameTableList[last]; gameTableList.RemoveAt(last); return work; }
private void buttonCheckResolving_Click(object sender, EventArgs e) { if (gameState < 0) // 0=not playing / 1=playing / -1-play stopped { return; } int ret = AnalyzeResult(solvetype.TESTRESULTS); if (ret > 1) { diffList = new List <int[]>(); int size = gameTable.boardsize; int difnb = resultList.gameTableList.Count; for (int nn = 0; nn < size; nn++) { GameTable firstTable = resultList.gameTableList[0]; gameTable.cell(nn).canresmask = 0; if (firstTable.cell(nn).orig == 1) { continue; } int num = 1 << (firstTable.cell(nn).fixNum - 1); for (int jj = 1; jj < difnb; jj++) { int numx = 1 << ((resultList.gameTableList[jj].cell(nn)).fixNum - 1); num |= numx; } int numnb = CountBits(num); if (numnb < 2) { continue; } gameTable.cell(nn).canresmask = num; diffList.Add(new int[] { nn, num }); } } }
public int Push(GameTable table) { gameTableList.Add(table.DeepClone<GameTable>(table)); return gameTableList.Count; }
void InitSuDokuTable(GameDef game) { gameTable = new GameTable(game.gxCells, game.gyCells); pictureTable_Resize(null, null); }
private int AnalyzeResult(solvetype type) { GameTable gameTableSave = gameTable.DeepClone(gameTable); sresult sret = SuSolve(type); // -1 - no solution // 0 - solved // >0 - other solve error string msgid; string msgtype; switch (sret) { case sresult.SOLVE_FEWDATA: msgid = chlang.GetLocalizedString("MB_msg_errfill"); msgtype = chlang.GetLocalizedString("MB_caption_err"); MessageBox.Show(msgid, msgtype, MessageBoxButtons.OK, MessageBoxIcon.Error); break; case sresult.SOLVE_IMPOSSIBLE: // "Lehetetlen megoldás" msgid = chlang.GetLocalizedString("MB_msg_NOresult"); msgtype = chlang.GetLocalizedString("MB_caption_err"); MessageBox.Show(msgid, msgtype, MessageBoxButtons.OK, MessageBoxIcon.Error); break; case sresult.SOLVE_CANCELLED: msgid = chlang.GetLocalizedString("MB_msg_stopped"); msgtype = chlang.GetLocalizedString("MB_caption_err"); MessageBox.Show(msgid, msgtype, MessageBoxButtons.OK, MessageBoxIcon.Error); break; case sresult.SOLVE_OK: // -1 "Jó megoldás !" // Returns: if (type == solvetype.MAKERESULT) { pictureTable_Resize(null, null); msgid = chlang.GetLocalizedString("MB_msg_result"); msgtype = chlang.GetLocalizedString("MB_caption_result"); } else { msgid = chlang.GetLocalizedString("MB_msg_solvable"); msgtype = chlang.GetLocalizedString("MB_caption_result"); } MessageBox.Show(msgid, msgtype, MessageBoxButtons.OK, MessageBoxIcon.Information); break; case sresult.SOLVE_NORESULT: // 0 "Hiba, nincs megoldás" msgid = chlang.GetLocalizedString("MB_msg_NOresult"); msgtype = chlang.GetLocalizedString("MB_caption_err"); MessageBox.Show(msgid, msgtype, MessageBoxButtons.OK, MessageBoxIcon.Error); break; case sresult.SOLVE_ONERESULT: // 1 "1 megoldás" msgid = chlang.GetLocalizedString("MB_msg_1result"); msgtype = chlang.GetLocalizedString("MB_caption_result"); MessageBox.Show(msgid, msgtype, MessageBoxButtons.OK, MessageBoxIcon.Information); break; case sresult.SOLVE_MORERESULT: // >15 "Több megoldás" msgid = string.Format(chlang.GetLocalizedString("MB_msg_MANYresult"), (int)sret); msgtype = chlang.GetLocalizedString("MB_caption_result"); MessageBox.Show(msgid, msgtype, MessageBoxButtons.OK, MessageBoxIcon.Information); break; default: // <15 "Több megoldás" msgid = string.Format(chlang.GetLocalizedString("MB_msg_NBresult"), (int)sret); msgtype = chlang.GetLocalizedString("MB_caption_result"); MessageBox.Show(msgid, msgtype, MessageBoxButtons.OK, MessageBoxIcon.Information); break; } gameTable = gameTableSave; gameTableSave = null; gameTable.ClearSelects(); pictureTable_Resize(null, null); return((int)sret); }