Skip to content

Commit 2721989

Browse files
author
Chris Elion
authored
Rider suggested cleanup, part 1 (#5265)
1 parent 04a02c1 commit 2721989

File tree

68 files changed

+34
-110
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+34
-110
lines changed

Project/Assets/ML-Agents/Examples/3DBall/Scripts/Ball3DHardAgent.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using UnityEngine;
22
using Unity.MLAgents;
33
using Unity.MLAgents.Actuators;
4-
using Unity.MLAgents.Sensors;
54
using Unity.MLAgents.Sensors.Reflection;
65

76
public class Ball3DHardAgent : Agent

Project/Assets/ML-Agents/Examples/Basic/Scripts/BasicActuatorComponent.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public override ActionSpec ActionSpec
3131
/// <summary>
3232
/// Simple actuator that converts the action into a {-1, 0, 1} direction
3333
/// </summary>
34-
public class BasicActuator : IActuator, IHeuristicProvider
34+
public class BasicActuator : IActuator
3535
{
3636
public BasicController basicController;
3737
ActionSpec m_ActionSpec;

Project/Assets/ML-Agents/Examples/Crawler/Scripts/CrawlerAgent.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using UnityEngine;
22
using Unity.MLAgents;
3-
using Unity.Barracuda;
43
using Unity.MLAgents.Actuators;
54
using Unity.MLAgentsExamples;
65
using Unity.MLAgents.Sensors;

Project/Assets/ML-Agents/Examples/DungeonEscape/Scripts/PushAgentEscape.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System.Collections;
21
using UnityEngine;
32
using Unity.MLAgents;
43
using Unity.MLAgents.Sensors;

Project/Assets/ML-Agents/Examples/DungeonEscape/Scripts/SimpleNPC.cs

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
// using System;
2-
using System.Collections;
3-
using System.Collections.Generic;
41
using UnityEngine;
52

63
public class SimpleNPC : MonoBehaviour

Project/Assets/ML-Agents/Examples/FoodCollector/Scripts/FoodCollectorAgent.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public void MoveAgent(ActionBuffers actionBuffers)
105105
dirToGo += transform.right * right;
106106
rotateDir = -transform.up * rotate;
107107

108-
var shootCommand = (int)discreteActions[0] > 0;
108+
var shootCommand = discreteActions[0] > 0;
109109
if (shootCommand)
110110
{
111111
m_Shoot = true;

Project/Assets/ML-Agents/Examples/Match3/Scripts/Match3Agent.cs

-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
using System;
22
using UnityEngine;
33
using Unity.MLAgents;
4-
using Unity.MLAgents.Actuators;
5-
using Unity.MLAgents.Integrations.Match3;
64

75
namespace Unity.MLAgentsExamples
86
{

Project/Assets/ML-Agents/Examples/PushBlock/Scripts/GoalDetectTrigger.cs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
using System.Collections;
2-
using System.Collections.Generic;
31
using UnityEngine;
42
using UnityEngine.Events;
53

Project/Assets/ML-Agents/Examples/PushBlock/Scripts/PushAgentCollab.cs

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
//Put this script on your blue cube.
2-
3-
using System.Collections;
42
using UnityEngine;
53
using Unity.MLAgents;
64
using Unity.MLAgents.Actuators;

Project/Assets/ML-Agents/Examples/PushBlockWithInput/Scripts/PushBlockWithInputAgentBasic.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
//Put this script on your blue cube.
2-
3-
using System;
42
using System.Collections;
53
using UnityEngine;
64
using Unity.MLAgents;
@@ -18,7 +16,7 @@ public class PushBlockWithInputAgentBasic : Agent
1816

1917
/// <summary>
2018
/// The area bounds.
21-
/// </summary'PushAgentBasic'>
19+
/// </summary>
2220
[HideInInspector]
2321
public Bounds areaBounds;
2422

Project/Assets/ML-Agents/Examples/SharedAssets/Scripts/CollisionCallbacks.cs

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
using UnityEngine;
2-
using Random = UnityEngine.Random;
3-
using Unity.MLAgents;
42
using UnityEngine.Events;
53

64
namespace Unity.MLAgentsExamples

Project/Assets/ML-Agents/Examples/Soccer/Scripts/SoccerEnvController.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System.Collections;
21
using System.Collections.Generic;
32
using Unity.MLAgents;
43
using UnityEngine;
@@ -91,7 +90,7 @@ public void ResetBall()
9190
var randomPosX = Random.Range(-2.5f, 2.5f);
9291
var randomPosZ = Random.Range(-2.5f, 2.5f);
9392

94-
ball.transform.position = m_BallStartingPos + new Vector3(randomPosX, 0f, randomPosZ); ;
93+
ball.transform.position = m_BallStartingPos + new Vector3(randomPosX, 0f, randomPosZ);
9594
ballRb.velocity = Vector3.zero;
9695
ballRb.angularVelocity = Vector3.zero;
9796

Project/Assets/ML-Agents/Examples/Sorter/Scripts/NumberTile.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
using System.Collections;
2-
using System.Collections.Generic;
31
using UnityEngine;
42

53
public class NumberTile : MonoBehaviour
@@ -8,7 +6,7 @@ public class NumberTile : MonoBehaviour
86
public Material DefaultMaterial;
97
public Material SuccessMaterial;
108

11-
private bool m_Visited = false;
9+
private bool m_Visited;
1210
private MeshRenderer m_Renderer;
1311

1412
public bool IsVisited

Project/Assets/ML-Agents/Examples/Sorter/Scripts/SorterAgent.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public override void CollectObservations(VectorSensor sensor)
8181
// Here, the observation for the tile is added to the BufferSensor
8282
m_BufferSensor.AppendObservation(listObservation);
8383

84-
};
84+
}
8585

8686
}
8787

Project/Assets/ML-Agents/Examples/Walker/Scripts/WalkerAgent.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,6 @@ void FixedUpdate()
261261
Vector3 GetAvgVelocity()
262262
{
263263
Vector3 velSum = Vector3.zero;
264-
Vector3 avgVel = Vector3.zero;
265264

266265
//ALL RBS
267266
int numOfRb = 0;
@@ -271,7 +270,7 @@ Vector3 GetAvgVelocity()
271270
velSum += item.rb.velocity;
272271
}
273272

274-
avgVel = velSum / numOfRb;
273+
var avgVel = velSum / numOfRb;
275274
return avgVel;
276275
}
277276

