Skip to content

Commit

Permalink
Rider suggested cleanup, part 1 (#5265)
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Elion authored Apr 15, 2021
1 parent 04a02c1 commit 2721989
Show file tree
Hide file tree
Showing 68 changed files with 34 additions and 110 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using UnityEngine;
using Unity.MLAgents;
using Unity.MLAgents.Actuators;
using Unity.MLAgents.Sensors;
using Unity.MLAgents.Sensors.Reflection;

public class Ball3DHardAgent : Agent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public override ActionSpec ActionSpec
/// <summary>
/// Simple actuator that converts the action into a {-1, 0, 1} direction
/// </summary>
public class BasicActuator : IActuator, IHeuristicProvider
public class BasicActuator : IActuator
{
public BasicController basicController;
ActionSpec m_ActionSpec;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using UnityEngine;
using Unity.MLAgents;
using Unity.Barracuda;
using Unity.MLAgents.Actuators;
using Unity.MLAgentsExamples;
using Unity.MLAgents.Sensors;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Collections;
using UnityEngine;
using Unity.MLAgents;
using Unity.MLAgents.Sensors;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SimpleNPC : MonoBehaviour
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public void MoveAgent(ActionBuffers actionBuffers)
dirToGo += transform.right * right;
rotateDir = -transform.up * rotate;

var shootCommand = (int)discreteActions[0] > 0;
var shootCommand = discreteActions[0] > 0;
if (shootCommand)
{
m_Shoot = true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System;
using UnityEngine;
using Unity.MLAgents;
using Unity.MLAgents.Actuators;
using Unity.MLAgents.Integrations.Match3;

namespace Unity.MLAgentsExamples
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
//Put this script on your blue cube.

using System.Collections;
using UnityEngine;
using Unity.MLAgents;
using Unity.MLAgents.Actuators;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
//Put this script on your blue cube.

using System;
using System.Collections;
using UnityEngine;
using Unity.MLAgents;
Expand All @@ -18,7 +16,7 @@ public class PushBlockWithInputAgentBasic : Agent

/// <summary>
/// The area bounds.
/// </summary'PushAgentBasic'>
/// </summary>
[HideInInspector]
public Bounds areaBounds;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using UnityEngine;
using Random = UnityEngine.Random;
using Unity.MLAgents;
using UnityEngine.Events;

namespace Unity.MLAgentsExamples
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Collections;
using System.Collections.Generic;
using Unity.MLAgents;
using UnityEngine;
Expand Down Expand Up @@ -91,7 +90,7 @@ public void ResetBall()
var randomPosX = Random.Range(-2.5f, 2.5f);
var randomPosZ = Random.Range(-2.5f, 2.5f);

ball.transform.position = m_BallStartingPos + new Vector3(randomPosX, 0f, randomPosZ); ;
ball.transform.position = m_BallStartingPos + new Vector3(randomPosX, 0f, randomPosZ);
ballRb.velocity = Vector3.zero;
ballRb.angularVelocity = Vector3.zero;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class NumberTile : MonoBehaviour
Expand All @@ -8,7 +6,7 @@ public class NumberTile : MonoBehaviour
public Material DefaultMaterial;
public Material SuccessMaterial;

private bool m_Visited = false;
private bool m_Visited;
private MeshRenderer m_Renderer;

public bool IsVisited
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public override void CollectObservations(VectorSensor sensor)
// Here, the observation for the tile is added to the BufferSensor
m_BufferSensor.AppendObservation(listObservation);

};
}

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ void FixedUpdate()
Vector3 GetAvgVelocity()
{
Vector3 velSum = Vector3.zero;
Vector3 avgVel = Vector3.zero;

//ALL RBS
int numOfRb = 0;
Expand All @@ -271,7 +270,7 @@ Vector3 GetAvgVelocity()
velSum += item.rb.velocity;
}

avgVel = velSum / numOfRb;
var avgVel = velSum / numOfRb;
return avgVel;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using UnityEngine;
using Unity.MLAgents;
using Unity.Barracuda;
using Unity.MLAgents.Actuators;
using Unity.MLAgentsExamples;
using Unity.MLAgents.Sensors;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#if MLA_INPUT_SYSTEM
using Unity.MLAgents.Actuators;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.InputSystem.LowLevel;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#if MLA_INPUT_SYSTEM
using System;
using Unity.MLAgents.Actuators;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.InputSystem.LowLevel;

namespace Unity.MLAgents.Extensions.Input
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#if MLA_INPUT_SYSTEM
using System;
using Unity.MLAgents.Actuators;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.LowLevel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

using Unity.MLAgents.Actuators;
using Unity.MLAgents.Policies;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.Profiling;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#if MLA_INPUT_TESTS
using System;
using NUnit.Framework;
using Unity.MLAgents.Actuators;
using Unity.MLAgents.Extensions.Input;
using UnityEngine;
using UnityEngine.InputSystem;

namespace Unity.MLAgents.Extensions.Tests.Runtime.Input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public void TestCountingSensor()

gridSensor.Update();

subarrayIndicies = new int[] { 77, 78, 87, 88 };
subarrayIndicies = new[] { 77, 78, 87, 88 };
expectedSubarrays = DuplicateArray(new float[] { 2, 0 }, 4);
expectedDefault = new float[] { 0, 0 };
AssertSubarraysAtIndex(gridSensor.PerceptionBuffer, subarrayIndicies, expectedSubarrays, expectedDefault);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Runtime.CompilerServices;
using UnityEngine;
using NUnit.Framework;
using Unity.MLAgents.Sensors;
Expand Down
2 changes: 0 additions & 2 deletions com.unity.ml-agents/Editor/DemonstrationDrawer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
using System.Text;
using UnityEditor;
using Unity.MLAgents.Demonstrations;
using Unity.MLAgents.Policies;


namespace Unity.MLAgents.Editor
{
Expand Down
1 change: 0 additions & 1 deletion com.unity.ml-agents/Runtime/Actuators/ActionSpec.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;

Expand Down
1 change: 0 additions & 1 deletion com.unity.ml-agents/Runtime/Actuators/ActuatorComponent.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using UnityEngine;

namespace Unity.MLAgents.Actuators
Expand Down
2 changes: 0 additions & 2 deletions com.unity.ml-agents/Runtime/Actuators/IDiscreteActionMask.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System.Collections.Generic;

namespace Unity.MLAgents.Actuators
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ internal class InferenceAnalytics
/// <summary>
/// Whether or not we've registered this particular event yet
/// </summary>
static bool s_EventRegistered = false;
static bool s_EventRegistered;

/// <summary>
/// Hourly limit for this event name
Expand Down
2 changes: 1 addition & 1 deletion com.unity.ml-agents/Runtime/Analytics/TrainingAnalytics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ internal static class TrainingAnalytics
/// <summary>
/// Whether or not we've registered this particular event yet
/// </summary>
static bool s_EventsRegistered = false;
static bool s_EventsRegistered;

/// <summary>
/// Behaviors that we've already sent events for.
Expand Down
6 changes: 3 additions & 3 deletions com.unity.ml-agents/Runtime/Communicator/GrpcExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ internal static class GrpcExtensions
/// <summary>
/// Static flag to make sure that we only fire the warning once.
/// </summary>
private static bool s_HaveWarnedTrainerCapabilitiesAgentGroup = false;
private static bool s_HaveWarnedTrainerCapabilitiesAgentGroup;

/// <summary>
/// Converts a AgentInfo to a protobuf generated AgentInfoActionPairProto
Expand Down Expand Up @@ -326,8 +326,8 @@ public static ActionBuffers ToActionBuffers(this AgentActionProto proto)
/// <summary>
/// Static flag to make sure that we only fire the warning once.
/// </summary>
private static bool s_HaveWarnedTrainerCapabilitiesMultiPng = false;
private static bool s_HaveWarnedTrainerCapabilitiesMapping = false;
private static bool s_HaveWarnedTrainerCapabilitiesMultiPng;
private static bool s_HaveWarnedTrainerCapabilitiesMapping;

/// <summary>
/// Generate an ObservationProto for the sensor using the provided ObservationWriter.
Expand Down
2 changes: 1 addition & 1 deletion com.unity.ml-agents/Runtime/DecisionRequester.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace Unity.MLAgents
///
/// The DecisionRequester component provides a convenient and flexible way to
/// trigger the agent decision making process. Without a DecisionRequester,
/// your <see cref="Agent"/> implmentation must manually call its
/// your <see cref="Agent"/> implementation must manually call its
/// <seealso cref="Agent.RequestDecision"/> function.
/// </remarks>
[AddComponentMenu("ML Agents/Decision Requester", (int)MenuGroup.Default)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,7 @@ public static bool HasDiscreteOutputs(this Model model)
}
else
{
return model.outputs.Contains(TensorNames.DiscreteActionOutput) &&
(int)model.DiscreteOutputSize() > 0;
return model.outputs.Contains(TensorNames.DiscreteActionOutput) && model.DiscreteOutputSize() > 0;
}
}

Expand Down
1 change: 0 additions & 1 deletion com.unity.ml-agents/Runtime/Inference/GeneratorImpl.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Collections.Generic;
using System;
using UnityEngine;
using Unity.Barracuda;
using Unity.MLAgents.Inference.Utils;
using Unity.MLAgents.Sensors;
Expand Down
1 change: 0 additions & 1 deletion com.unity.ml-agents/Runtime/Inference/ModelRunner.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using Unity.Barracuda;
using UnityEngine.Profiling;
Expand Down
12 changes: 6 additions & 6 deletions com.unity.ml-agents/Runtime/InplaceArray.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ public InplaceArray(T elem0)
{
m_Length = 1;
m_Elem0 = elem0;
m_Elem1 = new T { };
m_Elem2 = new T { };
m_Elem3 = new T { };
m_Elem1 = new T();
m_Elem2 = new T();
m_Elem3 = new T();
}

/// <summary>
Expand All @@ -44,8 +44,8 @@ public InplaceArray(T elem0, T elem1)
m_Length = 2;
m_Elem0 = elem0;
m_Elem1 = elem1;
m_Elem2 = new T { };
m_Elem3 = new T { };
m_Elem2 = new T();
m_Elem3 = new T();
}

