Skip to content

Commit

Permalink
Bug-368: Issues with sentries + implementation of ideas.
Browse files Browse the repository at this point in the history
  • Loading branch information
flemming-n-larsen committed Feb 26, 2014
1 parent 94304ea commit 29b03ee
Show file tree
Hide file tree
Showing 40 changed files with 274 additions and 124 deletions.
Expand Up @@ -108,12 +108,12 @@ public static void Update(Bullet bullet, double x, double y, string victimName,
public static RobotStatus createStatus(double energy, double x, double y, double bodyHeading, double gunHeading,
double radarHeading, double velocity, double bodyTurnRemaining,
double radarTurnRemaining, double gunTurnRemaining,
double distanceRemaining, double gunHeat, int others, int roundNum,
int numRounds, long time)
double distanceRemaining, double gunHeat, int others, int numSentries,
int roundNum, int numRounds, long time)
{
return statusHelper.createStatus(energy, x, y, bodyHeading, gunHeading, radarHeading, velocity,
bodyTurnRemaining, radarTurnRemaining, gunTurnRemaining, distanceRemaining,
gunHeat, others, roundNum, numRounds, time);
gunHeat, others, numSentries, roundNum, numRounds, time);
}

public static BattleRules createRules(int battlefieldWidth, int battlefieldHeight, int numRounds, double gunCoolingRate, long inactivityTime,
Expand Down
Expand Up @@ -20,8 +20,8 @@ public interface IHiddenStatusHelper
double radarHeading,
double velocity, double bodyTurnRemaining, double radarTurnRemaining,
double gunTurnRemaining,
double distanceRemaining, double gunHeat, int others, int roundNum, int numRounds,
long time);
double distanceRemaining, double gunHeat, int others, int numSentries,
int roundNum, int numRounds, long time);
}
}

Expand Down
Expand Up @@ -158,7 +158,7 @@
<PropertyGroup>
<PostBuildEvent>copy "$(TargetPath)" "$(SolutionDir)\robocode.dotnet.host\target"</PostBuildEvent>
<PreBuildEvent>if not exist $(OutDir)\build-sources\generated-sources\META-INF mkdir $(OutDir)\build-sources\generated-sources\META-INF\
echo [assembly: System.Reflection.AssemblyVersion("1.9.0.0")] &gt; $(OutDir)\build-sources\generated-sources\META-INF\AssemblyInfo.cs
echo [assembly: System.Reflection.AssemblyVersion("1.9.1.0")] &gt; $(OutDir)\build-sources\generated-sources\META-INF\AssemblyInfo.cs
</PreBuildEvent>
</PropertyGroup>
</Project>
16 changes: 16 additions & 0 deletions plugins/dotnet/robocode.dotnet.api/src/robocode/Robot.cs
Expand Up @@ -735,6 +735,22 @@ public int Others
}
}

/// <summary>
/// Returns how many sentry robots that are left in the current round.
/// </summary>
public int NumSentries
{
get
{
if (peer != null)
{
return peer.GetNumSentries();
}
UninitializedException();
return 0; // never called
}
}

/// <summary>
/// Returns the direction that the robot's radar is facing, in degrees.
/// The value returned will be between 0 and 360 (is excluded).
Expand Down
24 changes: 19 additions & 5 deletions plugins/dotnet/robocode.dotnet.api/src/robocode/RobotStatus.cs
Expand Up @@ -36,6 +36,7 @@ public sealed class RobotStatus
private readonly double distanceRemaining;
private readonly double gunHeat;
private readonly int others;
private readonly int numSentries;
private readonly int roundNum;
private readonly int numRounds;
private readonly long time;
Expand Down Expand Up @@ -265,6 +266,14 @@ public int Others
get { return others; }
}

/// <summary>
/// Returns how many sentry robots that are left in the current round.
/// </summary>
public int NumSentries
{
get { return numSentries; }
}

