Storing moves between turns


#1

Hello, I am relatively new to this competition and am not a professional. Is there any way to store the previous moves for each ship? I am having a problem with my ships getting stuck and would like to implement something that, evaluates if they have been still for x amount of rounds and then forces a move if this is true. I realise the source of the problem is poor navigation, but that is beyond my abilities at the moment.


Add attribute to entity (Python)
#2

One of the easiest ways is to put a dictionary (hash map) inside a Game or Map or Navi object (depends on your programing language, some starter kits doesn’t have Navi) and store ShipId -> any info you need.

Just don’t put this info inside a Ship object, since these objects are recreated each turn (this is a design decision of starter kit authors).


#3

I am using python. Can you store more than one move per ship with using a dictionary?


#4

You can probably put an array inside of dictionary, why not?


#5

Is it possible not to recreate these objects each turn in Python? What is the purpose of recreating them?


#6

I suppose it was easier to implement. If you want persistent entities, you have to implement it yourself (not a big deal, though).


#7

There is an issue started on the repo regarding persistent ship objects here, with a preliminary implementation here.


#8

Does this work already, if we replace the method in the game_map.py file, or will it only work if the other things out of our control are updated? Im guessing the __ships also needs to be added somewhere


#9

I’ve been using the modded _generate method.
Yes, __ships needs to be added.

See the actual code changes or download that file version.