public ActionType WhatResult2(TPosition Pos) { TAnalysisRes Res = new TAnalysisRes(); TFinal Finals = new TFinal(); foreach (TCoords C in Finals.ForWin) { Res = C.What(Pos); if (Res.Act == ActionType.Def) { return(ActionType.Def); } } foreach (TCoords C in Finals.ForWin) { Res = C.What(Pos); if (Res.Act == ActionType.Win) { return(ActionType.Win); } } return(ActionType.Neutral); }
public void Run(TPole Pole) { TAnalysis Analysis = new TAnalysis(); TAnalysisRes Res = Analysis.What(Pole.Pos); if (Res.Act != ActionType.Nil) { if (Pole.Move(Res.Coord.i, Res.Coord.j) != Result.Error) { return; } } for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { if (Pole.Move(i, j) != Result.Error) { return; } } } }
// } labvit public TAnalysisRes What(TPosition Pos) { TAnalysisRes Res = new TAnalysisRes(); int C_X = 0; int C_O = 0; int C_ = 0; foreach (TCoord c in C) { if (Pos.P[c.i, c.j] == 'X') { C_X++; } if (Pos.P[c.i, c.j] == 'O') { C_O++; } if (Pos.P[c.i, c.j] == ' ') { C_++; Res.Act = ActionType.Neutral; Res.Coord.i = c.i; Res.Coord.j = c.j; } } if (C_ == 1) { // if(C_X == 2) if (C_X == cell_count - 1) // labvit { Res.Act = ActionType.Def; } // if(C_O == 2) if (C_O == cell_count - 1) // labvit { Res.Act = ActionType.Win; } } return(Res); }
TAnalysisRes IsWin() { TAnalysisRes Res = new TAnalysisRes(); TFinal Finals = new TFinal(); foreach (TCoords C in Finals.ForWin) { Res = C.What(Pos); if (Res.Act == ActionType.Win) { return(Res); } } foreach (TCoords C in Finals.ForWin) { Res = C.What(Pos); if (Res.Act == ActionType.Def) { return(Res); } } foreach (TCoords C in Finals.ForWin) { Res = C.What(Pos); if (Res.Act == ActionType.Neutral) { return(Res); } } return(Res); }