AIXI.MyTttEnvironment.check_win C# (CSharp) Method

check_win() public method

public check_win ( ) : bool
return bool
        public bool check_win()
        {
            //we do not need to recognize who won: it is player who played last
            for (int r = 0; r < 3; r++) {
                if (this.Board[r,0]!=this.OEmpty &&
                    this.Board[r,0]==this.Board[r,1] &&
                    this.Board[r,1]==this.Board[r,2]
                    ){
                        return true;
                }
            }

            for (int c = 0; c < 3; c++) {
                if (this.Board[0, c] != this.OEmpty &&
                    this.Board[0,c]==this.Board[1,c] &&
                    this.Board[1,c]==this.Board[2,c]
                    ){
                        return true;
                }
            }

            if (this.Board[0,0]!=this.OEmpty &&
                this.Board[0,0]==this.Board[1,1] &&
                this.Board[1,1]==this.Board[2,2]
                ){
                return true;
            }

            if (this.Board[0, 2] != this.OEmpty &&
                this.Board[0, 2] == this.Board[1, 1] &&
                this.Board[1, 1] == this.Board[2, 0]
                )
            {
                return true;
            }
            return false;
        }