Skip to content

Commit

Permalink
Fix IsBot always being false
Browse files Browse the repository at this point in the history
Fix unit ball pred unit test
Add more to player mapping test to prevent regression
  • Loading branch information
VirxEC committed Jul 12, 2024
1 parent 9c9a0b2 commit 4ff6a55
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion RLBotCS/Conversion/GameStateToFlat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ ICollisionShape.Cylinder cylinderShape
DodgeTimeout = car.DodgeTimeout,
DemolishedTimeout = car.DemolishedTimeout,
IsSupersonic = car.IsSuperSonic,
IsBot = car.IsBot,
IsBot = car.IsCustomBot,
Name = car.Name,
Team = car.Team,
Boost = (uint)Math.Floor(car.Boost),
Expand Down
4 changes: 3 additions & 1 deletion RLBotCS/Server/BridgeMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public void HandleMessage(BridgeContext context)
CommandId = 0,
SpawnId = PlayerConfig.SpawnId,
DesiredPlayerIndex = DesiredIndex,
IsBot = false,
IsCustomBot = false
}
);
Expand Down Expand Up @@ -84,7 +85,8 @@ public void HandleMessage(BridgeContext context)
CommandId = commandId,
SpawnId = config.SpawnId,
DesiredPlayerIndex = DesiredIndex,
IsCustomBot = IsCustomBot
IsCustomBot = IsCustomBot,
IsBot = true
}
);
}
Expand Down
Binary file modified RLBotCS/lib/Bridge.dll
Binary file not shown.
4 changes: 2 additions & 2 deletions RLBotCSTests/BallPrediction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ public void TestBallPred()

var ballPred = BallPredictor.Generate(PredictionMode.Standard, 1, packet.Balls[12345]);

int numSlices = 8 * 120;
int numSlices = 6 * 120;
Assert.AreEqual(numSlices, ballPred.Slices.Count);
Assert.IsTrue(ballPred.Slices[numSlices - 1].GameSeconds > 8.9999);
Assert.IsTrue(ballPred.Slices[numSlices - 1].GameSeconds > 5.9999);

// comment out to see results of the below test
// dotnet test -c "Release" for best results
Expand Down
11 changes: 7 additions & 4 deletions RLBotCSTests/PlayerMappingTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,24 @@ public void TestSpawnProcess()
SpawnId = spawnId,
CommandId = commandId,
DesiredPlayerIndex = desiredIndex,
IsCustomBot = true
IsBot = true
};

_playerMapping.AddPendingSpawn(spawnTracker);

var carSpawn = new CarSpawn() { ActorId = actorId, CommandId = commandId, };
_playerMapping.ApplyCarSpawn(carSpawn);
var metadata = _playerMapping.ApplyCarSpawn(carSpawn);

Assert.AreEqual(desiredIndex, _playerMapping.PlayerIndexFromActorId(actorId));
Assert.IsTrue(metadata.IsBot);
Assert.IsTrue(!metadata.IsCustomBot);

_playerMapping.ApplyCarSpawn(new CarSpawn() { ActorId = 111, CommandId = 222, });
var metadata2 = _playerMapping.ApplyCarSpawn(new CarSpawn() { ActorId = 111, CommandId = 222, });

Assert.AreEqual(0u, _playerMapping.PlayerIndexFromActorId(111));
Assert.AreEqual(desiredIndex, _playerMapping.PlayerIndexFromActorId(actorId));
Console.Write("Good");
Assert.IsTrue(!metadata2.IsBot);
Assert.IsTrue(!metadata2.IsCustomBot);
}
}
}

0 comments on commit 4ff6a55

Please sign in to comment.