/// <summary>
/// Returns the number of rounds in the current battle.
/// </summary>
Expand Down Expand Up @@ -296,7 +305,9 @@ public long Time
double radarHeading,
double velocity, double bodyTurnRemaining, double radarTurnRemaining,
double gunTurnRemaining,
double distanceRemaining, double gunHeat, int others, int roundNum, int numRounds, long time)
double distanceRemaining, double gunHeat,
int others, int numSentries,
int roundNum, int numRounds, long time)
{
this.energy = energy;
this.x = x;
Expand All @@ -311,6 +322,7 @@ public long Time
this.distanceRemaining = distanceRemaining;
this.gunHeat = gunHeat;
this.others = others;
this.numSentries = numSentries;
this.roundNum = roundNum;
this.numRounds = numRounds;
this.time = time;
Expand All @@ -325,7 +337,7 @@ private class SerializableHelper : ISerializableHelperN, IHiddenStatusHelper
{
public int sizeOf(RbSerializerN serializer, object objec)
{
return RbSerializerN.SIZEOF_TYPEINFO + 12*RbSerializerN.SIZEOF_DOUBLE + 3*RbSerializerN.SIZEOF_INT
return RbSerializerN.SIZEOF_TYPEINFO + 12*RbSerializerN.SIZEOF_DOUBLE + 4*RbSerializerN.SIZEOF_INT
+ RbSerializerN.SIZEOF_LONG;
}

Expand All @@ -346,6 +358,7 @@ public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec)
serializer.serialize(buffer, obj.distanceRemaining);
serializer.serialize(buffer, obj.gunHeat);
serializer.serialize(buffer, obj.others);
serializer.serialize(buffer, obj.numSentries);
serializer.serialize(buffer, obj.roundNum);
serializer.serialize(buffer, obj.numRounds);
serializer.serialize(buffer, obj.time);
Expand All @@ -366,22 +379,23 @@ public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
double distanceRemaining = buffer.getDouble();
double gunHeat = buffer.getDouble();
int others = buffer.getInt();
int numSentries = buffer.getInt();
int roundNum = buffer.getInt();
int numRounds = buffer.getInt();
long time = buffer.getLong();

return new RobotStatus(energy, x, y, bodyHeading, gunHeading, radarHeading, velocity, bodyTurnRemaining,
radarTurnRemaining, gunTurnRemaining, distanceRemaining, gunHeat, others,
radarTurnRemaining, gunTurnRemaining, distanceRemaining, gunHeat, others, numSentries,
roundNum, numRounds, time);
}

public RobotStatus createStatus(double energy, double x, double y, double bodyHeading, double gunHeading,
double radarHeading, double velocity, double bodyTurnRemaining,
double radarTurnRemaining, double gunTurnRemaining, double distanceRemaining,
double gunHeat, int others, int roundNum, int numRounds, long time)
double gunHeat, int others, int numSentries, int roundNum, int numRounds, long time)
{
return new RobotStatus(energy, x, y, bodyHeading, gunHeading, radarHeading, velocity, bodyTurnRemaining,
radarTurnRemaining, gunTurnRemaining, distanceRemaining, gunHeat, others,
radarTurnRemaining, gunTurnRemaining, distanceRemaining, gunHeat, others, numSentries,
roundNum, numRounds, time);
}
}
Expand Down
Expand Up @@ -133,6 +133,11 @@ public interface IBasicRobotPeer
/// </summary>
int GetOthers();

/// <summary>
/// Returns how many sentry robots that are left in the current round.
/// </summary>
int GetNumSentries();

