-
Notifications
You must be signed in to change notification settings - Fork 157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Kore-2022 Java interpreter errors when wrapping #192
Comments
Nevermind, bad test :D Fixed with (incase you want to add the test...): Point p1 = new Point(x, board.size - 1); |
Reopened as the problem does exist when wrapping to the south. @Test
public void fleetWrapsAroundTheBoard_southNorth() throws IOException {
Board board = getStarterBoard();
int x = board.size / 2;
int playerId = 0;
Point p1 = new Point(x, 0);
Fleet f1 = new Fleet("f1", 50, Direction.SOUTH, p1, 100.0, "S", playerId, board);
final String f1Id = f1.id;
board.addFleet(f1);
Board nextBoard = board.next();
Player player0 = nextBoard.players[playerId];
Fleet nextF1 = List.of(player0.fleets()).stream().filter(fleet -> fleet.id == f1Id).findFirst().get();
Assert.assertEquals("position.x should not change when wrapping south -> north", nextF1.position.x, x);
Assert.assertEquals("position.y should wrap to board.size - 1", nextF1.position.y, board.size - 1);
}
|
I think I fixed this here: kaggle-environments/kaggle_environments/envs/kore_fleets/starter_bots/java/kore/Point.java Line 20 in ec90612
with: return new Point(Math.floorMod(this.x, size), Math.floorMod(this.y, size)); Validated with these tests: @Test
public void translate_wrapsNorthToSouth() {
int size = 31;
int x = 10;
Point point = new Point(x, 0);
Point offset = new Point(0, -1);
Point nextPoint = point.translate(offset, size);
Assert.assertEquals("y should wrap to the top", size - 1, nextPoint.y);
Assert.assertEquals("There should be no change in x", x, nextPoint.x);
}
@Test
public void translate_wrapsSouthToNorth() {
int size = 31;
int x = 10;
Point point = new Point(x, size - 1);
Point offset = new Point(0, 1);
Point nextPoint = point.translate(offset, size);
Assert.assertEquals("y should wrap to the bottom", 0, nextPoint.y);
Assert.assertEquals("There should be no change in x", x, nextPoint.x);
} |
I found a similar issue in TS starter and fixed it in this PR: |
I think I've found a bug when using the Board::next() function when there is a fleet on the edge of the map.
Below is a test I wrote to reproduce, looks like the code that handles positions / indexes is not quite right. I might have a play and see if I can find the bug. Help appreciated though, this would be the nail in the coffin of my java based approach :(
The text was updated successfully, but these errors were encountered: