/// <summary> /// The entry point for a server /// </summary> /// <param name="holder"></param> /// <param name="proposal"></param> public void CreateSelfTestServer(NetworkServerData holder, SettingsProposal proposal) { RunServer(holder); ReceiveConfiguration(holder); proposal.Push(holder.Settings, true); InstantiateWorld(holder); }
/// <summary> /// Creates a controller factory by the name of selected mode. /// </summary> /// <param name="modeName">BotDemo or Tutorial</param> /// <returns></returns> public ControllerFactory CreateControllerFactory(string modeName, SettingsProposal proposal) { ControllerFactory factory = null; if (modeName == "BotDemo") factory = new BotDemoControllerFactory(); else if (modeName == "Tutorial") factory = new TutorialControllerFactory(); else if (modeName == "Tournament") { var port = 14000; if (proposal.Port.HasValue) port = proposal.Port.Value; factory = new TournamentControllerFactory(port); } else throw new Exception("Mode '" + modeName + "' is unknown"); return factory; }
static void Main(string[] args) { int port = 14000; while (true) { try { Console.Write("Attempting to connect "); var client = new CvarcClient<object, MoveAndGripCommand>(); var loadingData = new LoadingData { AssemblyName = "Demo", Level = "Movement" }; var settings = new SettingsProposal { TimeLimit=3, Controllers = new List<ControllerSettings> { new ControllerSettings { ControllerId=TwoPlayersId.Left, Name="This", Type= ControllerType.Client } } }; var state=KnownWorldStates.EmptyWithOneRobot(false); var rules=new MoveAndGripRules(); client.Configurate(port, new ConfigurationProposal { LoadingData=loadingData, SettingsProposal=settings}, state); client.Act(rules.Move(30)); client.Act(rules.Rotate(Angle.Pi)); client.Exit(); Console.WriteLine("Success"); } catch (Exception e) { Console.WriteLine(e.Message); } Thread.Sleep(1000); } }
public ConfigurationProposal() { LoadingData = new LoadingData(); SettingsProposal = new SettingsProposal(); }
/// <summary> /// Runs the test as a Unit test. /// </summary> /// <param name="assemblyName"></param> /// <param name="level"></param> /// <param name="testName"></param> /// <param name="asserter"></param> public void RunSelfTestInVSContext(string assemblyName, string level, string testName, IAsserter asserter) { var holder = new NetworkServerData(); holder.Port = DefaultPort; holder.LoadingData = new LoadingData { AssemblyName = assemblyName, Level = level }; var test = GetTest(holder.LoadingData, testName); var thread = new Thread(() => { var proposal = new SettingsProposal { SpeedUp = true }; CreateSelfTestServer(holder, proposal); holder.World.RunActively(1); holder.Close(); }) { IsBackground = true }; thread.Start(); try { SelfTestClientThread(test, asserter, holder); } catch (Exception e) { throw e; } finally { holder.Close(); } }
protected override SettingsProposal MutateCopy(SettingsProposal settings) { settings.SpeedUp = _speedUp; return settings; }
protected override SettingsProposal MutateCopy(SettingsProposal settings) { settings.LogFile = _logFile; return settings; }
protected abstract SettingsProposal MutateCopy(SettingsProposal settings);
protected override SettingsProposal MutateCopy(SettingsProposal settings) { settings.EnableLog = _enableLog; return settings; }
protected override SettingsProposal MutateCopy(SettingsProposal settings) { settings.TimeLimit = _timeLimit; return settings; }
protected override SettingsProposal MutateCopy(SettingsProposal settings) { settings.Name = _name; return settings; }
protected override SettingsProposal MutateCopy(SettingsProposal settings) { settings.Controllers = _controllers; return settings; }
protected override SettingsProposal MutateCopy(SettingsProposal settings) { settings.SolutionsFolder = _solutionsFolder; return settings; }
protected override SettingsProposal MutateCopy(SettingsProposal settings) { settings.Port = _port; return settings; }
public SettingsProposal Mutate(SettingsProposal settings) { return MutateCopy(SettingsProposal.DeepCopy(settings)); }
/// <summary> /// Creates the world for non-networking case: BotDemo or Tutorial modes. /// </summary> /// <param name="loadingData"></param> /// <param name="proposal"></param> /// <param name="factory"></param> /// <returns></returns> public IWorld CreateSimpleMode(LoadingData loadingData, SettingsProposal proposal, ControllerFactory factory) { var configuration = new Configuration(); configuration.LoadingData = loadingData; var competitions = GetCompetitions(configuration.LoadingData); configuration.Settings = competitions.Logic.CreateDefaultSettings(); proposal.Push(configuration.Settings, true); var stateName = configuration.Settings.WorldState; if (stateName == null) { if (competitions.Logic.PredefinedWorldStates.Count == 0) throw new Exception("The count of predefined stated in the " + competitions.Logic.GetType() + " is zero"); stateName = competitions.Logic.PredefinedWorldStates[0]; } var state = competitions.Logic.CreateWorldState(stateName); return CreateWorld(configuration, factory, state); }
protected override SettingsProposal MutateCopy(SettingsProposal settings) { settings.OperationalTimeLimit = _operationalTimeLimit; return settings; }