/// <Summary> /// Menu->Commands->Save & Submit /// </Summary> /// <param name="sender">The source of the event.</param> /// <param name="e">A <see cref="EventArgs"/> that contains the event data.</param> private void SaveAndSubmitTurnToolStripMenuItem_Click(object sender, EventArgs e) { clientState.Save(); OrderWriter orderWriter = new OrderWriter(clientState); orderWriter.WriteOrders(); this.Close(); }
public static void Main(string[] args) { string raceName; int turnNumber = -1; // read paramaters for race and turn to play CommandArguments commandArguments; try { commandArguments = new CommandArguments(args); Console.WriteLine("Nova AI"); if (commandArguments.Count < 3) { Console.WriteLine("Usage: Nova --ai -r <race_name> -t <turn_number> -i <intel_file>"); return; } raceName = commandArguments[CommandArguments.Option.RaceName]; turnNumber = int.Parse(commandArguments[CommandArguments.Option.Turn], System.Globalization.CultureInfo.InvariantCulture); } catch { Console.WriteLine("Usage: Nova --ai -r <race_name> -t <turn_number> -i <intel_file>"); return; } // read in race data Console.WriteLine("Playing turn {0} for race \"{1}\".", turnNumber, raceName); try { // TODO (priority 6) - bypass password entry for AI. // Note: passwords have currently been disabled completely, awaiting a new more effective implementation - Dan 02 Mar 10 // ClientState.Initialize(commandArguments.ToArray()); try { intelLock = File.OpenWrite(raceName + "." + "lock"); } catch (System.IO.IOException) { // A copy of the AI seems to be already running, so quit. // Console.WriteLine("Unable to access turn {0} for {1}.", turnNumber, raceName); // Report.FatalError("Unable to access turn " + turnNumber + " for " + raceName + "."); } AI.Initialize(commandArguments); } catch { Console.WriteLine("Nova_AI encountered an error reading its intel."); return; } // play turn AI.DoMove(); // save turn) try { OrderWriter orderWriter = new OrderWriter(AI.ClientState); orderWriter.WriteOrders(); } catch { Console.WriteLine("Nova_AI encountered an error writing its orders."); } intelLock.Close(); intelLock.Dispose(); return; }