void SetEnvironment() { transform.position = m_InitialPosition * (m_ResetParams.GetWithDefault("gridSize", 5f) + 1); var playersList = new List <int>(); for (var i = 0; i < (int)m_ResetParams.GetWithDefault("numObstacles", 1); i++) { playersList.Add(1); } for (var i = 0; i < (int)m_ResetParams.GetWithDefault("numGoals", 1f); i++) { playersList.Add(0); } players = playersList.ToArray(); var gridSize = (int)m_ResetParams.GetWithDefault("gridSize", 5f); m_Plane.transform.localScale = new Vector3(gridSize / 10.0f, 1f, gridSize / 10.0f); m_Plane.transform.localPosition = new Vector3((gridSize - 1) / 2f, -0.5f, (gridSize - 1) / 2f); m_Sn.transform.localScale = new Vector3(1, 1, gridSize + 2); m_Ss.transform.localScale = new Vector3(1, 1, gridSize + 2); m_Sn.transform.localPosition = new Vector3((gridSize - 1) / 2f, 0.0f, gridSize); m_Ss.transform.localPosition = new Vector3((gridSize - 1) / 2f, 0.0f, -1); m_Se.transform.localScale = new Vector3(1, 1, gridSize + 2); m_Sw.transform.localScale = new Vector3(1, 1, gridSize + 2); m_Se.transform.localPosition = new Vector3(gridSize, 0.0f, (gridSize - 1) / 2f); m_Sw.transform.localPosition = new Vector3(-1, 0.0f, (gridSize - 1) / 2f); m_AgentCam.orthographicSize = (gridSize) / 2f; m_AgentCam.transform.localPosition = new Vector3((gridSize - 1) / 2f, gridSize + 1f, (gridSize - 1) / 2f); }
/// <summary> /// Configures the agent. Given an integer config, the wall will have /// different height and a different brain will be assigned to the agent. /// </summary> /// <param name="config">Config. /// If 0 : No wall and noWallBrain. /// If 1: Small wall and smallWallBrain. /// Other : Tall wall and BigWallBrain. /// </param> void ConfigureAgent(int config) { var localScale = wall.transform.localScale; if (config == 0) { localScale = new Vector3( localScale.x, m_ResetParams.GetWithDefault("no_wall_height", 0), localScale.z); wall.transform.localScale = localScale; SetModel(m_NoWallBehaviorName, noWallBrain); } else if (config == 1) { localScale = new Vector3( localScale.x, m_ResetParams.GetWithDefault("small_wall_height", 4), localScale.z); wall.transform.localScale = localScale; SetModel(m_SmallWallBehaviorName, smallWallBrain); } else { var height = m_ResetParams.GetWithDefault("big_wall_height", 8); localScale = new Vector3( localScale.x, height, localScale.z); wall.transform.localScale = localScale; SetModel(m_BigWallBehaviorName, bigWallBrain); } }
/// <summary> /// Configures the agent. Given an integer config, the wall will have /// different height and a different brain will be assigned to the agent. /// </summary> /// <param name="config">Config. /// If 0 : No wall and noWallBrain. /// If 1: Small wall and smallWallBrain. /// Other : Tall wall and BigWallBrain. /// </param> void ConfigureAgent(int config) { var localScale = wall.transform.localScale; if (config == 0) { localScale = new Vector3( localScale.x, m_ResetParams.GetWithDefault("no_wall_height", 0), localScale.z); wall.transform.localScale = localScale; SetModel("SmallWallJump", noWallBrain); } else if (config == 1) { localScale = new Vector3( localScale.x, m_ResetParams.GetWithDefault("small_wall_height", 4), localScale.z); wall.transform.localScale = localScale; SetModel("SmallWallJump", smallWallBrain); } else { var min = m_ResetParams.GetWithDefault("big_wall_min_height", 8); var max = m_ResetParams.GetWithDefault("big_wall_max_height", 8); var height = min + Random.value * (max - min); localScale = new Vector3( localScale.x, height, localScale.z); wall.transform.localScale = localScale; SetModel("BigWallJump", bigWallBrain); } }
public void SetResetParameters() { m_GoalSize = m_ResetParams.GetWithDefault("goal_size", 5); m_GoalSpeed = Random.Range(-1f, 1f) * m_ResetParams.GetWithDefault("goal_speed", 1); m_Deviation = m_ResetParams.GetWithDefault("deviation", 0); m_DeviationFreq = m_ResetParams.GetWithDefault("deviation_freq", 0); }
public void setBall() { ball_rb.mass = resetParams.GetWithDefault("mass", 5.0f); var scale = resetParams.GetWithDefault("scale", 2.0f); ball.transform.localScale = new Vector3(scale, scale, scale); }
void ResetScene() { ballRigidbody.mass = defaultParameters.GetWithDefault("mass", 1f); var scale = defaultParameters.GetWithDefault("scale", 0.5f); ball.transform.localScale = new Vector3(scale, scale, scale); }
public void SetGroundMaterialFriction() { var groundCollider = ground.GetComponent <Collider>(); groundCollider.material.dynamicFriction = m_ResetParams.GetWithDefault("dynamic_friction", 0); groundCollider.material.staticFriction = m_ResetParams.GetWithDefault("static_friction", 0); }
public void SetRobot() { //Set the attributes of the robot by fetching the information from the academy rb.mass = m_resetParams.GetWithDefault("mass", 1.0f); var scale = m_resetParams.GetWithDefault("scale", 1.0f); this.transform.localScale = new Vector3(scale, scale, scale); }
void EnvironmentReset() { this.score = 0f; Respawn(); this.MovementSpeed = EnvironmentParameters.GetWithDefault("movementSpeed", 1.0f); this.RotationSpeed = EnvironmentParameters.GetWithDefault("rotationSpeed", 100f); this.isRandomRespawn = EnvironmentParameters.GetWithDefault("randomRespawnTarget", 0f) == 1f ? true : false; }
public void SetBall() { //Set the attributes of the ball by fetching the information from the academy m_BallRb.mass = m_ResetParams.GetWithDefault("mass", 1.0f); var scale = m_ResetParams.GetWithDefault("scale", 1.0f); ball.transform.localScale = new Vector3(scale, scale, scale); }
public void SetRacket() { angle = m_ResetParams.GetWithDefault("angle", 55); gameObject.transform.eulerAngles = new Vector3( gameObject.transform.eulerAngles.x, gameObject.transform.eulerAngles.y, m_InvertMult * angle ); }
public override void OnEpisodeBegin() { // Fixed starting pose transform.position = new Vector3(-120.9f, 10.0f, 792.7f); transform.rotation = Quaternion.Euler(0.0f, 0.0f, 0.0f); keySpeed = m_ResetParams.GetWithDefault("key_speed", 10.0f); camSens = m_ResetParams.GetWithDefault("cam_sens", 0.25f); }
/// <summary> /// Initializes the environment and sets values based on what is received /// from Python /// </summary> public override void Initialize() { environmentParameters = Academy.Instance.EnvironmentParameters; stepReward = environmentParameters.GetWithDefault("step_reward", -0.1f); targetReward = environmentParameters.GetWithDefault("target_reward", 1.0f); fireReward = environmentParameters.GetWithDefault("fire_reward", -1.0f); MaxStep = (int)environmentParameters.GetWithDefault("max_steps", 250f); Time.timeScale = environmentParameters.GetWithDefault("time_scale", 1.0f); }
public void SetEnvParameters() { EnvironmentParameters envParameters = Academy.Instance.EnvironmentParameters; this.scanReward = envParameters.GetWithDefault("scan_reward", 1.0f); this.findReward = envParameters.GetWithDefault("find_reward", 1.0f); this.hitReward = envParameters.GetWithDefault("hit_rewerd", 0.0f); this.shotRewerd = envParameters.GetWithDefault("shot_reward", 0.0f); this.stepReward = envParameters.GetWithDefault("step_reward", -0.0002f); }
void Start() { m_Rb = gameObject.GetComponent <Rigidbody>(); m_ResetParams = Academy.Instance.EnvironmentParameters; var krange = m_ResetParams.GetWithDefault("killRange", 2f); BoxCollider collider = this.GetComponent(typeof(BoxCollider)) as BoxCollider; collider.size = new Vector3(krange, 1, krange); speed = m_ResetParams.GetWithDefault("praySpeed", 800); }
public void SetResetParameters() { exposureRadius = m_ResetParams.GetWithDefault("exposureRadius", pandemicArea.exposureRadius); GetComponent <SphereCollider>().radius = exposureRadius; recoverTime = m_ResetParams.GetWithDefault("recoverTime", pandemicArea.recoverTime); infectionCoeff = m_ResetParams.GetWithDefault("infectionCoeff", pandemicArea.infectionCoeff); //healthyCount = (int) m_ResetParams.GetWithDefault("healthyCount", pandemicArea.healthyBotCount); //infectedCount =(int)m_ResetParams.GetWithDefault("infectedCount", pandemicArea.infectedBotCount); //pandemicArea.healthyBotCount = healthyCount; //pandemicArea.infectedBotCount = infectedCount; }
public override void CollectDiscreteActionMasks(DiscreteActionMasker actionMasker) { // Mask the necessary actions if selected by the user. if (maskActions) { // Prevents the agent from picking an action that would make it collide with a wall var positionX = (int)transform.position.x; var positionZ = (int)transform.position.z; var maxPosition = (int)m_ResetParams.GetWithDefault("gridSize", 5f) - 1; if (positionX == 0) { actionMasker.SetMask(0, new int[] { k_Left }); } if (positionX == maxPosition) { actionMasker.SetMask(0, new int[] { k_Right }); } if (positionZ == 0) { actionMasker.SetMask(0, new int[] { k_Down }); } if (positionZ == maxPosition) { actionMasker.SetMask(0, new int[] { k_Up }); } } }
public void Respawn() { m_Rb.velocity = Vector3.zero; m_Rb.angularVelocity = Vector3.zero; currentCollisions = new List <HunterAgent>(); gameObject.transform.localPosition = new Vector3((1 - 2 * Random.value) * 1, 0.5f, (1 - 2 * Random.value) * 1); //Get curriculum update from the academy var krange = m_ResetParams.GetWithDefault("killRange", 2f); BoxCollider collider = this.GetComponent(typeof(BoxCollider)) as BoxCollider; collider.size = new Vector3(krange, 1, krange); speed = m_ResetParams.GetWithDefault("praySpeed", 800); }
public override void OnEpisodeBegin() { worldArea.ResetArea(); weaponHeld.weaponDamage = (int)m_ResetParams.GetWithDefault("weapon_damage", 10); weaponHeld.WeaponReset(); health = 100; }
private void Start() { EnvironmentParameters = Academy.Instance.EnvironmentParameters; EnemyCount = Mathf.FloorToInt(EnvironmentParameters.GetWithDefault("amountZombies", 4f)); SetEnemiesActive(); }
public override void WriteDiscreteActionMask(IDiscreteActionMask actionMask) { // Mask the necessary actions if selected by the user. if (maskActions) { // Prevents the agent from picking an action that would make it collide with a wall var positionX = (int)transform.localPosition.x; var positionZ = (int)transform.localPosition.z; var maxPosition = (int)m_ResetParams.GetWithDefault("gridSize", 5f) - 1; if (positionX == 0) { actionMask.SetActionEnabled(0, k_Left, false); } if (positionX == maxPosition) { actionMask.SetActionEnabled(0, k_Right, false); } if (positionZ == 0) { actionMask.SetActionEnabled(0, k_Down, false); } if (positionZ == maxPosition) { actionMask.SetActionEnabled(0, k_Up, false); } } }
public void ResetArea() { RemoveFishes(); PlacePenguin(); PlaceBaby(); SpawnFish(4, parameters.GetWithDefault("fish_speed", 0.5f)); }
public void Respawn() { CurrentHealth = startingHealth; speed = EnvironmentParameters.GetWithDefault("zombieSpeed", 1f); navAgent.speed = speed; transform.position = new Vector3(StartPosition.x + Random.Range(randomRangeX_Neg, randomRangeX_Pos), StartPosition.y, StartPosition.z + Random.Range(randomRangeZ_Neg, randomRangeZ_Pos)); }
public override void OnEpisodeBegin() { m_ResetParams = Academy.Instance.EnvironmentParameters; rc.height = m_ResetParams.GetWithDefault("init_height", 550); rc.init_angle_roll = m_ResetParams.GetWithDefault("init_angle_roll", 5); rc.init_angle_pitch = m_ResetParams.GetWithDefault("init_angle_pitch", 90); rc.init_xoffset = m_ResetParams.GetWithDefault("init_xoffset", 15); rc.init_zoffset = m_ResetParams.GetWithDefault("init_zoffset", 90); rc.init_zspeed = m_ResetParams.GetWithDefault("init_zspeed", 1); rc.angle_tvc = m_ResetParams.GetWithDefault("angle_tvc", 7); rc.thrust_engine = m_ResetParams.GetWithDefault("thrust_engine", 5000); rc.thrust_rcs = m_ResetParams.GetWithDefault("thrust_rcs", 0.2f); rc.collision_speed = m_ResetParams.GetWithDefault("collision_speed", 5); episodeFinished = false; rc.ResetPosition(); }
public void ResetBall() { egg.transform.position = ballStartingPos; ballRb.velocity = Vector3.zero; ballRb.angularVelocity = Vector3.zero; var ballScale = m_ResetParams.GetWithDefault("ball_scale", 0.015f); //ballRb.transform.localScale = new Vector3(ballScale, ballScale, ballScale); }
void SetResetParameters() { if (resetParams != null) { moveSpeed = resetParams.GetWithDefault("moveSpeed", moveSpeed); rotateSpeed = resetParams.GetWithDefault("rotateSpeed", rotateSpeed); viewAngle = (int)resetParams.GetWithDefault("viewAngle", viewAngle); viewDistance = resetParams.GetWithDefault("viewDistance", viewDistance); if (level) { level.SetParameters(resetParams); } else { this.transform.root.GetComponent <LevelManager>().SetParameters(resetParams); } } }
/// <summary> /// Creates an environment. /// Sets values for targets /// </summary> private void CreateEnvironment() { List <int> objs = new List <int>(); // Add a number of Target objects int numTargets = (int)environmentParameters.GetWithDefault("num_targets", 2); for (int i = 0; i < numTargets; i++) { objs.Add(0); // 0 index in the environmentObjectTypes[] } // Add a number of Fire objects int fireTargets = (int)environmentParameters.GetWithDefault("num_fires", 4); for (int i = 0; i < fireTargets; i++) { objs.Add(1); // 1 index in the environmentObjectTypes[] } environmentObjects = objs.ToArray(); }
public override void OnEpisodeBegin() { m_MaxNumberOfTiles = (int)m_ResetParams.GetWithDefault("num_tiles", DefaultMaxNumTiles); m_NumberOfTilesToSpawn = Random.Range(1, m_MaxNumberOfTiles + 1); SelectTilesToShow(); SetTilePositions(); transform.position = m_StartingPos; m_AgentRb.velocity = Vector3.zero; m_AgentRb.angularVelocity = Vector3.zero; }
protected void SetAIRobotResetParameters() { m_RotationSpeed = m_ResetParams.GetWithDefault( "agent_rotation_speed", m_AIRobotSettings.agentRotationSpeed); m_RotationSpeedRandomFactor = m_GameArena.m_AgentSpeedRandomFactor; // float rotationSpeedRandom = m_ResetParams.GetWithDefault( // "random_direction", // m_AIRobotSettings.agentRotationSpeedRandom); // m_RotationSpeedRandomFactor = Utils.AddRandomFactor(rotationSpeedRandom); m_AgentSpeed = m_ResetParams.GetWithDefault( "agent_speed", m_AIRobotSettings.agentRunSpeed); m_AgentSpeedRandomFactor = m_GameArena.m_AgentSpeedRandomFactor; // float agentSpeedRandom = m_ResetParams.GetWithDefault( // "random_speed", // m_AIRobotSettings.agentRunSpeedRandom); // m_AgentSpeedRandomFactor = Utils.AddRandomFactor(agentSpeedRandom); m_AgentMoveRotMoveSpeed = m_ResetParams.GetWithDefault( "agent_moverot_move_speed", m_AIRobotSettings.agentMoveRotMoveSpeed); m_AgentMoveRotTurnSpeed = m_ResetParams.GetWithDefault( "agent_moverot_rot_speed", m_AIRobotSettings.agentMoveRotTurnSpeed); float observationDistanceRandom = m_ResetParams.GetWithDefault( "random_obs_dist", m_AIRobotSettings.observationDistanceRandom); float observationAngleRandom = m_ResetParams.GetWithDefault( "random_obs_angle", m_AIRobotSettings.observationAngleRandom); var distance = m_ResetParams.GetWithDefault( "ray_length", m_AIRobotSettings.rayLength); if (lowerSensor != null) { lowerSensor.UpdateCasting(distance, observationDistanceRandom, observationAngleRandom); } if (upperSensor != null) { upperSensor.UpdateCasting(distance, observationDistanceRandom, observationAngleRandom); } MaxStep = (int)m_ResetParams.GetWithDefault("max_steps", MaxStep); }
private void Start() { StartPosition = transform.position; CurrentHealth = startingHealth; EnvironmentParameters = Academy.Instance.EnvironmentParameters; speed = EnvironmentParameters.GetWithDefault("zombieSpeed", 1f); navAgent = GetComponent <NavMeshAgent>(); navAgent.speed = speed; Agent.OnEnvironmentReset += Respawn; }