Project/Assets/ML-Agents/Examples/Worm/Scripts/WormAgent.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using UnityEngine;
22
using Unity.MLAgents;
3-
using Unity.Barracuda;
43
using Unity.MLAgents.Actuators;
54
using Unity.MLAgentsExamples;
65
using Unity.MLAgents.Sensors;

com.unity.ml-agents.extensions/Runtime/Input/Adaptors/ButtonInputActionAdaptor.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#if MLA_INPUT_SYSTEM
22
using Unity.MLAgents.Actuators;
3-
using UnityEngine;
43
using UnityEngine.InputSystem;
54
using UnityEngine.InputSystem.Controls;
65
using UnityEngine.InputSystem.LowLevel;

com.unity.ml-agents.extensions/Runtime/Input/Adaptors/Vector2InputActionAdaptor.cs

-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
#if MLA_INPUT_SYSTEM
2-
using System;
32
using Unity.MLAgents.Actuators;
43
using UnityEngine;
54
using UnityEngine.InputSystem;
6-
using UnityEngine.InputSystem.Controls;
75
using UnityEngine.InputSystem.LowLevel;
86

97
namespace Unity.MLAgents.Extensions.Input

com.unity.ml-agents.extensions/Runtime/Input/IRLActionInputAdaptor.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#if MLA_INPUT_SYSTEM
2-
using System;
32
using Unity.MLAgents.Actuators;
43
using UnityEngine.InputSystem;
54
using UnityEngine.InputSystem.LowLevel;

com.unity.ml-agents.extensions/Runtime/Input/InputActionActuator.cs

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
using Unity.MLAgents.Actuators;
44
using Unity.MLAgents.Policies;
5-
using UnityEngine;
65
using UnityEngine.InputSystem;
76
using UnityEngine.Profiling;
87

com.unity.ml-agents.extensions/Tests/Runtime/Input/Adaptors/IntegerInputActionAdaptorTests.cs

-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
#if MLA_INPUT_TESTS
2-
using System;
32
using NUnit.Framework;
43
using Unity.MLAgents.Actuators;
54
using Unity.MLAgents.Extensions.Input;
6-
using UnityEngine;
75
using UnityEngine.InputSystem;
86

97
namespace Unity.MLAgents.Extensions.Tests.Runtime.Input

