Stuck attempting to advance my code!

Hey guys just a little help required, I’ve been stuck developing my code recently and I am not sure what is causing a crash at round 2, but here is the error spots.

Removing defense from certain locations for attack path.

    remove_block = [[27, 13], [26, 13]]
    if (game_state.get_resource(game_state.BITS, 0) >= 9):
        gamelib.game_state.GameState.attempt_remove(
            self, locations=[[27, 13], [26, 13]])
        return

Rebuild broken filters into destructors.

    activate_list = [[0, 13], [1, 13], [2, 13], [
        3, 12], [4, 11], [5, 10], [6, 9], [22, 10], [23, 11], [
        24, 12], [25, 13]]
    for location in activate_list:
        if game_state.contains_stationary_unit(location):
            not_destroyed = [[0, 13], [1, 13], [2, 13], [
                3, 12], [4, 11], [5, 10], [6, 9], [22, 10], [23, 11], [
                24, 12], [25, 13]]
            destroyed = []
            for location in not_destroyed:
                if not game_state.contains_stationary_unit(location):
                    destroyed.append(location)
                    return destroyed
            for location in destroyed:
                if game_state.can_spawn(DESTRUCTOR, location):
                    game_state.attempt_spawn(DESTRUCTOR, location)

P.S. feel free to use my code :stuck_out_tongue: and any help would be appreciated; thank you so much!

Use game_state.attempt_remove() and see if that fixes it.

I does take an extra turn to remove a structure but the error checking should account for that.

Side note, not_destroyed is a bit redundant when activate_list is already defined.

1 Like

Reason for the not_destroyed list is because this function will be called first before having my filters placed. to avoid building destructors right off the bat I made it so it tries to recognize if there is a filter there then if there is, it initiates the not_destroyed and that’s where it will start placing defense if it breaks. but I’m sure I’m missing something I’ll keep trying on it!

Guess I wasn’t looking closely enough. You’re nesting a variable “location” inside a for each loop with variable… “location”

1 Like