// Update is called once per frame void Update() { if (null != Human) { Human.Update(); } }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { // For Mobile devices, this logic will close the Game when the Back button is pressed // Exit() is obsolete on iOS if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) { Exit(); } //////////////////////////// // tiles foreach (Tile tile in tiles) { tile.Update(); } // players p1.Update(); p2.Update(); //if(rnd.Next(50) == 0) { // int x = rnd.Next(NUM_TILES); // int y = rnd.Next(NUM_TILES); // //while(tiles[x, y].isOccupied()) { // // x = rnd.Next(NUM_TILES); // // y = rnd.Next(NUM_TILES); // //} // tiles[x, y].PlaceSprite(new Wall(tiles[x, y].pos, this)); //} //////////////////////////// base.Update(gameTime); }
public void DestroyWolfAndCreateHuman(Wolf wolf) { arena.wolves.Remove(wolf); wolf.RemoveFromArea(); this.wolf = null; human = new Human(this, arena.entityArea, true); human.SetPosition(wolf.x, wolf.y); human.AddToArea(); arena.humans.Add(human); human.Update(); }
// Update is called once per frame void Update() { _human.Update(); }
public void Run() { for (int i = 0; i < trial_times; i++) { foreach (int WR in wingmanRange) { HexaPos startPos = this._mapForm.human.path[0]; TopologyGraphGenerator topologyGenerator = new TopologyGraphGenerator(this._mapForm.map); TopologyGraph tograph = topologyGenerator.GetTopologyGraph(); PlanningGraphGenerator planningGenerator = new PlanningGraphGenerator(tograph); PathPlanningGraph planGraph = planningGenerator.GetPathPlanningGraph(this._mapForm.HumanPath, WR); PlanningGraphPruner pruner = new PlanningGraphPruner(); PathPlanningGraph newPlanGraph = pruner.GetPlanningGraph(planGraph, startPos); PathPlanningGraph prunedPlanGraph = pruner.BackwardPrune(newPlanGraph); prunedPlanGraph = pruner.ForwardPrune(prunedPlanGraph); Robot robot = new Robot(this._mapForm.map); Human human = new Human(this._mapForm.map); foreach (int HR in humanRange) { this._mapForm.map.GetMapStateMgr().RandomizeValue(); human.SetObservationRange(HR); double[,] localEntropy = this._mapForm.map.GetMapStateMgr().CopyEntropy(); human.Update(this._mapForm.HumanPath, localEntropy); foreach (int RR in robotRange) { robot.SetObservationRange(RR); Console.WriteLine("Trial Time: " + i.ToString() + " WR: " + WR.ToString() + " RR: " + RR.ToString() + " HR: " + HR.ToString()); HexaPath maxPath = new HexaPath(); TreeExpandingWithIterativeTrackingPathPlanner planner = new TreeExpandingWithIterativeTrackingPathPlanner(this._mapForm.map, robot); planner._localEntropy = localEntropy; planner.iteratingOnce = false; maxPath = planner.FindPath(prunedPlanGraph, startPos); Console.WriteLine("PATH : " + maxPath.ToString()); // double[,] tempEntropy = (double[,])this._mapForm.map.GetMapStateMgr().CopyEntropy(); //double maxScore = robot.Score(maxPath, tempEntropy); double maxScore = planner.finalMaxScore; Console.WriteLine("SCORE: " + maxScore); Console.WriteLine(""); PerformanceParameter param = new PerformanceParameter(); param.maxScore = maxScore; param.problemSize = planner.problemSize; param.scoreAtFirstRun = planner.scoreAtFirstRun; param.exploredSize = planner.exploredSize; param.totalRunTime = planner.totalRunTime; param.hitOptimalRunTime = planner.hitOptimalRunTime; param.robotRange = RR; param.humanRange = HR; param.wingmanRange = WR; param.runIndex = i; this.performanceList.Add(param); } } } } save(prefix); }
public void DestroyWolfAndCreateHuman(Wolf wolf) { arena.wolves.Remove(wolf); wolf.RemoveFromArea(); this.wolf = null; human = new Human(this,arena.entityArea,true); human.SetPosition(wolf.x,wolf.y); human.AddToArea(); arena.humans.Add(human); human.Update(); }
/// <summary> /// Runs one frame of update for the game. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen) { float elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds; // Check it one of the players reached 5 and stop the game if ((player.Catapult.GameOver || computer.Catapult.GameOver) && (gameOver == false)) { gameOver = true; if (player.Score > computer.Score) { AudioManager.PlaySound("gameOver_Win"); } else { AudioManager.PlaySound("gameOver_Lose"); } return; } // If Reset flag raised and both catapults are not animating - // active catapult finished the cycle, new turn! if ((player.Catapult.CurrentState == CatapultState.Reset || computer.Catapult.CurrentState == CatapultState.Reset) && !(player.Catapult.AnimationRunning || computer.Catapult.AnimationRunning)) { changeTurn = true; if (player.IsActive == true) //Last turn was a human turn? { player.IsActive = false; computer.IsActive = true; isHumanTurn = false; player.Catapult.CurrentState = CatapultState.Idle; computer.Catapult.CurrentState = CatapultState.Aiming; } else //It was an AI turn { player.IsActive = true; computer.IsActive = false; isHumanTurn = true; computer.Catapult.CurrentState = CatapultState.Idle; player.Catapult.CurrentState = CatapultState.Idle; } } if (changeTurn) { // Update wind wind = new Vector2(random.Next(-1, 2), random.Next(minWind, maxWind + 1)); // Set new wind value to the players and player.Catapult.Wind = computer.Catapult.Wind = wind.X > 0 ? wind.Y : -wind.Y; changeTurn = false; } // Update the players player.Update(gameTime); computer.Update(gameTime); // Updates the clouds position UpdateClouds(elapsed); base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen); }