informatiCup / informatiCup2020

Pandemie!
https://informaticup.github.io/informatiCup2020/
20 stars 5 forks source link

Cannot quarantine city more than once #13

Closed AbdBarho closed 4 years ago

AbdBarho commented 4 years ago

I am not sure if this is a bug or the intended behavior, but the quarantine event remains in the city even after the defined rounds has passed.

This prevents quarantining the city in any upcoming rounds.

Using the latest version of the windows game binary (2.0.1)

How to reproduce:

from bottle import post, request, run, BaseRequest

quarantine_sent = False
@post("/")
def index():
    game = request.json
    berlin_data = game["cities"]["Berlin"]
    print(f'round: {game["round"]}, Berlin events: {get_quarantine_event(berlin_data)}')

    global quarantine_sent
    action = {"type": "endRound"}
    if not quarantine_sent:
      action = {"type": "putUnderQuarantine", "city": "Berlin", "rounds": 1}
      quarantine_sent = True
    return action

def get_quarantine_event(city):
    events = city.get("events", [])
    return list(filter(lambda e: e["type"] == "quarantine", events))

BaseRequest.MEMFILE_MAX = 10 * 1024 * 1024
run(host="0.0.0.0", port=50123, quiet=True)

After running this code we get the following output:

round: 1, Berlin events: []
round: 1, Berlin events: [{'type': 'quarantine', 'sinceRound': 1, 'untilRound': 2}]
round: 2, Berlin events: [{'type': 'quarantine', 'sinceRound': 1, 'untilRound': 2}]
round: 3, Berlin events: [{'type': 'quarantine', 'sinceRound': 1, 'untilRound': 2}]
round: 4, Berlin events: [{'type': 'quarantine', 'sinceRound': 1, 'untilRound': 2}]
round: 5, Berlin events: [{'type': 'quarantine', 'sinceRound': 1, 'untilRound': 2}]
round: 6, Berlin events: [{'type': 'quarantine', 'sinceRound': 1, 'untilRound': 2}]
round: 7, Berlin events: [{'type': 'quarantine', 'sinceRound': 1, 'untilRound': 2}]
round: 8, Berlin events: [{'type': 'quarantine', 'sinceRound': 1, 'untilRound': 2}]
round: 9, Berlin events: [{'type': 'quarantine', 'sinceRound': 1, 'untilRound': 2}]
...
ghost commented 4 years ago

Fixed in 2.0.2. Thanks for the helpful code sample!