/// <summary>
Expand All @@ -60,7 +60,7 @@ public InplaceArray(T elem0, T elem1, T elem2)
m_Elem0 = elem0;
m_Elem1 = elem1;
m_Elem2 = elem2;
m_Elem3 = new T { };
m_Elem3 = new T();
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion com.unity.ml-agents/Runtime/Integrations/Match3/Move.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public static Move FromMoveIndex(int moveIndex, BoardSize maxBoardSize)

if (moveIndex < 0 || moveIndex >= NumPotentialMoves(maxBoardSize))
{
throw new ArgumentOutOfRangeException("Invalid move index.");
throw new ArgumentOutOfRangeException("moveIndex");
}
Direction dir;
int row, col;
Expand Down
3 changes: 2 additions & 1 deletion com.unity.ml-agents/Runtime/MLAgentsSettingsManager.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using System;
using System.Linq;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#else
using System.Linq;
#endif

namespace Unity.MLAgents
Expand Down
2 changes: 1 addition & 1 deletion com.unity.ml-agents/Runtime/MultiAgentGroupIdCounter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ internal static class MultiAgentGroupIdCounter
static int s_Counter;
public static int GetGroupId()
{
return Interlocked.Increment(ref s_Counter); ;
return Interlocked.Increment(ref s_Counter);
}
}
}
1 change: 0 additions & 1 deletion com.unity.ml-agents/Runtime/Policies/HeuristicPolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ internal class HeuristicPolicy : IPolicy
NullList m_NullList = new NullList();