com.unity.ml-agents.extensions/Tests/Runtime/Sensors/CountingGridSensorTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public void TestCountingSensor()
133133

134134
gridSensor.Update();
135135

136-
subarrayIndicies = new int[] { 77, 78, 87, 88 };
136+
subarrayIndicies = new[] { 77, 78, 87, 88 };
137137
expectedSubarrays = DuplicateArray(new float[] { 2, 0 }, 4);
138138
expectedDefault = new float[] { 0, 0 };
139139
AssertSubarraysAtIndex(gridSensor.PerceptionBuffer, subarrayIndicies, expectedSubarrays, expectedDefault);

com.unity.ml-agents.extensions/Tests/Runtime/Sensors/RigidBodySensorTests.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System.Runtime.CompilerServices;
21
using UnityEngine;
32
using NUnit.Framework;
43
using Unity.MLAgents.Sensors;

com.unity.ml-agents/Editor/DemonstrationDrawer.cs

-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
using System.Text;
33
using UnityEditor;
44
using Unity.MLAgents.Demonstrations;
5-
using Unity.MLAgents.Policies;
6-
75

86
namespace Unity.MLAgents.Editor
97
{

com.unity.ml-agents/Runtime/Actuators/ActionSpec.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System;
2-
using System.Collections.Generic;
32
using System.Linq;
43
using UnityEngine;
54

com.unity.ml-agents/Runtime/Actuators/ActuatorComponent.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System;
21
using UnityEngine;
32

43
namespace Unity.MLAgents.Actuators

com.unity.ml-agents/Runtime/Actuators/IDiscreteActionMask.cs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
using System.Collections.Generic;
2-
31
namespace Unity.MLAgents.Actuators
42
{
53
/// <summary>

com.unity.ml-agents/Runtime/Analytics/InferenceAnalytics.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ internal class InferenceAnalytics
3131
/// <summary>
3232
/// Whether or not we've registered this particular event yet
3333
/// </summary>
34-
static bool s_EventRegistered = false;
34+
static bool s_EventRegistered;
3535

3636
/// <summary>
3737
/// Hourly limit for this event name

com.unity.ml-agents/Runtime/Analytics/TrainingAnalytics.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ internal static class TrainingAnalytics
4747
/// <summary>
4848
/// Whether or not we've registered this particular event yet
4949
/// </summary>
50-
static bool s_EventsRegistered = false;
50+
static bool s_EventsRegistered;
5151

5252
/// <summary>
5353
/// Behaviors that we've already sent events for.

com.unity.ml-agents/Runtime/Communicator/GrpcExtensions.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ internal static class GrpcExtensions
2424
/// <summary>
2525
/// Static flag to make sure that we only fire the warning once.
2626
/// </summary>
27-
private static bool s_HaveWarnedTrainerCapabilitiesAgentGroup = false;
27+
private static bool s_HaveWarnedTrainerCapabilitiesAgentGroup;
2828

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

332332
/// <summary>
333333
/// Generate an ObservationProto for the sensor using the provided ObservationWriter.

com.unity.ml-agents/Runtime/DecisionRequester.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace Unity.MLAgents
1414
///
1515
/// The DecisionRequester component provides a convenient and flexible way to
1616
/// trigger the agent decision making process. Without a DecisionRequester,
17-
/// your <see cref="Agent"/> implmentation must manually call its
17+
/// your <see cref="Agent"/> implementation must manually call its
1818
/// <seealso cref="Agent.RequestDecision"/> function.
1919
/// </remarks>
2020
[AddComponentMenu("ML Agents/Decision Requester", (int)MenuGroup.Default)]

com.unity.ml-agents/Runtime/Inference/BarracudaModelExtensions.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,7 @@ public static bool HasDiscreteOutputs(this Model model)
226226
}
227227
else
228228
{
229-
return model.outputs.Contains(TensorNames.DiscreteActionOutput) &&
230-
(int)model.DiscreteOutputSize() > 0;
229+
return model.outputs.Contains(TensorNames.DiscreteActionOutput) && model.DiscreteOutputSize() > 0;
231230
}
232231
}
233232

com.unity.ml-agents/Runtime/Inference/GeneratorImpl.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System.Collections.Generic;
22
using System;
3-
using UnityEngine;
43
using Unity.Barracuda;
54
using Unity.MLAgents.Inference.Utils;
65
using Unity.MLAgents.Sensors;

