Detecting Breaches

yeah I did and I get this error:

File “/tmp/algo13700944336319812296/”, line 37, in on_action
frame = json.loads(game_state)
NameError: name ‘json’ is not defined

thats weird algocore imports json in its file

Have you ever been able to get this code to work?

json is a module that is included by default with Python when you install it, so the error means you either never import json (you deleted it somewhere - check to make sure its at the top of your code and if not add it).

If your code still fails after adding import json at the top:
Try opening an cmd or terminal window:

  1. Type py or python and enter (interactive python should show up, will have >)
  2. Type and enter import json. If that fails then you have a problem with your installation.

Yeah I must have deleted it somewhen, thanks it works now.
Where do I call detectBreach?

im guessing you can call whenever in your strategy after the action phase

So im currently calling detectBreaches like this:


and it doesnt crash but (as you see in the code im outputting the breaches in the console) it keeps printing this:

[[[26, 12]]]
[[[26, 12], [26, 12]]]
[[[26, 12], [26, 12], [26, 12]]]

and I dont know what this is supposed to be, its not the coordinate where the breach is, nor anything else I can tell.

What now? I would like the coordinates where my opponents information units actually breach.

in the code above(picture) you put list_breaches_turns inside the for frame and for breach loops. So for every breach it appends the list again and again, so if a unit actually breaches [26,12] it will add it again and again. list_breaches_turns should append the list after all the for loops.
You’re also calling gamelib.debug_write(possibly list_breaches_turns in here) also inside the for breach and for frame loops, outputting the repetitive list_breaches_turns. This is why it outputs that way.
It is unlikely that the code itself would change the coordinates without some specific script that was added to change the breach info. Also, why would you even want to change that breach information?
Hope this answers your question

Yeah thanks this kind of answered my question, but im also wondering about why its outputting [26,12] if it has nothing to do with where anything breached.

Also to answer your question, I dont quite understand what you mean by

why would you even want to change that breach information?

I want to get the information of were the enemy breached my side, to place firewalls there or something along those lines, I dont intend to change anything about that information.


Erm nevermind I fixed it