/// <summary> /// 深度分析(VCF) /// </summary> public StateEnum DeepAnalyze() { #region 待VCF时,判断己VCF是否成立 if (Result == StateEnum.WVCF) { PieceInfo VCFPoint = TryGetVCFPiece(CurrentBoard, m4LtS, CurrentBoard.Step + 1); //VCF成立返回VCF点 if (VCFPoint != null) { MaxLev = LevelEnum.VCF_5; MaxLt.Add(VCFPoint); Result = StateEnum.Win; return(Result); }//无VCF继续分析 else { Result = Analyze(highLevS, highLevD, highLtS, highLtD, m4LtS.Count, m4LtD.Count, ProcessEnum.己无VCF); } } #endregion #region 待敌VCF时,判断敌VCF是否成立 if (Result == StateEnum.WAVCF) { PieceInfo VCFPoint_D = TryGetVCFPiece(CurrentBoard, m4LtD, CurrentBoard.Step + 2); //敌VCF成立返回VCF点 if (VCFPoint_D != null) { MaxLev = LevelEnum.VCF_5; MaxLt.Add(VCFPoint_D); Result = StateEnum.Loss; return(Result); }//无VCF继续分析 else { Result = Analyze(highLevS, highLevD, highLtS, highLtD, m4LtS.Count, m4LtD.Count, ProcessEnum.敌无VCF); } } #endregion #region 双方无VCF if (Result == StateEnum.Win || Result == StateEnum.A) { MaxLev = highLevS; MaxLt = highLtS; } else if (Result == StateEnum.Loss || Result == StateEnum.D) { MaxLev = highLevD; MaxLt = highLtD; } else { MaxLev = highLevS; MaxLt = highLtS; } return(Result); #endregion }
private bool ChackIsVCFPiece(Board board, PieceInfo m4Point, int step) { //冲4点落子棋盘 Board V1Board = board.ChangeBoard(m4Point.X, m4Point.Y, step); BoardInfo V1BoardInfo = new BoardInfo(V1Board, currentLooplev + 1); //冲4必防点 PieceInfo V2Piece = V1BoardInfo.MaxLt[0]; //冲4防守点落子棋盘 Board V2Board = V1Board.ChangeBoard(V2Piece.X, V2Piece.Y, step + 1); BoardInfo V2BoardInfo = new BoardInfo(V2Board, currentLooplev + 1); StateEnum flag = V2BoardInfo.GetVCFResult(); return(flag == StateEnum.Win); }
public PieceInfo GetPieceInfo(int x, int y) { PieceInfo info = new PieceInfo(); for (int i = 0; i < 4; i++) { info.X = x; info.Y = y; info.PLine[i] = CurrentBoard.GetLinePieces(x, y, i); info.Names[ColourEnum.Black][i] = GetName(info.PLine[i], ColourEnum.Black, ColourEnum.Empty); info.Names[ColourEnum.White][i] = GetName(info.PLine[i], ColourEnum.White, ColourEnum.Empty); } info.Levels[ColourEnum.Black] = GetLevByName(info.Names[ColourEnum.Black]); info.Levels[ColourEnum.White] = GetLevByName(info.Names[ColourEnum.White]); return(info); }
private PieceInfo TryGetVCFPiece(Board board, List <PieceInfo> m4Lt, int step) { PieceInfo returnPoint = null; if (currentLooplev < MaxLooplev) { Parallel.ForEach(m4Lt, (m4Point, ParallelLoopState) => { if (ChackIsVCFPiece(board, m4Point, step)) { returnPoint = m4Point; ParallelLoopState.Stop(); return; } }); } return(returnPoint); }
private StateEnum GetVCFResult() { if (this.Result == StateEnum.Win) { return(StateEnum.Win); } if (this.Result != StateEnum.WVCF) { return(StateEnum.NVCF); } PieceInfo VCFCrossPoint = TryGetVCFPiece(this.CurrentBoard, this.m4LtS, this.CurrentBoard.Step + 1); if (VCFCrossPoint == null) { return(StateEnum.NVCF); } else { return(StateEnum.Win); } }