|
@@ -85,31 +85,8 @@ func (game *Game) onRobot(robot Robot) bool {
|
|
|
return found
|
|
return found
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// TODO: improve this
|
|
|
|
|
func (game *Game) deleteRobot(robot Robot) {
|
|
func (game *Game) deleteRobot(robot Robot) {
|
|
|
|
|
|
|
|
- // The following would work, if it wasn't for the fact you are iterating through an array,
|
|
|
|
|
- // and deleting elements form that same array. So deleting item #15 isn't going to work
|
|
|
|
|
- // when the array has been reduced to 13 elements.
|
|
|
|
|
- // if robot < len(game.robots) {
|
|
|
|
|
- // game.robots = append(game.robots[:robot], game.robots[robot+1:]...)
|
|
|
|
|
- // }
|
|
|
|
|
-
|
|
|
|
|
- // This isn't going to work for the same reason,
|
|
|
|
|
- // and it adds the issue that random robots will get deleted.
|
|
|
|
|
- // var rowboz []Position
|
|
|
|
|
-
|
|
|
|
|
- // for i, r := range game.robots {
|
|
|
|
|
- // if robot != i {
|
|
|
|
|
- // rowboz = append(rowboz, r)
|
|
|
|
|
- // }
|
|
|
|
|
- // }
|
|
|
|
|
-
|
|
|
|
|
- // game.robots = nil
|
|
|
|
|
- // game.robots = rowboz
|
|
|
|
|
-
|
|
|
|
|
- // Conclusion: I need to find a different way to do this properly while iterating to that same array.
|
|
|
|
|
-
|
|
|
|
|
var rowboz []Robot
|
|
var rowboz []Robot
|
|
|
|
|
|
|
|
for _, r := range game.robots {
|
|
for _, r := range game.robots {
|