public override int Play(Board CurGame) { bool OK = false; int col = -1; while (!OK) { col = rnd.Next(CurGame.Width); OK = CurGame.IsMoveValid(col); } return(col); }
public override int Play(Board CurGame) { bool OK = false; int col = -1; while (!OK) { using (NamedPipeServerStream pipe = new NamedPipeServerStream(pipeName)) { pipe.WaitForConnection(); try { using (StreamReader sr = new StreamReader(pipe)) { string line; if (!(line = sr.ReadLine()).Contains("<EOM>")) { continue; } string[] input = line.Split('-'); lock (this) { col = Convert.ToInt32(input[0]); OK = CurGame.IsMoveValid(col); } } } catch (IOException e) { Console.WriteLine("ERROR: {0}", e.Message); } } } return(col); }