public void SimulateForward(Agent.Action action) { if (gameOver) { return; } scrollSpeed += Time.fixedDeltaTime * MyGameManager._.scrollAcceleration; if (action == Agent.Action.LeftClick) { verticalSpeed = Bird._.tapSpeed; } else { verticalSpeed += Physics2D.gravity.y * Time.fixedDeltaTime; } birdPos += (Vector3.right * scrollSpeed + Vector3.up * verticalSpeed) * Time.fixedDeltaTime; if (birdPos.y > 4.8f) { birdPos.y = 4.8f; } distSinceLastSpawned += Time.fixedDeltaTime * scrollSpeed; if (distSinceLastSpawned >= ColumnPool._.distBetweenColumns) { distSinceLastSpawned = 0f; columnsPositions[currentColumn] = ColumnPool._.NewSpawnPos(birdPos.x); currentColumn = (currentColumn + 1) % columnsPositions.Length; } CheckCollisions(); }
/* ------------------------------------------------------------------------- */ public void updateRobotAction(Agent.Action action, Position position) { switch (action) { case MOVE_UP: case MOVE_RIGHT: case MOVE_DOWN: case MOVE_LEFT: doMove(position); break; case CLEAN: doClean(position); break; case PICKUP: doPickup(position); break; case STAY: break; default: throw new ArgumentOutOfRangeException(nameof(action), action, null); } }
public override bool Validate(Technique tech, Agent.Action action, float value) { foreach (ActionState actionState in actionStates) { if (actionState.action == action && actionState.state == (Mathf.Abs(value) > 0)) { tech.owner.TransitionTechnique(null, true); return(true); } } return(false); }
private void FixedUpdate() { if (controlledByPlayer) { return; } //AI decision making is managed here so we make sure that AI makes 30 decisions per second. if (MyGameManager.gameOver) { aIAction = Agent.Action.LeftClick; //We should click to restart game } else { aIAction = agent.GetAction(); } }
/// <summary> /// Returns whether the technique allows the given action to take place during the techniques execution. /// May cause additional behaviour to take place at the same time. /// </summary> /// <param name="action">The action in question</param> /// <returns>Boolean indicating whether the action is allowed during the technique</returns> public virtual bool ValidateAction(Agent.Action action, float value) { if (validateStrategies == null) { return(true); } bool valid = true; foreach (ActionValidateTechStrategy strategy in validateStrategies) { if (!strategy.Validate(this, action, value)) { valid = false; } } return(valid); }
public void move(Environment environment, Agent.Action action) { var position = new Environment.Position(); switch (action) { case Agent.Action.MOVE_UP: position.y--; environment.updateRobotAction(Agent.Action.MOVE_UP, position); break; case Agent.Action.MOVE_RIGHT: position.x++; environment.updateRobotAction(Agent.Action.MOVE_RIGHT, position); break; case Agent.Action.MOVE_DOWN: position.y++; environment.updateRobotAction(Agent.Action.MOVE_DOWN, position); break; case Agent.Action.MOVE_LEFT: position.x--; environment.updateRobotAction(Agent.Action.MOVE_LEFT, position); break; case Agent.Action.CLEAN: break; case Agent.Action.PICKUP: break; case Agent.Action.STAY: break; default: throw new ArgumentOutOfRangeException(nameof(action), action, null); } }
private void updatePerformance(Agent.Action action, Position position) { switch (getState(position)) { case JEWEL when action == CLEAN: performance -= 6; break; case JEWEL when action == PICKUP: performance += 10; break; case DUST when action == CLEAN: performance += 8; break; case DUST when action == PICKUP: performance += 0; break; case DUST_AND_JEWEL when action == CLEAN: performance -= 6; break; case DUST_AND_JEWEL when action == PICKUP: performance += 10; break; case EMPTY: break; default: throw new ArgumentOutOfRangeException(); } Debug.WriteLine($"Performance: {performance}"); }
private void Update() { if (MyGameManager.gameOver) { if (Clicked()) { MyGameManager.ResetGame(); } return; } if (Clicked()) { anim.SetTrigger("Flap"); verticalSpeed = tapSpeed; } else { verticalSpeed += Physics2D.gravity.y * Time.deltaTime; } transform.Translate((Vector3.right * MyGameManager._.scrollSpeed + Vector3.up * verticalSpeed) * Time.deltaTime); Camera.main.transform.position = new Vector3(transform.position.x + cameraOffsetX, 0, Camera.main.transform.position.z); aIAction = Agent.Action.UNKNOWN; //We make it UNKNOWN to make sure that one AI action doesn't execute more than once between 2 fixed updates }
public override bool Validate(Technique tech, Agent.Action action, float value) { return(true); }
public abstract bool Validate(Technique tech, Agent.Action action, float value);