/// <summary>
/// Returns the number of rounds in the current battle.
/// <seealso cref="GetRoundNum"/>
Expand Down
6 changes: 3 additions & 3 deletions plugins/dotnet/robocode.dotnet.content/.classpath
Expand Up @@ -4,10 +4,10 @@
<classpathentry kind="output" path="target/classes"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="src" path="/robocode.dotnet.host"/>
<classpathentry kind="var" path="M2_REPO/net/sf/robocode/robocode.host/1.9.0.0/robocode.host-1.9.0.0.jar"/>
<classpathentry kind="var" path="M2_REPO/net/sf/robocode/robocode.core/1.9.0.0/robocode.core-1.9.0.0.jar"/>
<classpathentry kind="var" path="M2_REPO/net/sf/robocode/robocode.host/1.9.1.0/robocode.host-1.9.1.0.jar"/>
<classpathentry kind="var" path="M2_REPO/net/sf/robocode/robocode.core/1.9.1.0/robocode.core-1.9.1.0.jar"/>
<classpathentry kind="var" path="M2_REPO/org/picocontainer/picocontainer/2.14.2/picocontainer-2.14.2.jar"/>
<classpathentry kind="var" path="M2_REPO/net/sf/robocode/robocode.repository/1.9.0.0/robocode.repository-1.9.0.0.jar"/>
<classpathentry kind="var" path="M2_REPO/net/sf/robocode/robocode.repository/1.9.1.0/robocode.repository-1.9.1.0.jar"/>
<classpathentry kind="var" path="M2_REPO/net/sf/robocode/codesize/1.1/codesize-1.1.jar"/>
<classpathentry kind="var" path="M2_REPO/net/sf/jni4net/jni4net.j/0.8.6.0/jni4net.j-0.8.6.0.jar"/>
</classpath>
Expand Up @@ -49,14 +49,14 @@ under the License.
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://C:/Users/Flemming.Flemming-PC/.m2/repository/net/sf/robocode/robocode.host/1.9.0.0/robocode.host-1.9.0.0.jar!/"/>
<root url="jar://C:/Users/Flemming.Flemming-PC/.m2/repository/net/sf/robocode/robocode.host/1.9.1.0/robocode.host-1.9.1.0.jar!/"/>
</CLASSES>
</library>
</orderEntry>
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://C:/Users/Flemming.Flemming-PC/.m2/repository/net/sf/robocode/robocode.core/1.9.0.0/robocode.core-1.9.0.0.jar!/"/>
<root url="jar://C:/Users/Flemming.Flemming-PC/.m2/repository/net/sf/robocode/robocode.core/1.9.1.0/robocode.core-1.9.1.0.jar!/"/>
</CLASSES>
</library>
</orderEntry>
Expand All @@ -70,7 +70,7 @@ under the License.
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://C:/Users/Flemming.Flemming-PC/.m2/repository/net/sf/robocode/robocode.repository/1.9.0.0/robocode.repository-1.9.0.0.jar!/"/>
<root url="jar://C:/Users/Flemming.Flemming-PC/.m2/repository/net/sf/robocode/robocode.repository/1.9.1.0/robocode.repository-1.9.1.0.jar!/"/>
</CLASSES>
</library>
</orderEntry>
Expand Down
Expand Up @@ -40,11 +40,11 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\robocode\libs\jni4net.n-0.8.6.0.dll</HintPath>
</Reference>
<Reference Include="robocode, Version=1.9.0.0, Culture=neutral, PublicKeyToken=43c1c8ae0e25a953, processorArchitecture=MSIL">
<Reference Include="robocode, Version=1.9.1.0, Culture=neutral, PublicKeyToken=43c1c8ae0e25a953, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\robocode\libs\robocode.dll</HintPath>
</Reference>
<Reference Include="robocode.control, Version=1.9.0.0, Culture=neutral, PublicKeyToken=43c1c8ae0e25a953, processorArchitecture=MSIL">
<Reference Include="robocode.control, Version=1.9.1.0, Culture=neutral, PublicKeyToken=43c1c8ae0e25a953, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\robocode\libs\robocode.control.dll</HintPath>
</Reference>
Expand Down
Expand Up @@ -8,7 +8,7 @@
<ProjectGuid>{80857B97-6397-487B-A9F5-B07026DCB666}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>SampleCs</RootNamespace>
<AssemblyName>samplescs-1.9.0.0</AssemblyName>
<AssemblyName>samplescs-1.9.1.0</AssemblyName>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkSubset>
Expand Down Expand Up @@ -38,7 +38,7 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Reference Include="robocode, Version=1.9.0.0, Culture=neutral, PublicKeyToken=e58e8a3c73c4b22d, processorArchitecture=MSIL">
<Reference Include="robocode, Version=1.9.1.0, Culture=neutral, PublicKeyToken=e58e8a3c73c4b22d, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\libs\robocode.dll</HintPath>
<Private>False</Private>
Expand Down
Expand Up @@ -188,7 +188,7 @@
-->
<PropertyGroup>
<PreBuildEvent>if not exist $(OutDir)\build-sources\generated-sources\META-INF mkdir $(OutDir)\build-sources\generated-sources\META-INF\
echo [assembly: System.Reflection.AssemblyVersion("1.9.0.0")] &gt; $(OutDir)\build-sources\generated-sources\META-INF\AssemblyInfo.cs
echo [assembly: System.Reflection.AssemblyVersion("1.9.1.0")] &gt; $(OutDir)\build-sources\generated-sources\META-INF\AssemblyInfo.cs
</PreBuildEvent>
<PostBuildEvent>copy "$(TargetPath)" "$(SolutionDir)\robocode.dotnet.host\target"
copy "$(SolutionDir)\tools\lib\*.dll" "$(TargetDir)"
Expand Down
6 changes: 3 additions & 3 deletions plugins/dotnet/robocode.dotnet.distribution/.classpath
Expand Up @@ -5,10 +5,10 @@
<classpathentry kind="src" path="/robocode.dotnet.installer"/>
<classpathentry kind="src" path="/robocode.dotnet.content"/>
<classpathentry kind="src" path="/robocode.dotnet.host"/>
<classpathentry kind="var" path="M2_REPO/net/sf/robocode/robocode.host/1.9.0.0/robocode.host-1.9.0.0.jar"/>
<classpathentry kind="var" path="M2_REPO/net/sf/robocode/robocode.core/1.9.0.0/robocode.core-1.9.0.0.jar"/>
<classpathentry kind="var" path="M2_REPO/net/sf/robocode/robocode.host/1.9.1.0/robocode.host-1.9.1.0.jar"/>
<classpathentry kind="var" path="M2_REPO/net/sf/robocode/robocode.core/1.9.1.0/robocode.core-1.9.1.0.jar"/>
<classpathentry kind="var" path="M2_REPO/org/picocontainer/picocontainer/2.14.2/picocontainer-2.14.2.jar"/>
<classpathentry kind="var" path="M2_REPO/net/sf/robocode/robocode.repository/1.9.0.0/robocode.repository-1.9.0.0.jar"/>
<classpathentry kind="var" path="M2_REPO/net/sf/robocode/robocode.repository/1.9.1.0/robocode.repository-1.9.1.0.jar"/>
<classpathentry kind="var" path="M2_REPO/net/sf/robocode/codesize/1.1/codesize-1.1.jar"/>
<classpathentry kind="var" path="M2_REPO/net/sf/jni4net/jni4net.j/0.8.6.0/jni4net.j-0.8.6.0.jar"/>
</classpath>
Expand Up @@ -58,14 +58,14 @@ under the License.
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://C:/Users/Flemming.Flemming-PC/.m2/repository/net/sf/robocode/robocode.host/1.9.0.0/robocode.host-1.9.0.0.jar!/"/>
<root url="jar://C:/Users/Flemming.Flemming-PC/.m2/repository/net/sf/robocode/robocode.host/1.9.1.0/robocode.host-1.9.1.0.jar!/"/>
</CLASSES>
</library>
</orderEntry>
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://C:/Users/Flemming.Flemming-PC/.m2/repository/net/sf/robocode/robocode.core/1.9.0.0/robocode.core-1.9.0.0.jar!/"/>
<root url="jar://C:/Users/Flemming.Flemming-PC/.m2/repository/net/sf/robocode/robocode.core/1.9.1.0/robocode.core-1.9.1.0.jar!/"/>
</CLASSES>
</library>
</orderEntry>
Expand All @@ -79,7 +79,7 @@ under the License.
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://C:/Users/Flemming.Flemming-PC/.m2/repository/net/sf/robocode/robocode.repository/1.9.0.0/robocode.repository-1.9.0.0.jar!/"/>
<root url="jar://C:/Users/Flemming.Flemming-PC/.m2/repository/net/sf/robocode/robocode.repository/1.9.1.0/robocode.repository-1.9.1.0.jar!/"/>
</CLASSES>
</library>
</orderEntry>
Expand Down
8 changes: 4 additions & 4 deletions plugins/dotnet/robocode.dotnet.host/.classpath
Expand Up @@ -4,11 +4,11 @@
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="output" path="target/classes"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="var" path="M2_REPO/net/sf/robocode/robocode.host/1.9.0.0/robocode.host-1.9.0.0.jar"/>
<classpathentry kind="var" path="M2_REPO/net/sf/robocode/robocode.api/1.9.0.0/robocode.api-1.9.0.0.jar"/>
<classpathentry kind="var" path="M2_REPO/net/sf/robocode/robocode.core/1.9.0.0/robocode.core-1.9.0.0.jar"/>
<classpathentry kind="var" path="M2_REPO/net/sf/robocode/robocode.host/1.9.1.0/robocode.host-1.9.1.0.jar"/>
<classpathentry kind="var" path="M2_REPO/net/sf/robocode/robocode.api/1.9.1.0/robocode.api-1.9.1.0.jar"/>
<classpathentry kind="var" path="M2_REPO/net/sf/robocode/robocode.core/1.9.1.0/robocode.core-1.9.1.0.jar"/>
<classpathentry kind="var" path="M2_REPO/org/picocontainer/picocontainer/2.14.2/picocontainer-2.14.2.jar"/>
<classpathentry kind="var" path="M2_REPO/net/sf/robocode/robocode.repository/1.9.0.0/robocode.repository-1.9.0.0.jar"/>
<classpathentry kind="var" path="M2_REPO/net/sf/robocode/robocode.repository/1.9.1.0/robocode.repository-1.9.1.0.jar"/>
<classpathentry kind="var" path="M2_REPO/net/sf/robocode/codesize/1.1/codesize-1.1.jar"/>
<classpathentry kind="var" path="M2_REPO/net/sf/jni4net/jni4net.j/0.8.6.0/jni4net.j-0.8.6.0.jar"/>
<classpathentry kind="var" path="M2_REPO/junit/junit/4.11/junit-4.11.jar"/>
Expand Down
8 changes: 4 additions & 4 deletions plugins/dotnet/robocode.dotnet.host/robocode.dotnet.host.iml
Expand Up @@ -95,21 +95,21 @@ under the License.
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://C:/Users/Flemming.Flemming-PC/.m2/repository/net/sf/robocode/robocode.host/1.9.0.0/robocode.host-1.9.0.0.jar!/"/>
<root url="jar://C:/Users/Flemming.Flemming-PC/.m2/repository/net/sf/robocode/robocode.host/1.9.1.0/robocode.host-1.9.1.0.jar!/"/>
</CLASSES>
</library>
</orderEntry>
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://C:/Users/Flemming.Flemming-PC/.m2/repository/net/sf/robocode/robocode.api/1.9.0.0/robocode.api-1.9.0.0.jar!/"/>
<root url="jar://C:/Users/Flemming.Flemming-PC/.m2/repository/net/sf/robocode/robocode.api/1.9.1.0/robocode.api-1.9.1.0.jar!/"/>
</CLASSES>
</library>
</orderEntry>
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://C:/Users/Flemming.Flemming-PC/.m2/repository/net/sf/robocode/robocode.core/1.9.0.0/robocode.core-1.9.0.0.jar!/"/>
<root url="jar://C:/Users/Flemming.Flemming-PC/.m2/repository/net/sf/robocode/robocode.core/1.9.1.0/robocode.core-1.9.1.0.jar!/"/>
</CLASSES>
</library>
</orderEntry>
Expand Down Expand Up @@ -137,7 +137,7 @@ under the License.
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://C:/Users/Flemming.Flemming-PC/.m2/repository/net/sf/robocode/robocode.repository/1.9.0.0/robocode.repository-1.9.0.0.jar!/"/>
<root url="jar://C:/Users/Flemming.Flemming-PC/.m2/repository/net/sf/robocode/robocode.repository/1.9.1.0/robocode.repository-1.9.1.0.jar!/"/>
</CLASSES>
</library>
</orderEntry>
Expand Down

0 comments on commit 29b03ee

Please sign in to comment.