/// <summary> /// warning: motor should be created before creating an agent. if not, use AttachBike to assign motor correctly /// </summary> public BotAgent(AgentController ac, string name, int motorID) : base(ac, name) { this.motorID = motorID; ownMotor = (BotMotor)GameSettings.gameMotors[motorID]; teammates = new Hashtable(); enemies = new Hashtable(); friendlyAgents = new Hashtable(); steeringLocked = false; target = -1; lastTargetHP = 0; faData = new FoolAroundData(); avaisionPenalty = 0; }
private void FoolAround(ref MotorDataContext mdc, FoolAroundData fad) { //generate brakes active/inactive command if (fad.brakes_time <= 0) { //0.2 of chance for activating brakes fad.brakes = MotorkiGame.random.Next(0, 15) % 5 > 0 ? false : true; fad.brakes_time = MotorkiGame.random.Next(250, 750); } fad.brakes_time -= MotorkiGame.game.currentTime.ElapsedGameTime.Milliseconds; //generate forward/left/right command if (fad.steering_time <= 0) { //(1/3) of chance for going forward, left or right fad.steering = MotorkiGame.random.Next(0, 12) % 3 - 1; fad.steering_time = MotorkiGame.random.Next(100, 500); } fad.steering_time -= MotorkiGame.game.currentTime.ElapsedGameTime.Milliseconds; //encode steering signal mdc.newSteering = fad.steering * (fad.brakes ? 2 : 1) + ((fad.steering == 0) && fad.brakes ? 3 : 0); }