/// <inheritdoc />
public HeuristicPolicy(ActuatorManager actuatorManager, ActionSpec actionSpec)
{
m_ActuatorManager = actuatorManager;
Expand Down
1 change: 0 additions & 1 deletion com.unity.ml-agents/Runtime/Policies/RemotePolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ internal class RemotePolicy : IPolicy
/// </summary>
private IList<IActuator> m_Actuators;

/// <inheritdoc />
public RemotePolicy(
ActionSpec actionSpec,
IList<IActuator> actuators,
Expand Down
2 changes: 1 addition & 1 deletion com.unity.ml-agents/Runtime/Sensors/BoxOverlapChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void InitCellLocalPositions()

/// <summary>Converts the index of the cell to the 3D point (y is zero) relative to grid center</summary>
/// <returns>Vector3 of the position of the center of the cell relative to grid center</returns>
/// <param name="cell">The index of the cell</param>
/// <param name="cellIndex">The index of the cell</param>
Vector3 GetCellLocalPosition(int cellIndex)
{
float x = (cellIndex / m_GridSize.z - m_CellCenterOffset.x) * m_CellScale.x;
Expand Down
2 changes: 1 addition & 1 deletion com.unity.ml-agents/Runtime/Sensors/GridSensorComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace Unity.MLAgents.Sensors
{
/// <summary>
/// A SensorComponent that creates a <see cref="GridSensor"/>.
/// A SensorComponent that creates a <see cref="GridSensorBase"/>.
/// </summary>
[AddComponentMenu("ML Agents/Grid Sensor", (int)MenuGroup.Sensors)]
public class GridSensorComponent : SensorComponent
Expand Down
Loading

0 comments on commit 2721989

Please sign in to comment.