/// <summary> /// Constructor basico sin lista de unidades a las que afecta <see cref="BoostItem"/> class. /// </summary> /// <param name="listOfBoosts">Lista de mejoras a las que llama.</param> /// <param name="_timeBoost">Tiempo de duracion de las mejoras.</param> /// <param name="_manager">Gestor de las mejoras</param> public BoostItem(Boost[] listOfBoosts,float _timeBoost, BoostManager _manager){ units = null; boosts = listOfBoosts; timeBoost = _timeBoost; manager = _manager; active = true; // Invoke("RemoveBoost",timeBoost); }
/// <summary> /// Initializes a new instance of the <see cref="BoostItem"/> class. /// </summary> /// <param name="listOfBoosts">Lista de mejoras a las que llama.</param> /// <param name="_timeBoost">Tiempo de duracion de las mejoras.</param> /// <param name="_units">Unidades a las que afecta</param> /// <param name="_manager">Gestor de las mejoras.</param> public BoostItem(Boost[] listOfBoosts,float _timeBoost, List<Unit> _units, BoostManager _manager){ boosts = listOfBoosts; timeBoost = _timeBoost; units = _units; manager = _manager; active = true; for (int i=0; units != null && i < units.Count; i++){ foreach(Boost boost in boosts) boost.Apply(units[i]); } // Invoke("RemoveBoost",timeBoost); }
public void ConstructorTest() { double[][] inputs = { new double[] { 10, 42 }, new double[] { 162, 96 }, new double[] { 125, 20 }, new double[] { 96, 6 }, new double[] { 2, 73 }, new double[] { 52, 51 }, new double[] { 71, 49 }, }; int[] outputs = { -1, -1, +1, +1, -1, -1, +1 }; var classifier = new Boost<DecisionStump>(); var teacher = new AdaBoost<DecisionStump>(classifier) { Creation = (weights) => { var stump = new DecisionStump(2); stump.Learn(inputs, outputs, weights); return stump; }, Iterations = 5, Tolerance = 1e-3 }; double error = teacher.Run(inputs, outputs); Assert.AreEqual(0, error); Assert.AreEqual(5, classifier.Models.Count); Assert.AreEqual(0.16684734250395147, classifier.Models[0].Weight); Assert.AreEqual(0.22329026900109736, classifier.Models[1].Weight); Assert.AreEqual(0.28350372170582383, classifier.Models[2].Weight); Assert.AreEqual(0.16684734250395139, classifier.Models[3].Weight); Assert.AreEqual(0.15951132428517592, classifier.Models[4].Weight); int[] actual = new int[outputs.Length]; for (int i = 0; i < actual.Length; i++) actual[i] = classifier.Compute(inputs[i]); for (int i = 0; i < actual.Length; i++) Assert.AreEqual(outputs[i], actual[i]); }
/// <summary> /// Añade un boost nuevo que se debe gestionar /// </summary> /// <returns>Devuelve el boost generado.</returns> /// <param name="boosts">Lista de mejoras que va a aplicar el boost</param> /// <param name="timeBoost">Duracion del boost.</param> /// <param name="units">Unidades afectadas por el boost</param> /// <param name="type">Tipo de boost que se va a generar</param> public BoostItem AddBoost(Boost[] boosts,float timeBoost ,List<Unit> units, Skill.typesSkill type){ if (type == Skill.typesSkill.Boost){ //Debug.Log ("Nuevo boost: tiempo: " + timeBoost); BoostItem boostItem = new BoostItem(boosts,timeBoost, units, this); boostsEnabled.Add(boostItem); return boostItem; } return null; /*En caso de que sea de tipo Area Estatica boostsEnabled.Add(new BoostAreaDynamic(boosts, this, pos <---- comoo sacamos la posiciiiiiiooon )); */ }
public void AddMagnit(Boost boostPrefab) { GlobalOptions.GetMissionEmmitters().NotifyMagnitCollected(1); boostNotifierController.AddBoostNotifier(boostPrefab); playerScript.MakeMagnit(); }
public BoostArea(Boost[] listOfBoosts,float _timeBoost, BoostManager _manager, GameObject _follow) : base(listOfBoosts,_timeBoost,_manager) { follow = _follow; pos = follow.transform.position; }
private void SetBoost(Boost b) { _currentBoost = b; }
/// <summary> /// Loads the trained model. /// </summary> /// <param name="path">The location from where to load the trained model.</param> public override void Load(string path) { Model = Accord.IO.Serializer.Load <Boost <DecisionTree> >(path); }
void Update() { getTarget(); Inputs(); if (canMove && !isDead && !useNavMesh) { CameraRelativeMovement(); } Jumping(); /* * if(inputDeath && canAction && isGrounded){ * if(!isDead){ * Death(); * } * else{ * Revive(); * } * }*/ if (inputAttackL && canAction && isGrounded) { Attack(1); } if (inputAttackR && canAction && isGrounded) { AttackKick(2); } //Strafing. if (inputBlock && canAction) { isStrafing = true; animator.SetBool("Strafing", true); } else { isStrafing = false; animator.SetBool("Strafing", false); } //Navmesh. if (useNavMesh) { agent.enabled = true; navMeshSpeed = agent.velocity.magnitude; } else { agent.enabled = false; } //Navigate to click. if (Input.GetMouseButtonDown(0)) { if (useNavMesh) { RaycastHit hit; if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 100)) { agent.destination = hit.point; } } } //Slow time. if (Input.GetKeyDown(KeyCode.T)) { if (Time.timeScale != 1) { Time.timeScale = 1; } else { Time.timeScale = 0.15f; } } //Pause. if (Input.GetKeyDown(KeyCode.P)) { if (Time.timeScale != 1) { Time.timeScale = 1; } else { Time.timeScale = 0f; } } if (boostTimer >= boostMax) { switch (boost) { case Boost.SPEED: if (fastRunSpeed > runSpeed) { float f = runSpeed; runSpeed = fastRunSpeed; fastRunSpeed = f; } animator.speed = 1.5f; this.gameObject.transform.GetChild(2).GetComponent <ParticleSystem>().Play(); break; case Boost.JUMP: doublejumping = true; this.gameObject.transform.GetChild(3).GetComponent <ParticleSystem>().Play(); break; default: break; } } if (immuneTimer > 0) { immuneTimer -= Time.deltaTime; } if (boostTimer > 0) { boostTimer -= Time.deltaTime; } if (boostTimer <= 0f) { if (fastRunSpeed < runSpeed) { float f = runSpeed; runSpeed = fastRunSpeed; fastRunSpeed = f; } animator.speed = 1f; this.gameObject.transform.GetChild(2).GetComponent <ParticleSystem>().Stop(); this.gameObject.transform.GetChild(3).GetComponent <ParticleSystem>().Stop(); doublejumping = false; boost = Boost.NONE; } }
/// <summary> /// Options regarding boost. Using boost enables WebGL rendering instead of the default Javascript rendering. /// </summary> /// <param name="boost"></param> /// <returns></returns> public Highcharts SetBoost(Boost boost) { _boost = boost; return(this); }
public void TestBoostObject() { // Arrange Boost boost = new Boost("03c26917-5d66-4de9-96bc-b13066173c65"); boost.Search("Local Business Data, Global"); boost.User("test_driver_user"); // Act var response = Factual.Boost("us-sandbox", boost); // Assert AssertReceivedOkResponse(response); }
void Start() { currentState = gameObject.GetComponent<DetectState> (); boostScript = gameObject.GetComponent<Boost>(); rayDirection = -Vector3.up; direction = transform.forward; CustomJumpVec = Vector3.up; }
public void SetBoost(Boost boost) { _boost = boost; title.text = boost.GetName(); cost.text = boost.GetCost() + "pts"; }
private void UpdateCage(Cage cage, int elapsed, float happiness, List <Boost> boosts) { if (happiness < 0.5f) { return; } Boost feromones = boosts.Find(x => x.type == BoostType.feromons); Boost vitamins = boosts.Find(x => x.type == BoostType.vitamins); foreach (var animal in cage.animals) { if (animal.data.adult) { if (animal.data.pregnant) { animal.data.pregnancy += (happiness - 0.5f) * 2f / animal.stats.TicksToBorn * elapsed; } else { animal.data.sexualActivity += (happiness - 0.5f) * 2f / animal.stats.TicksToFullMate * elapsed * (feromones != null ? 2f * feromones.power : 1f); } } else { animal.data.age += (happiness - 0.5f) * 2f / animal.stats.TicksToFullMate * elapsed * (vitamins != null ? 2f * vitamins.power : 1f); } } var toBorn = new List <Animal>(); foreach (var animal in cage.animals) { if (animal.data.sexualActivity >= 0.999f) { animal.data.sexualActivity = -1; } } foreach (var animal in cage.animals) { if (animal.data.sexualActivity < -0.1f && animal.data.male) { var mate = cage.GetProperMate(); if (mate == null) { continue; } mate.status.Pregnant(); mate.data.sexualActivity = 0; animal.data.sexualActivity = 0; } else if (animal.data.pregnancy >= 0.999f) { toBorn.Add(animal); } } foreach (var animal in toBorn) { animal.status.Born(); } foreach (var b in boosts) { b.ticksRemain -= elapsed; } boosts.RemoveAll(b => b.ticksRemain <= 0); }
/* This function is called once upon game scene loading, and upon menu scene loading. * It's not efficient and is pretty bulky, but it's only called once per game load * Note: "GameObject.Find" calls are necessary since scene references can't be set before scene exists * * Game load sets all settings. * Menu load tells menu to go to unlocks screen, but only if the menu has been visited once already (game start). */ void ApplyGameModeSettings(Scene scene, LoadSceneMode mode) { //music obj is same in both scenes if (scene.name.Equals("Game")) { Debug.Log("Persistent settings are applying to the current scene..."); GameObject gameMaster = GameObject.Find("GameMaster"); GamePattern gamePattern = gameMaster.GetComponent <GamePattern>(); gamePattern.fireMode = fireMode; // firemode gamePattern.rotateBy45Degrees = rotate45; // roation gamePattern.minWaitTime = minWaitTime; // min time between block throws gamePattern.maxWaitTime = maxWaitTime; // max time between block throws //apply a palette - based on player options or gamemode if (optionOverridePalette != null && !impossibleMode) { gamePattern.currentPalette = optionOverridePalette; //use player selection instead if there is one (only exception is impossible mode!) } else { gamePattern.currentPalette = settingPalette; // the colour palette object to pull from - passes through Pattern into throw() } ScoreData scoreData = gameMaster.GetComponent <ScoreData>(); scoreData.makeScoreNegative = makeScoreNegative; scoreData.currentMode = currentModeName; GameObject cameraMain = GameObject.Find("Main Camera"); GameObject cameraKillLine = GameObject.Find("KillLine Camera"); if (flipCamera) { cameraMain.transform.eulerAngles = new Vector3(0, 0, 180); } else { cameraMain.transform.eulerAngles = new Vector3(0, 0, 0); //need this line to reset when changing between gamemodes in same session } if (flipCamera) { cameraKillLine.transform.eulerAngles = new Vector3(0, 0, 180); } else { cameraKillLine.transform.eulerAngles = new Vector3(0, 0, 0); //need this line to reset when changing between gamemodes in same session } Player player = GameObject.Find("Player").GetComponent <Player>(); player.slipperyJumpAllowed = slipperyJumpAllowed; Boost boost = GameObject.Find("Player").GetComponent <Boost>(); boost.cooldownLength = boostCooldown; Exploder exploder = GameObject.Find("Player").GetComponent <Exploder>(); exploder.immuneToCrush = immuneToCrush; AudioSource sceneMusic = GameObject.Find("Music").GetComponent <AudioSource>(); sceneMusic.mute = musicMuted; Debug.Log("Persistent settings application complete."); } //ensures menu loads into the unlocks screen else if (scene.name.Equals("MainMenu")) { MainMenu menuNav = GameObject.Find("MenuNavigator").GetComponent <MainMenu>(); if (mainMenuVisitedOnGameStartFlag && unlockMessageQueue.Count > 0) { Debug.Log("PersistentSettings is notifying MenuNavigator that a game has been played. Menu should load into unlock screen."); menuNav.userHasPlayedARound = true; //there's no need to set the unlock messages; they are collected automatically then wiped by the UnlockCanvas } if (musicMuted) { Debug.Log("Attempting to mute music on main menu"); menuNav.needToApplyPersistentMusicMute = true; } } mainMenuVisitedOnGameStartFlag = true; //flag to mark that the main menu has been visited }
public override void ReceiveBuff(Boost boost, bool isBuff, bool useAnim) { //No buffs for blocks. }
private void OnBoostTaked(Boost boost) { boost.BoostTaked -= OnBoostTaked; boost.gameObject.SetActive(false); }
public void GetBoost(Boost boost, int count) { boost.count += count; BoostsSave(); }
/// <summary> /// Initializes a new instance of the <see cref="AdaBoostM1{TModel}"/> class. /// </summary> /// /// <param name="model">The model to be learned.</param> /// public AdaBoostM1(Boost <TModel> model) { this.classifier = model; this.convergence = new RelativeConvergence(); }
void DrawInfo(ref Boost pBoost) { GUILayout.Space(15); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Label("Tag Boost:"); GUILayout.Space(5); pBoost.Tag = EditorGUILayout.TextField(pBoost.Tag, GUILayout.Width(250)); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Space(15); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Label("Qtd:"); GUILayout.Space(5); pBoost.Qtd = EditorGUILayout.IntField(pBoost.Qtd, GUILayout.Width(250)); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Space(15); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Label("Value To Buy:"); GUILayout.Space(5); pBoost.ValueToBuy = EditorGUILayout.IntField(pBoost.ValueToBuy, GUILayout.Width(250)); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Space(15); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Label("Time in Seconds:"); GUILayout.Space(5); pBoost.TimeLimit = EditorGUILayout.FloatField(pBoost.TimeLimit, GUILayout.Width(250)); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Space(15); }
/// <summary> /// Initializes a new instance of the <see cref="AdaBoostM1{TModel}"/> class. /// </summary> /// /// <param name="model">The model to be learned.</param> /// <param name="creationFunction">The model fitting function.</param> /// public AdaBoostM1(Boost <TModel> model, ModelConstructor <TModel> creationFunction) { this.classifier = model; this.Creation = creationFunction; this.convergence = new RelativeConvergence(); }
public GameObject CreateBoost(Boost boost) { return(CreateBoost(boost, null)); }
// Use this for initialization void Awake() { text = GetComponent <Text>(); boost = GameObject.Find("Player").GetComponent <Boost>(); }
static void Main(string[] args) { var data = HealthInfo.DeserialiseData(HEART_DATASET); var testData = new List <HealthInfo>(); while (testData.Count < 25) { int index = _randEngine.Next(data.Count - 1); testData.Add(data[index]); data.RemoveAt(index); } var agent = new Boost <HealthInfo>(); agent.Add(new Agent <HealthInfo>(100)); int Nbsucces = 0; int bestNbSuccess = 0; int run = 0; int nbRunSinceLastSuccess = 0; int nbAgent = 1; while ((double)Nbsucces / data.Count < 0.85) { Nbsucces = 0; for (int i = 0; i < 1; i++) { agent.Fit(data); } foreach (var item in data) { if ((agent.MakePrediction(item) > 0) == (item.Target > 0)) { Nbsucces++; } } if (Nbsucces > bestNbSuccess) { Console.WriteLine($"Last best result at : {DateTime.Now.ToString()}"); Console.WriteLine($"The agent made {Nbsucces} prediction succefully on a total of {data.Count} at run {run}."); Console.WriteLine($"This is accurate at {(double)Nbsucces / data.Count}"); Console.WriteLine($"The Agent spec"); Console.WriteLine(agent.ToString()); Console.WriteLine("Result"); Console.WriteLine($"{data[0].Header()} Prediction"); int lineToBePrintedCount = 303; for (int i = 0; i < data.Count; i++) { if (lineToBePrintedCount > 0 && (_randEngine.Next() % 303 == 0 || data.Count - i < lineToBePrintedCount)) { Console.WriteLine($"{data[i].ToString()} {agent.MakePrediction(data[i])}"); lineToBePrintedCount--; } } Console.WriteLine($"This is accurate at {(double)Nbsucces / data.Count}"); bestNbSuccess = Nbsucces; nbRunSinceLastSuccess = -1; } nbRunSinceLastSuccess++; if (nbRunSinceLastSuccess >= 500) { if (_randEngine.Next() % 2 == 0) { agent = new Boost <HealthInfo>(); agent.Add(new Agent <HealthInfo>(100)); Console.WriteLine($"New Agent at run {run}"); } nbRunSinceLastSuccess = 0; nbAgent++; } run++; } Console.WriteLine($"The tranning is complete after {run} run and {nbAgent} agents"); int dataEvaluation = 0; foreach (var d in testData) { if ((agent.MakePrediction(d) > 0) == (d.Target > 0)) { dataEvaluation++; } } Console.WriteLine($"Final score is {(double)dataEvaluation/testData.Count} or {dataEvaluation} / {testData.Count}"); Console.ReadLine(); }
private static VSTestResult GenerateResult(VSTestCase test, Boost.Results.TestResult result, DateTimeOffset start, DateTimeOffset end) { Code.Require(test, "test"); Code.Require(result, "result"); // Convert the Boost.Test.Result data structure into an equivalent Visual Studio model VSTestResult vsResult = result.AsVSTestResult(test); vsResult.StartTime = start; vsResult.EndTime = end; return vsResult; }
public BoostArea(Boost[] listOfBoosts,float _timeBoost, BoostManager _manager, Vector3 _pos) : base(listOfBoosts,_timeBoost,_manager) { pos = _pos; }
public void TestBoost() { using (Boost tree = new Boost()) { MCvBoostParams param = MCvBoostParams.GetDefaultParameter(); } }
public void ConstructorTest2() { double[][] inputs = LeastSquaresLearningTest.yinyang.GetColumns(0, 1).ToArray(); int[] outputs = LeastSquaresLearningTest.yinyang.GetColumn(2).ToInt32(); var outputs2 = outputs.Apply(x => x > 0 ? 1.0 : 0.0); var classifier = new Boost<Weak<LogisticRegression>>(); var teacher = new AdaBoost<Weak<LogisticRegression>>(classifier) { Creation = (weights) => { LogisticRegression reg = new LogisticRegression(2, intercept: 1); IterativeReweightedLeastSquares irls = new IterativeReweightedLeastSquares(reg) { ComputeStandardErrors = false }; for (int i = 0; i < 50; i++) irls.Run(inputs, outputs2, weights); return new Weak<LogisticRegression>(reg, (s, x) => Math.Sign(s.Compute(x) - 0.5)); }, Iterations = 50, Tolerance = 1e-5, }; double error = teacher.Run(inputs, outputs); Assert.AreEqual(0.11, error); Assert.AreEqual(2, classifier.Models.Count); Assert.AreEqual(0.63576818449825168, classifier.Models[0].Weight); Assert.AreEqual(0.36423181550174832, classifier.Models[1].Weight); int[] actual = new int[outputs.Length]; for (int i = 0; i < actual.Length; i++) actual[i] = classifier.Compute(inputs[i]); //for (int i = 0; i < actual.Length; i++) // Assert.AreEqual(outputs[i], actual[i]); }
public void AddBoost(Boost boost) { _activeBoosts.Add(boost); CalculateCurrentBoostFactor(); Observable.Timer(TimeSpan.FromSeconds(boost.Duration)).Subscribe(_ => RemoveBoost(boost)); }
public void Visit(Boost.Test.TestCase testCase) { Utility.Code.Require(testCase, "testCase"); // Convert from Boost.Test.TestCase to a Visual Studio TestCase object VSTestCase test = GenerateTestCase(testCase); if (test != null) { Logger.Info("Found test: {0}", testCase.FullyQualifiedName); ++this.Count; // Register test case this.Sink.SendTestCase(test); } }
private void RemoveBoost(Boost boost) { _activeBoosts.Remove(boost); CalculateCurrentBoostFactor(); }
/// <summary> /// Generates a default TestResult for a timeout exception. /// </summary> /// <param name="test">The test which failed due to a timeout.</param> /// <param name="ex">The exception related to this timeout.</param> /// <returns>A timed-out, failed TestResult related to the provided test.</returns> private static VSTestResult GenerateTimeoutResult(VSTestCase test, Boost.Runner.TimeoutException ex) { VSTestResult result = new VSTestResult(test); result.ComputerName = Environment.MachineName; result.Outcome = TestOutcome.Failed; result.Duration = TimeSpan.FromMilliseconds(ex.Timeout); result.ErrorMessage = "Timeout exceeded. Test ran for more than " + ex.Timeout + " ms."; if (!string.IsNullOrEmpty(test.CodeFilePath)) { result.ErrorStackTrace = new SourceFileInfo(test.CodeFilePath, test.LineNumber).ToString(); } return result; }
public Racer(string firstname, string lastname, string cbrand, double cweight, double chp, Boost cboost) { this.FirstName = firstname; this.LastName = lastname; this.CBrand = cbrand; this.CWeight = cweight; this.CHP = chp; this.CBoost = cboost; }