示例#1
0
        /// <summary>
        /// Gets the latest AI entry.
        /// </summary>
        /// <returns>AI Data.</returns>
        public static CoastalRaidersFuedalResourceManager[] GetLatestAiEntry()
        {
            CoastalRaidersFuedalResourceManager latestAiP1 = null;
            CoastalRaidersFuedalResourceManager latestAiP2 = null;

            string cmdString = @"
				SELECT  AD1.Name as player1, AD2.Name as player2,  ANNF.* 
				FROM aoenn.ai_neural_network_feed ANNF
					INNER JOIN ai_definition AD1
						ON ANNF.p1Index = AD1.AIIndex
					INNER JOIN ai_definition AD2
						ON ANNF.p2Index = AD2.AIIndex
				ORDER BY GameId DESC
				LIMIT 1;
				"                ;

            // Delegates allow me to take laziness to a whole new level.
            ReadSql((MySqlDataReader msdr) =>
            {
                // Gets all that good data.
                while (msdr.Read())
                {
                    latestAiP1 = new CoastalRaidersFuedalResourceManager(
                        Convert.ToString(msdr["player1"]),
                        Convert.ToInt32(msdr["GameId"]),

                        Convert.ToDouble(msdr["p1Wood"]),
                        Convert.ToDouble(msdr["p1Food"]),
                        Convert.ToDouble(msdr["p1Stone"]),
                        Convert.ToDouble(msdr["p1Gold"]),
                        Convert.ToDouble(msdr["p1Builders"]),

                        Convert.ToInt32(msdr["p1WoodHighest"]),
                        Convert.ToInt32(msdr["p1FoodHighest"]),
                        Convert.ToInt32(msdr["p1GoldHighest"]),
                        Convert.ToInt32(msdr["p1StoneHighest"]));
                    latestAiP2 = new CoastalRaidersFuedalResourceManager(
                        Convert.ToString(msdr["player2"]),
                        Convert.ToInt32(msdr["GameId"]),

                        Convert.ToDouble(msdr["p2Wood"]),
                        Convert.ToDouble(msdr["p2Food"]),
                        Convert.ToDouble(msdr["p2Stone"]),
                        Convert.ToDouble(msdr["p2Gold"]),
                        Convert.ToDouble(msdr["p2Builders"]),

                        Convert.ToInt32(msdr["p2WoodHighest"]),
                        Convert.ToInt32(msdr["p2FoodHighest"]),
                        Convert.ToInt32(msdr["p2GoldHighest"]),
                        Convert.ToInt32(msdr["p2StoneHighest"]));
                }
            }, cmdString);

            return(new CoastalRaidersFuedalResourceManager[2] {
                latestAiP1, latestAiP2
            });
        }
示例#2
0
        /// <summary>
        /// Gets the AI data set.
        /// </summary>
        /// <returns>AI Data set.</returns>
        public static List <CoastalRaidersFuedalResourceManager> GetAiDataSet()
        {
            var dataRows = new List <CoastalRaidersFuedalResourceManager>();

            string cmdString = @"
				SELECT  AD1.Name as player1, AD2.Name as player2,  ANNF.* 
				FROM aoenn.ai_neural_network_feed ANNF
					INNER JOIN ai_definition AD1 ON ANNF.p1Index = AD1.AIIndex
					INNER JOIN ai_definition AD2 ON ANNF.p2Index = AD2.AIIndex;"                    ;

            // Delegates allow me to take laziness to a whole new level.
            ReadSql((MySqlDataReader msdr) =>
            {
                // Gets all that good data.
                while (msdr.Read())
                {
                    var player1 = new CoastalRaidersFuedalResourceManager(
                        Convert.ToString(msdr["player1"]),
                        Convert.ToInt32(msdr["GameId"]),

                        Convert.ToDouble(msdr["p1Wood"]),
                        Convert.ToDouble(msdr["p1Food"]),
                        Convert.ToDouble(msdr["p1Stone"]),
                        Convert.ToDouble(msdr["p1Gold"]),
                        Convert.ToDouble(msdr["p1Builders"]),

                        Convert.ToInt32(msdr["p1WoodHighest"]),
                        Convert.ToInt32(msdr["p1FoodHighest"]),
                        Convert.ToInt32(msdr["p1GoldHighest"]),
                        Convert.ToInt32(msdr["p1StoneHighest"]));

                    var player2 = new CoastalRaidersFuedalResourceManager(
                        Convert.ToString(msdr["player2"]),
                        Convert.ToInt32(msdr["GameId"]),

                        Convert.ToDouble(msdr["p2Wood"]),
                        Convert.ToDouble(msdr["p2Food"]),
                        Convert.ToDouble(msdr["p2Stone"]),
                        Convert.ToDouble(msdr["p2Gold"]),
                        Convert.ToDouble(msdr["p2Builders"]),

                        Convert.ToInt32(msdr["p2WoodHighest"]),
                        Convert.ToInt32(msdr["p2FoodHighest"]),
                        Convert.ToInt32(msdr["p2GoldHighest"]),
                        Convert.ToInt32(msdr["p2StoneHighest"]));

                    dataRows.Add(player1);
                    dataRows.Add(player2);
                }
            }, cmdString);

            return(dataRows);
        }