I was doing the spring-challenge-2023-ants to learn groovy and got really weird bug.
doing absolutely nothing to my code and relaunching the tests make it work sometime (even using the same seed), the errors messages are truncated (obviously the interesting part is missing out) and sometime the program seem to just hang in the middle of nowhere…
I saw there was timeout issue last year (I didn’t get timeout notification when trying) is groovy still bugged out ?
(for reference the code I use, i only added a Cell class to the starter code:)
input = new Scanner(System.in);
class Cell {
int index
int type
int initialResources
int[] neighbours
String toString() {
"[$index : $initialResources : $type]"
}
}
def cells = []
numberOfCells = input.nextInt() // amount of hexagonal cells in this map
for (i = 0; i < numberOfCells; ++i) {
type = input.nextInt() // 0 for empty, 1 for eggs, 2 for crystal
initialResources = input.nextInt() // the initial amount of eggs/crystals on this cell
neigh0 = input.nextInt() // the index of the neighbouring cell for each direction
neigh1 = input.nextInt()
neigh2 = input.nextInt()
neigh3 = input.nextInt()
neigh4 = input.nextInt()
neigh5 = input.nextInt()
def cell = new Cell().tap {
index = i
type = type
initialResources = initialResources
neighbours = [neigh0, neigh1, neigh2, neigh3, neigh4, neigh5]
}
System.err.println("$cell")
cells << cell
}
numberOfBases = input.nextInt()
for (i = 0; i < numberOfBases; ++i) {
myBaseIndex = input.nextInt()
}
for (i = 0; i < numberOfBases; ++i) {
oppBaseIndex = input.nextInt()
}
// game loop
while (true) {
for (i = 0; i < numberOfCells; ++i) {
resources = input.nextInt() // the current amount of eggs/crystals on this cell
myAnts = input.nextInt() // the amount of your ants on this cell
oppAnts = input.nextInt() // the amount of opponent ants on this cell
}
// Write an action using println
// To debug: System.err << "Debug messages...\n"
// WAIT | LINE <sourceIdx> <targetIdx> <strength> | BEACON <cellIdx> <strength> | MESSAGE <text>
println "WAIT"
}
using the seed
seed=-2577043716117712000