public static string GetBestMove(ChessLibrary.Game g) { using (var client = Utils.NewAPIClient()) { //ChessAI ai = new ChessAI(client); //string game_xml = g.XmlSerialize(new System.Xml.XmlDocument()).InnerText; //string type = g.GameTurn.GetType().ToString(); string gameXml = g.XmlSerialize(new System.Xml.XmlDocument()).OuterXml; XmlDocument doc = new XmlDocument(); doc.LoadXml(gameXml); XmlNode gameXmlNode = doc.DocumentElement; ChessLibrary.Game g1 = new ChessLibrary.Game(); g1.XmlDeserialize(gameXmlNode); ChessLibrary.Player p = g1.BlackPlayer; if (g1.BlackTurn()) { p = g1.WhitePlayer; } ChessLibrary.Move m = p.GetBestMove(); string best_str = m.ToString(); string m_str = ChessAIExtensions.PostByGamexmlAndTimelimitinsecs(new ChessAI(client), new Models.StringAux(gameXml), 5); return(m_str); } }
protected async override void OnNavigatedTo(NavigationEventArgs e) // { this.InitializeComponent(); this.currGame = ChessGameManager.initializeGame(); Session sess = e.Parameter as Session; this.username = sess.PlayerName; DisplayInformation.AutoRotationPreferences = DisplayOrientations.Portrait; Timer = new DispatcherTimer(); Timer.Interval = TimeSpan.FromMilliseconds(10); Timer.Tick += DispatcherTimer_Tick; TimeSpaner = TimeSpan.FromMinutes(0); tb_Timer.Text = showTime(); Timer.Start(); }
public static ChessLibrary.Game initializeGame() { ChessLibrary.Game g = new ChessLibrary.Game(); g.Reset(); return(g); }