Beispiel #1
0
 static void Main(string[] args)
 {
     HeadlessArena ha = new HeadlessArena();
     if (!parseArgs(args, ha))
         return;
     ha.Run();
 }
Beispiel #2
0
        static void Main(string[] args)
        {
            HeadlessArena ha = new HeadlessArena();

            if (!parseArgs(args, ha))
            {
                return;
            }
            ha.Run();
        }
Beispiel #3
0
        /// <summary>
        /// Parses out the commandline arguments into the arena
        /// </summary>
        /// <param name="args">The list of commandline arguments</param>
        /// <param name="ha">The instance of the headless arena</param>
        /// <returns>true if the parsing was successful, false otherwise</returns>
        static bool parseArgs(string[] args, HeadlessArena ha)
        {
            if (args.Length == 0)
            {
                showHelp();
                return(false);
            }

            for (int i = 0; i < args.Length; i++)
            {
                // parse out chronon's per second
                if (args[i] == "-cpu")
                {
                    int?cs = loadNextInt("-cpu", args, i);
                    if (cs.HasValue)
                    {
                        ha.ChrononsPerUpdate = cs.Value;
                        i++;
                    }
                    else
                    {
                        return(false);
                    }
                }
                // parse out updates per second
                else if (args[i] == "-cl")
                {
                    int?us = loadNextInt("-cl", args, i);
                    if (us.HasValue)
                    {
                        ha.ChrononLimit = us.Value;
                        i++;
                    }
                    else
                    {
                        return(false);
                    }
                }
                // check for interactive mode
                else if (args[i] == "-i")
                {
                    ha.InteractiveMode = true;
                }
                // show help when requested
                else if (args[i].ToLower() == "-h")
                {
                    showHelp();
                    return(false);
                }
                // otherwise, assume it's a filename and try to load it
                else
                {
                    try
                    {
                        ha.AddRobot(RobotFile.OpenFile(args[i]));
                    }
                    catch (Exception e)
                    {
                        showError(String.Format("Unable to load robot file: {0}\n {1}",
                                                args[i], e.Message));
                    }
                }
            }
            return(true);
        }
Beispiel #4
0
        /// <summary>
        /// Parses out the commandline arguments into the arena
        /// </summary>
        /// <param name="args">The list of commandline arguments</param>
        /// <param name="ha">The instance of the headless arena</param>
        /// <returns>true if the parsing was successful, false otherwise</returns>
        static bool parseArgs(string[] args, HeadlessArena ha)
        {
            if (args.Length == 0)
            {
                showHelp();
                return false;
            }

            for (int i = 0; i < args.Length; i++)
            {
                // parse out chronon's per second
                if (args[i] == "-cpu")
                {
                    int? cs = loadNextInt("-cpu",args, i);
                    if (cs.HasValue)
                    {
                        ha.ChrononsPerUpdate = cs.Value;
                        i++;
                    }
                    else
                        return false;
                }
                // parse out updates per second
                else if (args[i] == "-cl")
                {
                    int? us = loadNextInt("-cl", args, i);
                    if (us.HasValue)
                    {
                        ha.ChrononLimit = us.Value;
                        i++;
                    }
                    else
                        return false;
                }
                // check for interactive mode
                else if (args[i] == "-i")
                {
                    ha.InteractiveMode = true;
                }
                // show help when requested
                else if (args[i].ToLower() == "-h")
                {
                    showHelp();
                    return false;
                }
                // otherwise, assume it's a filename and try to load it
                else
                {
                    try
                    {
                        ha.AddRobot(RobotFile.OpenFile(args[i]));
                    }
                    catch (Exception e)
                    {
                        showError(String.Format("Unable to load robot file: {0}\n {1}",
                                                args[i], e.Message));
                    }
                }

            }
            return true;
        }