示例#1
0
 public Trainer(ITrainable component, CostFunction cf, AdaptationStrategy strategy)
 {
     _component       = component;
     _costFunction    = cf;
     _strategy        = strategy;
     _costAccumulator = 0;
 }
示例#2
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!");
     }
 }
示例#3
0
        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());
        }
示例#4
0
    // 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();
//		}
    }
示例#5
0
        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);
        }
示例#6
0
 public Benchmark(ITrainable classifier, List <WordPartOfSpeech> testSet)
 {
     this.classifier = classifier;
     this.testSet    = testSet;
 }
 public JsonSerializer(ITrainable classifier)
 {
     this.classifier = classifier;
 }