static void Main(string[] args) { Board b = new Board(); Player p = Player.White; Console.WriteLine(b); while(true) { Console.WriteLine("White Move: o "); Move m = new Move(); Console.WriteLine("Введите координату x:"); m.x=Int32.Parse(Console.ReadLine()); Console.WriteLine("Введите координату y:"); m.y = Int32.Parse(Console.ReadLine()); b.PerformMove(p, m); Console.WriteLine("\n"); Console.WriteLine(b); if(p==Player.White)p=Player.Black; else p=Player.White; Node max = AB.GetOptimalMove(p, b, 5); b.PerformMove(p, max.m); if (p == Player.White) p = Player.Black; else p = Player.White; Console.WriteLine("\n"); Console.WriteLine(b); } /* Console.WriteLine(b); Console.WriteLine(b.Price(p)); p = Player.White; Node max=AB.GetOptimalMove(p, b, 5); Console.WriteLine("x="+max.m.x+" y="+max.m.y+" Price="+max.max_price);*/ }
public static Node Go_Round(Player p, Board b, int max_depth,Player p1,int depth) { // if (p == p1) Console.WriteLine("yes where max=" + max_depth + "\n"); List<Node> prices=new List<Node>(); Node max_price=new Node(); List <Move> moves = b.GetMoves(p); int max = 0, min = 100 ; foreach (Move move in moves) { if (max_depth > 0) { Node node=new Node(); Board new_board = new Board(b); new_board.PerformMove(p, move); if (p == Player.Black) { node = Go_Round(Player.White, new_board, (max_depth - 1), p1, depth); } else { node = Go_Round(Player.Black, new_board, (max_depth - 1), p1, depth); } prices.Add(node); if (p == p1) { //Console.WriteLine("yes where max=" + max_depth + "\n"); // foreach(Node n in prices) // { if (node.max_price > max) { max_price.max_price = node.max_price; max_price.m = move; max = node.max_price; // Console.WriteLine("max=" + max); } } // } else { //Console.WriteLine("no where max=" + max_depth + "\n"); //foreach (Node n in prices) // { if (node.max_price < min) { max_price.max_price = node.max_price; max_price.m = move; min = node.max_price; } // } } } else if (max_depth==0) { // if (p == p1) { Console.WriteLine("p=p1"); } // else Console.WriteLine("p!!!!!!!!!!p1"); max_price.max_price=b.Price(p); max_price.m = move; //Console.WriteLine(b.Price(p)); } } /* if (max_depth == depth) { Console.WriteLine("MLength=" + moves.Count); foreach (Node pr in prices) { Console.WriteLine("Price=" + pr.max_price + " where x="+pr.m.x+" y="+pr.m.y+"\n"); } }*/ return max_price; }