/// <summary> /// Serialize the Game object as XML String /// </summary> /// <returns>XML containing the Game object state XML</returns> public XmlNode XmlSerialize(XmlDocument xmlDoc) { XmlElement xmlNode = xmlDoc.CreateElement("Side"); // Serialize and append to the side object xmlNode.InnerXml = XMLHelper.XmlSerialize(typeof(SideType), m_side); // Return this as String return(xmlNode); }
/// <summary> /// Serialize the Game object as XML String /// </summary> /// <returns>XML containing the Game object state XML</returns> public XmlNode XmlSerialize(XmlDocument xmlDoc) { XmlElement xmlGame = xmlDoc.CreateElement("Game"); // Append game state attributes xmlGame.AppendChild(XMLHelper.CreateNodeWithValue(xmlDoc, "DoNullMovePruning", DoNullMovePruning.ToString())); xmlGame.AppendChild(XMLHelper.CreateNodeWithValue(xmlDoc, "DoPrincipleVariation", DoPrincipleVariation.ToString())); xmlGame.AppendChild(XMLHelper.CreateNodeWithValue(xmlDoc, "DoQuiescentSearch", DoQuiescentSearch.ToString())); // Append the Game turn info xmlGame.AppendChild(XMLHelper.CreateNodeWithValue(xmlDoc, "GameTurn", GameTurn.ToString())); // Append the Board State xmlGame.AppendChild(Board.XmlSerialize(xmlDoc)); // Append the Player Info xmlGame.AppendChild(XMLHelper.CreateNodeWithXmlValue(xmlDoc, "WhitePlayer", XMLHelper.XmlSerialize(typeof(Player), m_WhitePlayer))); xmlGame.AppendChild(XMLHelper.CreateNodeWithXmlValue(xmlDoc, "BlackPlayer", XMLHelper.XmlSerialize(typeof(Player), m_BlackPlayer))); object[] moves = m_MovesHistory.ToArray(); // Store all the moves from the move history string xml = ""; for (int i = moves.Length - 1; i >= 0; i--) { Move move = (Move)moves[i]; xml += XMLHelper.XmlSerialize(typeof(Move), move); } xmlGame.AppendChild(XMLHelper.CreateNodeWithXmlValue(xmlDoc, "MovesHistory", xml)); // Create the Checksome to avoid user temporing of the file string checksum = GetChecksum(xmlGame.InnerXml); (xmlGame as XmlElement).SetAttribute("Checksum", checksum); (xmlGame as XmlElement).SetAttribute("Version", "1.2"); // Return this as String return(xmlGame); }
/// <summary> /// Serialize the Game object as XML String /// </summary> /// <returns>XML containing the Game object state XML</returns> public XmlNode XmlSerialize(XmlDocument xmlDoc) { XmlElement xmlNode = xmlDoc.CreateElement("Cells"); string xml = ""; // Serialize and append every cell of this board for (int row = 1; row <= 8; row++) { for (int col = 1; col <= 8; col++) { Cell cell = this[row, col]; xml += XMLHelper.XmlSerialize(typeof(Cell), cell); } } xmlNode.InnerXml = xml; // Return this as String return(xmlNode); }