private void Copy() { ActionSimulator.HoldDownOnBtn(VirtualKeyCode.CONTROL); ActionSimulator.ClickOnBtn(VirtualKeyCode.VK_C); ActionSimulator.ReleaseBtn(VirtualKeyCode.CONTROL); Console.WriteLine("released clicked!"); }
public void ActionSimulatorUpdated(ActionSimulator updatedSimulator) { if (!finished) { actionRules[currentAction].ActionSimulatorUpdated(updatedSimulator); } }
public virtual void ActionSimulatorUpdated(ActionSimulator updatedSimulator) { if (actionStatesRectangle != null && currentStateRectangle < actionStatesRectangle.Count) { actionStatesCircle[currentStateCircle].ActionSimulatorUpdated(updatedSimulator); actionStatesRectangle[currentStateRectangle].ActionSimulatorUpdated(updatedSimulator); } }
//implements abstract circle interface: provides the circle agent with a simulator to make predictions about the future level state public override void ActionSimulatorUpdated(ActionSimulator updatedSimulator) { if (gameMode == 0) { singlePlayer.ActionSimulatorUpdated(updatedSimulator); } else { multiPlayer.ActionSimulatorUpdated(updatedSimulator); } }
//1) on first launch of the program, select the bottom item and click on it public void Select_USB_UIRT_InMenu() { Thread.Sleep(1000); ActionSimulator.ClickOnBtn(VirtualKeyCode.UP); ActionSimulator.ClickOnBtn(VirtualKeyCode.DOWN); ActionSimulator.ClickOnBtn(VirtualKeyCode.DOWN); ActionSimulator.ClickOnBtn(VirtualKeyCode.DOWN); ActionSimulator.ClickOnBtn(VirtualKeyCode.RETURN); WaitForWindowTitle(WINDOW_TITLE_HEX_CODE, this); //WaitForWindowTitle(WINDOW_TITLE_HEX_CODE, true, this); }
private void SelectAll() { ActionSimulator.ClickRightMouseBtn(); ActionSimulator.ClickOnBtn(VirtualKeyCode.DOWN); ActionSimulator.ClickOnBtn(VirtualKeyCode.DOWN); ActionSimulator.ClickOnBtn(VirtualKeyCode.DOWN); ActionSimulator.ClickOnBtn(VirtualKeyCode.DOWN); ActionSimulator.ClickOnBtn(VirtualKeyCode.DOWN); ActionSimulator.ClickOnBtn(VirtualKeyCode.DOWN); ActionSimulator.ClickOnBtn(VirtualKeyCode.RETURN); }
//3) After the green screen will be filled, close the window and go back public void CloseRecordWindow() { if (!ExeWindowTitleReader.GetActiveWindowTitle().Equals(WINDOW_TITLE_LEARN_IR_CODE)) { return; } ActionSimulator.ClickOnBtn(VirtualKeyCode.TAB); ActionSimulator.ClickOnBtn(VirtualKeyCode.TAB); ActionSimulator.ClickOnBtn(VirtualKeyCode.RETURN); //WaitForWindowTitle(WINDOW_TITLE_HEX_CODE, false, this); }
internal void CheckForClosingDialog() { Console.WriteLine("sleeping"); Thread.Sleep(CLOSE_WINDOW_WAIT_TIME); ActionSimulator.ClickOnBtn(WindowsInput.Native.VirtualKeyCode.SPACE); ActionSimulator.ClickOnBtn(WindowsInput.Native.VirtualKeyCode.SPACE); Console.WriteLine("waking! window: " + ExeWindowTitleReader.GetActiveWindowTitle()); Console.WriteLine("is it close window? : " + ExeWindowTitleReader.GetActiveWindowTitle().Equals(CLOSE_WINDOW_TITLE)); /*if (ExeWindowTitleReader.GetActiveWindowTitle().Equals(CLOSE_WINDOW_TITLE)) * { * Console.WriteLine("clicking space"); * ActionSimulator.ClickOnBtn(WindowsInput.Native.VirtualKeyCode.SPACE); * }*/ }
//2) click on "learn an ir code" public void ClickOnLearnIrCode() { Console.WriteLine("clicking tab"); ActionSimulator.ClickOnBtn(VirtualKeyCode.TAB); Console.WriteLine("clicking tab"); ActionSimulator.ClickOnBtn(VirtualKeyCode.TAB); Console.WriteLine("clicking tab"); ActionSimulator.ClickOnBtn(VirtualKeyCode.TAB); Console.WriteLine("clicking tab"); ActionSimulator.ClickOnBtn(VirtualKeyCode.TAB); Console.WriteLine("clicking tab"); ActionSimulator.ClickOnBtn(VirtualKeyCode.TAB); Console.WriteLine("clicking return"); ActionSimulator.ClickOnBtn(VirtualKeyCode.RETURN); Console.WriteLine("waiting for window title"); WaitForWindowTitle(WINDOW_TITLE_LEARN_IR_CODE, this); //WaitForWindowTitle(WINDOW_TITLE_LEARN_IR_CODE, true, this); }
private void ExecuteSingleFrameOrder(List <KeyValuePair <Unit, Command> > commands, List <Player> players, Board board) { Dictionary <Unit, UnitDisplacement> displacements = GetAggregatedDisplacements(players, commands, board); ActionSimulator simulator = new ActionSimulator(displacements, board); Dictionary <Unit, SimulatedDisplacement> result = simulator.Simulate(); foreach (KeyValuePair <Unit, Command> pair in commands) { Unit unit = pair.Key; Command command = pair.Value; Direction absDir = command.GetAbsoluteDir(); SimulatedDisplacement sim = result[unit]; if (command.frame.effect.CanExecute(sim, absDir, board)) { sim.displacement.unit.FaceDirection(absDir); sim.displacement.unit.FaceDirectionAnim(absDir); command.frame.effect.ExecuteEffect(sim, absDir, board); Board.MoveUnit(sim, board); command.frame.anim.ExecuteAnimation(sim, absDir, board); } } }
public NodeGS(Node p, State s, Moves action, ActionSimulator predictor, List <Moves> moves) : base(p, s, action, moves) { simulator = predictor; }
//implements abstract circle interface: provides the circle agent with a simulator to make predictions about the future level state public override void ActionSimulatorUpdated(ActionSimulator updatedSimulator) { this.predictor = updatedSimulator; }
//implements abstract circle interface: provides the circle agent with a simulator to make predictions about the future level state public void ActionSimulatorUpdated(ActionSimulator updatedSimulator) { predictor = updatedSimulator; }
//implements abstract circle interface: updates the agent state logic and predictions public override void Update(TimeSpan elapsedGameTime) { // Execute an action every 'moveStep' cycles if (iterationCount == moveStep) { DecideAction(); iterationCount = 0; } iterationCount++; //check if any collectible was caught lock (remaining) { if (remaining.Count > 0) { List <CollectibleRepresentation> toRemove = new List <CollectibleRepresentation>(); foreach (CollectibleRepresentation item in uncaughtCollectibles) { if (!remaining.Contains(item)) { caughtCollectibles.Add(item); toRemove.Add(item); } } foreach (CollectibleRepresentation item in toRemove) { uncaughtCollectibles.Remove(item); //PARA TESTAR Node circleNextNode = this.graph.diamondNodes[nextDiamondIndex]; Point point = new Point((int)item.X, (int)item.Y); Node caughtNode = new Node(point.X, point.Y, Node.Type.Diamond); if (point == circleNextNode.location) { updateNextDiamond(caughtNode); SendRequest(new Request(new Command.DeleteDiamond(caughtNode))); } else { SendRequest(new Request(new Command.CatchNextDiamond(caughtNode))); deleteDiamond(caughtNode); } } } } //predict what will happen to the agent given the current state and current action if (predictor != null) //predictions are only possible where the agents manager provided { /* * 1) simulator can only be properly used when the Circle and Rectangle characters are ready, this must be ensured for smooth simulation * 2) in this implementation we only wish to simulate a future state when whe have a fresh simulator instance, i.e. the generated debug information is empty */ if (predictor.CharactersReady() && predictor.SimulationHistoryDebugInformation.Count == 0) { List <CollectibleRepresentation> simCaughtCollectibles = new List <CollectibleRepresentation>(); //keep a local reference to the simulator so that it can be updated even whilst we are performing simulations ActionSimulator toSim = predictor; //prepare the desired debug information (to observe this information during the game press F1) toSim.DebugInfo = true; //you can also select the type of debug information generated by the simulator to circle only, rectangle only or both as it is set by default //toSim.DebugInfoSelected = ActionSimulator.DebugInfoMode.Circle; //setup the current circle action in the simulator toSim.AddInstruction(currentAction); //register collectibles that are caught during simulation toSim.SimulatorCollectedEvent += delegate(Object o, CollectibleRepresentation col) { simCaughtCollectibles.Add(col); }; //simulate 2 seconds (predict what will happen 2 seconds ahead) toSim.Update(2); //prepare all the debug information to be passed to the agents manager List <DebugInformation> newDebugInfo = new List <DebugInformation>(); //clear any previously passed debug information (information passed to the manager is cumulative unless cleared in this way) newDebugInfo.Add(DebugInformationFactory.CreateClearDebugInfo()); //add all the simulator generated debug information about circle/rectangle predicted paths newDebugInfo.AddRange(toSim.SimulationHistoryDebugInformation); // see nodes considered by A* Graph.ShowNodes(newDebugInfo, this.graph); // see initial paths created by A* if (Utils.AIAD_DEMO_A_STAR_INITIAL_PATHS) { this.graph.showAllKnownPaths(newDebugInfo, this.type); } //see current path else { Graph.showPath(newDebugInfo, this.nextDiamondPath.path, this.type); } //create additional debug information to visualize collectibles that have been predicted to be caught by the simulator foreach (CollectibleRepresentation item in simCaughtCollectibles) { newDebugInfo.Add(DebugInformationFactory.CreateCircleDebugInfo(new PointF(item.X - debugCircleSize / 2, item.Y - debugCircleSize / 2), debugCircleSize, GeometryFriends.XNAStub.Color.Red)); newDebugInfo.Add(DebugInformationFactory.CreateTextDebugInfo(new PointF(item.X, item.Y), "Predicted catch!", GeometryFriends.XNAStub.Color.White)); } //create additional debug information to visualize collectibles that have already been caught by the agent foreach (CollectibleRepresentation item in caughtCollectibles) { newDebugInfo.Add(DebugInformationFactory.CreateCircleDebugInfo(new PointF(item.X - debugCircleSize / 2, item.Y - debugCircleSize / 2), debugCircleSize, GeometryFriends.XNAStub.Color.GreenYellow)); } //set all the debug information to be read by the agents manager debugInfo = newDebugInfo.ToArray(); } } }
private Moves Launch() { Moves move = Moves.NO_ACTION; if (this.predictor != null) { if (predictor.CharactersReady() && predictor.SimulationHistoryDebugInformation.Count == 0) { ActionSimulator sim = predictor; sim.Update(1); //TODO NAO e preciso esta treta toda dos status CircleRepresentation circle = new CircleRepresentation(sim.CirclePositionX, sim.CirclePositionY, sim.CircleVelocityX, sim.CircleVelocityY, sim.CircleVelocityRadius); RectangleRepresentation rectangle = new RectangleRepresentation(sim.RectanglePositionX, sim.RectanglePositionY, sim.RectangleVelocityX, sim.RectangleVelocityY, sim.RectangleHeight); ObstacleRepresentation dummy = new ObstacleRepresentation(sim.RectanglePositionX, sim.RectanglePositionY, Utils.getRectangleWidth(sim.RectangleHeight), sim.RectangleHeight); Status futureCircle = new Status(); futureCircle.Update(circle, rectangle, dummy, AgentType.Circle); if (this.Jumping) { if (this.rectangleInfo.Height > 160) //When almost fully morphed up, circle jumps { Log.LogInformation("REHEARSAL: Jumping!"); move = Moves.JUMP; SendRequest(new Request(new Command.MorphUp())); this.Jumping = false; //Already ended the jump } else //while rectangle not yet all morphed up { Log.LogInformation("REHEARSAL: Beginning the launch!"); move = Moves.NO_ACTION; SendRequest(new Request(new Command.MorphUp())); } } else { if (this.agentStatus.ABOVE_OTHER_AGENT == Utils.Quantifier.SLIGHTLY && this.agentStatus.LEFT_FROM_OTHER_AGENT == Utils.Quantifier.NONE && this.agentStatus.RIGHT_FROM_OTHER_AGENT == Utils.Quantifier.NONE && this.agentStatus.NEAR_OTHER_AGENT) //Ready to jump { if (this.agentStatus.MOVING) { Log.LogInformation("REHEARSAL: Still moving on top of rectangle"); move = HoldGround(); SendRequest(new Request(new Command.MorphDown())); } else //Prepare to jump { Log.LogInformation("REHEARSAL: Stopped, and activating launch sequence"); this.Jumping = true; move = Moves.NO_ACTION; SendRequest(new Request(new Command.MorphUp())); } } else //Position himself on top of the rectangle { Log.LogInformation("REHEARSAL: Jumping onto Rectangle"); move = JumpOntoRectangle(); SendRequest(new Request(new Command.MorphDown())); } } } } return(move); }
public virtual void ActionSimulatorUpdated(ActionSimulator updatedSimulator) { }
//constructor public TreeGS(State initialState, ActionSimulator predictor, List <Moves> moves, bool BGT) : base(initialState, moves, BGT) { setRoot(new NodeGS(null, initialState, 0, predictor, moves)); addNode(getRoot()); }
public override void ActionSimulatorUpdated(ActionSimulator updatedSimulator) { circleSingleplayer.ActionSimulatorUpdated(updatedSimulator); }
/* internal void releaseCtrl() * { * ActionSimulator.ReleaseBtn(VirtualKeyCode.RCONTROL); * ActionSimulator.ReleaseBtn(VirtualKeyCode.CONTROL); * ActionSimulator.ReleaseBtn(VirtualKeyCode.LCONTROL); * }*/ internal void CloseWindowsTryToFixWindow() { //releaseCtrl(); ActionSimulator.ClickLeftMouseBtn(); ActionSimulator.ClickOnBtn(VirtualKeyCode.RETURN); }
//implements abstract circle interface: updates the agent state logic and predictions public override void Update(TimeSpan elapsedGameTime) { //Every second one new action is choosen if (lastMoveTime == 60) { lastMoveTime = 0; } if ((lastMoveTime) <= (DateTime.Now.Second) && (lastMoveTime < 60)) { if (!(DateTime.Now.Second == 59)) { RandomAction(); lastMoveTime = lastMoveTime + 1; //DebugSensorsInfo(); } else { lastMoveTime = 60; } } //check if any collectible was caught lock (remaining) { if (remaining.Count > 0) { List <CollectibleRepresentation> toRemove = new List <CollectibleRepresentation>(); foreach (CollectibleRepresentation item in uncaughtCollectibles) { if (!remaining.Contains(item)) { caughtCollectibles.Add(item); toRemove.Add(item); } } foreach (CollectibleRepresentation item in toRemove) { uncaughtCollectibles.Remove(item); } } } //predict what will happen to the agent given the current state and current action if (predictor != null) //predictions are only possible where the agents manager provided { /* * 1) simulator can only be properly used when the Circle and Rectangle characters are ready, this must be ensured for smooth simulation * 2) in this implementation we only wish to simulate a future state when whe have a fresh simulator instance, i.e. the generated debug information is empty */ if (predictor.CharactersReady() && predictor.SimulationHistoryDebugInformation.Count == 0) { List <CollectibleRepresentation> simCaughtCollectibles = new List <CollectibleRepresentation>(); //keep a local reference to the simulator so that it can be updated even whilst we are performing simulations ActionSimulator toSim = predictor; //prepare the desired debug information (to observe this information during the game press F1) toSim.DebugInfo = true; //you can also select the type of debug information generated by the simulator to circle only, rectangle only or both as it is set by default //toSim.DebugInfoSelected = ActionSimulator.DebugInfoMode.Circle; //setup the current circle action in the simulator toSim.AddInstruction(currentAction); //register collectibles that are caught during simulation toSim.SimulatorCollectedEvent += delegate(Object o, CollectibleRepresentation col) { simCaughtCollectibles.Add(col); }; //simulate 2 seconds (predict what will happen 2 seconds ahead) toSim.Update(2); //prepare all the debug information to be passed to the agents manager List <DebugInformation> newDebugInfo = new List <DebugInformation>(); //clear any previously passed debug information (information passed to the manager is cumulative unless cleared in this way) newDebugInfo.Add(DebugInformationFactory.CreateClearDebugInfo()); //add all the simulator generated debug information about circle/rectangle predicted paths newDebugInfo.AddRange(toSim.SimulationHistoryDebugInformation); //create additional debug information to visualize collectibles that have been predicted to be caught by the simulator foreach (CollectibleRepresentation item in simCaughtCollectibles) { newDebugInfo.Add(DebugInformationFactory.CreateCircleDebugInfo(new PointF(item.X - debugCircleSize / 2, item.Y - debugCircleSize / 2), debugCircleSize, GeometryFriends.XNAStub.Color.Red)); newDebugInfo.Add(DebugInformationFactory.CreateTextDebugInfo(new PointF(item.X, item.Y), "Predicted catch!", GeometryFriends.XNAStub.Color.White)); } //create additional debug information to visualize collectibles that have already been caught by the agent foreach (CollectibleRepresentation item in caughtCollectibles) { newDebugInfo.Add(DebugInformationFactory.CreateCircleDebugInfo(new PointF(item.X - debugCircleSize / 2, item.Y - debugCircleSize / 2), debugCircleSize, GeometryFriends.XNAStub.Color.GreenYellow)); } //set all the debug information to be read by the agents manager debugInfo = newDebugInfo.ToArray(); } } }