private void BEngine1_Click(object sender, EventArgs e) { HansAI bob = new HansAI(b, 5000); b = bob.FinalBoard; Refresh(); }
private void Screen_MouseClick(object sender, MouseEventArgs e) { //b.ParseMove(e.Location); //Refresh(); int max = 0; while (true) { b = new Board(); b.DoMove(new Position(8, 8)); Refresh(); HansAI.lost = false; int i = 0; while (!HansAI.lost) { Application.DoEvents(); HansAI bob = new HansAI(b, 5000); b = bob.FinalBoard; Refresh(); if (b == null) { break; } bob = new HansAI(b, 5000); b = bob.FinalBoard; Refresh(); } max = Math.Max(i, max); } }
private static void Main(string[] args) { Console.WriteLine("Hello World"); string path = args[0]; bool starts = args[1] == "B"; int time = int.Parse(args[2]); bool debug = args[3] == "1"; //string path = Console.ReadLine(); //bool starts = Console.ReadLine() == "B"; if (debug) { Console.WriteLine("[HansAI]: Color: " + (starts ? "Black" : "White") + ", TextPath: " + path); } Board b = new Board(); if (starts) { b.DoMove(new Position(6, 6)); File.WriteAllText(path, b.GetMoveString()); if (debug) { Console.WriteLine("[HansAI]: Starting: TextFileChangedTo " + b.GetMoveString()); } } string lastGame = b.GetMoveString(); while (true) { while (CheckFile()) { Thread.Sleep(50); } b = new Board(path); if (debug) { Console.WriteLine("[HansAI]: Reading " + lastGame); } //b.WriteData(); HansAI bob = new HansAI(b, time); if (bob.FinalBoard == null) { if (b.GetAllMoves().Count == 0) { break; } bob.FinalBoard = b.GetAllMoves()[0]; } b = bob.FinalBoard; //b.WriteData(); lastGame = b.GetMoveString(); while (!WriteFile()) { Thread.Sleep(10); } if (debug) { Console.WriteLine("[HansAI]: TextFileChangedTo " + lastGame); } } bool CheckFile() { try { return(File.ReadAllText(path) == lastGame); } catch (Exception e) { //Console.WriteLine("[HansAI]: Catched: " + e.ToString()); return(false); } } bool WriteFile() { try { File.WriteAllText(path, lastGame); return(true); } catch (Exception e) { //Console.WriteLine("[HansAI]: Catched: " + e.ToString()); return(false); } } }