public Trainer(ITrainable component, CostFunction cf, AdaptationStrategy strategy) { _component = component; _costFunction = cf; _strategy = strategy; _costAccumulator = 0; }
protected virtual void Start() { academy = FindObjectOfType <Academy>(); try { trainable = (ITrainable)agent; } catch (System.Exception) { Debug.LogError("The agent (" + agent.name + ") does not implement ITrainable!"); } }
private static void Evaluate(ITrainable classifier) { classifier.Train(trainingSet); var serializer = new JsonSerializer(classifier); serializer.SerializeTo(classifier + ".json"); var benchmark = new Benchmark(classifier, testSet); Console.WriteLine(benchmark.Report()); }
// Commands public void TrainCommand(string identifier) { if (ResourceManager.instance.resources.IsSufficient(Utils.unitCostTable[identifier])) { AudioController.instance.PlaySingle("training"); ResourceManager.instance.resources.Reduce(Utils.unitCostTable[identifier]); ITrainable trainer = Selection.instance.selectedEntities.Values.First().GetComponent <ITrainable>(); trainer.Train(identifier); } else { AudioController.instance.PlaySingle("insufficient funds"); } // if(identifier == "Villager") // { // MainBuilding building = SelectionController00.instance.selectedEntities.Values.First().GetComponent<MainBuilding>(); // building.AddTrainingQueueu(); // } }
public IGameAction CreateTrainAction(ITrainableDef trainableDef, ITrainingEntity trainingEntity) { IGameAction gameAction = new GameAction(trainableDef.IconData); gameAction.Clicked += () => { UnitFactory unitFactory = new UnitFactory(trainingEntity.Faction, game); ITrainable spawnable = unitFactory.CreateNewTrainable(trainableDef); if (!trainingEntity.Faction.CanPurchase(spawnable.Def)) { return; } trainingEntity.Faction.Purchase(spawnable.Def); trainingEntity.TrainingQueue.Enqueue(spawnable); }; return(gameAction); }
public Benchmark(ITrainable classifier, List <WordPartOfSpeech> testSet) { this.classifier = classifier; this.testSet = testSet; }
public JsonSerializer(ITrainable classifier) { this.classifier = classifier; }