public Moves Move(Utils.Direction direction, Utils.Quantifier speed) { Moves move = Moves.NO_ACTION; Utils.Quantifier Moving_In_Pretended_Direction; Moves Move_Direction, Move_Oposite_Direction; if (direction == Utils.Direction.RIGHT) { Moving_In_Pretended_Direction = this.agentStatus.MOVING_RIGHT; Move_Direction = Moves.MOVE_RIGHT; Move_Oposite_Direction = Moves.MOVE_LEFT; } else { Moving_In_Pretended_Direction = this.agentStatus.MOVING_LEFT; Move_Direction = Moves.MOVE_LEFT; Move_Oposite_Direction = Moves.MOVE_RIGHT; } if (Moving_In_Pretended_Direction == speed + 1) //TODO REDUDANT, NEEDS TO REFACTOR. I JUST COPIED IT FROM CIRCLE XD { move = Move_Oposite_Direction; } else if (Moving_In_Pretended_Direction <= speed) { move = Move_Direction; } else { move = Move_Oposite_Direction; } return(move); }
private Moves Roll(Utils.Direction direction, Utils.Quantifier speed) { Moves move = Moves.NO_ACTION; Utils.Quantifier Moving_In_Pretended_Direction; Moves Roll_Pretended_Direction, Roll_Oposite_Direction; //Define directions if (direction == Utils.Direction.RIGHT) { Moving_In_Pretended_Direction = this.agentStatus.MOVING_RIGHT; Roll_Pretended_Direction = Moves.ROLL_RIGHT; Roll_Oposite_Direction = Moves.ROLL_LEFT; } else { Moving_In_Pretended_Direction = this.agentStatus.MOVING_LEFT; Roll_Pretended_Direction = Moves.ROLL_LEFT; Roll_Oposite_Direction = Moves.ROLL_RIGHT; } //Decide action if (this.predictor != null) { //TODO Remove this first condition. This is the same as Else condition if (Moving_In_Pretended_Direction == speed + 1) //If Agent is moving with a little bit excessive speed { Log.LogInformation("SPEED: Good enough - " + Enum.GetName(typeof(Utils.Quantifier), Moving_In_Pretended_Direction).ToString()); //move = Moves.NO_ACTION; move = Roll_Oposite_Direction; } else if (Moving_In_Pretended_Direction <= speed) //When the agent is moving with not enough speed { Log.LogInformation("SPEED: Still not enough - " + Enum.GetName(typeof(Utils.Quantifier), Moving_In_Pretended_Direction).ToString()); move = Roll_Pretended_Direction; } else //When the agent is moving with too much speed and needs to brake (> speed + 1) { Log.LogInformation("SPEED: Too much! Rolling backwards - " + Enum.GetName(typeof(Utils.Quantifier), Moving_In_Pretended_Direction).ToString()); move = Roll_Oposite_Direction; } } return(move); }