com.unity.ml-agents/Runtime/Inference/ModelRunner.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System;
21
using System.Collections.Generic;
32
using Unity.Barracuda;
43
using UnityEngine.Profiling;

com.unity.ml-agents/Runtime/InplaceArray.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ public InplaceArray(T elem0)
2929
{
3030
m_Length = 1;
3131
m_Elem0 = elem0;
32-
m_Elem1 = new T { };
33-
m_Elem2 = new T { };
34-
m_Elem3 = new T { };
32+
m_Elem1 = new T();
33+
m_Elem2 = new T();
34+
m_Elem3 = new T();
3535
}
3636

3737
/// <summary>
@@ -44,8 +44,8 @@ public InplaceArray(T elem0, T elem1)
4444
m_Length = 2;
4545
m_Elem0 = elem0;
4646
m_Elem1 = elem1;
47-
m_Elem2 = new T { };
48-
m_Elem3 = new T { };
47+
m_Elem2 = new T();
48+
m_Elem3 = new T();
4949
}
5050

5151
/// <summary>
@@ -60,7 +60,7 @@ public InplaceArray(T elem0, T elem1, T elem2)
6060
m_Elem0 = elem0;
6161
m_Elem1 = elem1;
6262
m_Elem2 = elem2;
63-
m_Elem3 = new T { };
63+
m_Elem3 = new T();
6464
}
6565

6666
/// <summary>

com.unity.ml-agents/Runtime/Integrations/Match3/Move.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public static Move FromMoveIndex(int moveIndex, BoardSize maxBoardSize)
7575

7676
if (moveIndex < 0 || moveIndex >= NumPotentialMoves(maxBoardSize))
7777
{
78-
throw new ArgumentOutOfRangeException("Invalid move index.");
78+
throw new ArgumentOutOfRangeException("moveIndex");
7979
}
8080
Direction dir;
8181
int row, col;

com.unity.ml-agents/Runtime/MLAgentsSettingsManager.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
using System;
2-
using System.Linq;
32
using UnityEngine;
43
#if UNITY_EDITOR
54
using UnityEditor;
5+
#else
6+
using System.Linq;
67
#endif
78

89
namespace Unity.MLAgents

com.unity.ml-agents/Runtime/MultiAgentGroupIdCounter.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ internal static class MultiAgentGroupIdCounter
77
static int s_Counter;
88
public static int GetGroupId()
99
{
10-
return Interlocked.Increment(ref s_Counter); ;
10+
return Interlocked.Increment(ref s_Counter);
1111
}
1212
}
1313
}

com.unity.ml-agents/Runtime/Policies/HeuristicPolicy.cs

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ internal class HeuristicPolicy : IPolicy
2222
NullList m_NullList = new NullList();
2323

2424

25-
/// <inheritdoc />
2625
public HeuristicPolicy(ActuatorManager actuatorManager, ActionSpec actionSpec)
2726
{
2827
m_ActuatorManager = actuatorManager;

com.unity.ml-agents/Runtime/Policies/RemotePolicy.cs

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ internal class RemotePolicy : IPolicy
2626
/// </summary>
2727
private IList<IActuator> m_Actuators;
2828

29-
/// <inheritdoc />
3029
public RemotePolicy(
3130
ActionSpec actionSpec,
3231
IList<IActuator> actuators,

com.unity.ml-agents/Runtime/Sensors/BoxOverlapChecker.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ void InitCellLocalPositions()
8383

8484
/// <summary>Converts the index of the cell to the 3D point (y is zero) relative to grid center</summary>
8585
/// <returns>Vector3 of the position of the center of the cell relative to grid center</returns>
86-
/// <param name="cell">The index of the cell</param>
86+
/// <param name="cellIndex">The index of the cell</param>
8787
Vector3 GetCellLocalPosition(int cellIndex)
8888
{
8989
float x = (cellIndex / m_GridSize.z - m_CellCenterOffset.x) * m_CellScale.x;

com.unity.ml-agents/Runtime/Sensors/GridSensorComponent.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
namespace Unity.MLAgents.Sensors
55
{
66
/// <summary>
7-
/// A SensorComponent that creates a <see cref="GridSensor"/>.
7+
/// A SensorComponent that creates a <see cref="GridSensorBase"/>.
88
/// </summary>
99
[AddComponentMenu("ML Agents/Grid Sensor", (int)MenuGroup.Sensors)]
1010
public class GridSensorComponent : SensorComponent

0 commit comments

Comments
 (0)