Hi I started doing this puzzle and am having a lot of fun, but I can’t seem to scan the opponents robots items.
My code for scanning the characters:
myRobots, opponentRobots, radars, traps := []entity{}, []entity{}, []entity{}, []entity{}
for i := 0; i < entityCount; i++ {
// entityId: unique id of the entity
// entityType: 0 for your robot, 1 for other robot, 2 for radar, 3 for trap
// y: position of the entity
// item: if this entity is a robot, the item it is carrying (-1 for NONE, 2 for RADAR, 3 for TRAP, 4 for ORE)
var entityId, entityType, x, y, item int
scanner.Scan()
fmt.Sscan(scanner.Text(), &entityId, &entityType, &x, &y, &item)
if entityType == 0 {
myRobots = append(myRobots, entity{entityId, entityType, x, y, item})
} else if entityType == 1 {
opponentRobots = append(opponentRobots, entity{entityId, entityType, x, y, item})
} else if entityType == 2 {
radars = append(radars, entity{entityId, entityType, x, y, item})
} else if entityType == 3 {
traps = append(traps, entity{entityId, entityType, x, y, item})
}
}
I use a struct to store all the characters:
type entity struct {
entityId, entityType, x, y, item int
}
I know what items my robots are carrying, but I don’t know what my opponents robots are carrying. Could someone show me what I am doing wrong?
Thanks