Code VS Zombies - Optimization - Puzzle discussion

Which turn do you find the issue, and what do you find on/print to the error stream? Can you copy and paste it here? Maybe the relevant portion of the code (not the whole code) is needed too.

Hello, that was first turn. has ask first assumption is i am wrong looking more and more on my code I am.
the reflex case was the only raise clearly a missmanagement in my data table. I am working on optimization of that. thanks for consider my asking, sorry for disturbing.

2 Likes

Hello,

I am wondering what is the behavior in case a zombie is at the same distance to Ash and to the closest human ? In 2017 (one of the first question) was about 2 humans and the admin said that the lower ID has the priority. However Ash does not have any ID, does he have max priority or worse ?

Thanks for your support

I have the same issue.
if i find solution, iā€™ll write you

Hi @Di_Masta ,

Iā€™m probably just being daft, but I still donā€™t understand how to simulate the whole game. What I mean is, I only have the character positions for the current state (and zombie next x,y). How do I know where the zombie will be after that in order to simulate the whole game? I can use vectors to calculate based on zombie current x, y and next x,y where they will end up eventually, but what if they change direction for some random reason (of course they will if they destroy their target human, etc., but that aside)?

There are no random movements in the game. All zombies move in the manner as described in the statement.

1 Like

Ah yes doh. I think I get so wrapped up in trying to code solutions, my brain just forgets part of what Iā€™m doing. I mean, my first solution was finding the first human in danger that I could reach, so I must know where the zombies are heading, lol!. It says that every zombie will target the closest human and step 400 units towards them. So I know exactly where every zombie is heading and when they will get there. (Sorry, by ā€œrandomā€ I just meant ā€œunknownā€, but there are no unknowns). Thanks!

1 Like

Hi!

Before I go full steam implementing my GA, does anyone know whether Python would be fast enough for 100ms / turn time limit?

Depending on how many sims you are aiming for. My current solution uses python and GA, and it passes all the test cases and validators. Iā€™ve never counted how many sims the code runs per turn, but I doubt itā€™ll be any big number when compared with GA coded using other faster programming languages. I can only say it wonā€™t be very bad.

1 Like

Awesome thanks @5DN1L !

Hello, iā€™m confused, iā€™ve passed all the test without brut value but when i upload my result i donā€™t pass the 19th Test ā€œReflexā€. Can some one have an solution to verif what i miss ?

if you want to see my code : Codingame/main.cs at main Ā· Sterbweise/Codingame Ā· GitHub

Hello, i am uncertain if i predict the movement correctly.
Is this correct?

def zombie_move_to(zombie, human):
    delta_x = human[0] - zombie[0]
    delta_y = human[1] - zombie[1]
    distance = dist(zombie, human)
    if distance > 400:
        scalar = 400 / distance
        delta_x = math.floor(delta_x * scalar)
        delta_y = math.floor(delta_y * scalar)

    zombie[0] += delta_x
    zombie[1] += delta_y

Looks correct to me, assuming your identification of the variable human is correct (e.g. it is indeed the nearest human, Ash is considered when calculating the nearest human).

You may also run a few cases on CodinGame and compare the coordinates given to you in every turn and your calculation to check the correctness.

Thank you, your answer helped me. It seems to work.

1 Like

i need help im a new coder
the game is hard but its my dream to become a game creator so im not gonna give up

@Testadicardi Iā€™m just assuming that they output the winning weights and biases and the shape to the console, then copies those back in as hardcoded AI. LOL

Hi,
What happens if Ash kills some zombies but other zombies kill humans at the same turn?
Is the score counted using the number of humans alive at the time of killing the zombies or the number of humans alive at the very end of the turn (after the zombies killed the humans)?

Thanks!

According to the bellow quoted sentence, the 1st zombie killed worth 3*human^2*10. Which could mean that 3 zombies killedā€™s worth = (3+5+8)*human^2*10
Or does it mean that it may only be counted after the 2nd zombie, meaning 3 zombies killedā€™s worth = (1+5+8)*human^2*10?
Or it also could mean that the 1st ADDITIONAL zombie killed, that is 3 zombies killedā€™s worth=(1+3+5)*human^2*10.
Could you please help me, which version is the correct one?

ā€œthe nth zombie killedā€™s worth is multiplied by the (n+2)th number of the Fibonnacci sequenceā€

Does anyone know why Ash moves to the first human but then never moves again in my code?

from pickle import decode_long
import sys
import math

# Save humans, destroy zombies!
Move = [0,0]
Zombies = {}
Humans ={}
def EntitiesDefinitions():
    x, y = [int(i) for i in input().split()]
    human_count = int(input())
    EndangeredHuman = {
        "id": 0,
        "d": 18347.99,
        }
    Zombies.clear()
    Humans.clear()
    for i in range(human_count):
        human_id, human_x, human_y = [int(j) for j in input().split()]
        Human = {
            "id": human_id,
            "x": human_x,
            "y": human_y,
        }
        Humans[human_id] = Human
    zombie_count = int(input())
    for i in range(zombie_count):
        ClosestHuman = {
            "id": 0,
            "d": 18347.99,
            }
        zombie_id, zombie_x, zombie_y, zombie_xnext, zombie_ynext = [int(j) for j in input().split()]
        for H in Humans:
            if ClosestHuman["d"] > math.dist([zombie_xnext, zombie_ynext], [Humans[H]["x"], Humans[H]["y"]]):
                ClosestHuman = {
                    "id": Humans[H]["id"],
                    "d": math.dist([zombie_xnext, zombie_ynext], [Humans[H]["x"], Humans[H]["y"]]),
                }
                if EndangeredHuman["d"] > ClosestHuman["d"]:
                    EndangeredHuman = {
                    "id": ClosestHuman["id"],
                    "d": ClosestHuman["d"],
                }
        Zombie = {
            "id": zombie_id,
            "x": zombie_x,
            "y": zombie_y,
            "xn": zombie_xnext,
            "yn": zombie_ynext,
            "att": ClosestHuman["id"],
        }
        Zombies[zombie_id] = Zombie

# game loop
while True:
    EndangeredHuman = {
        "id": 0,
        "d": 18347.99,
        }
    EntitiesDefinitions()
    Move[0] = Humans[EndangeredHuman["id"]]["x"]
    Move[1] = Humans[EndangeredHuman["id"]]["y"]
    # Write an action using print
    # To debug: print("Debug messages...", file=sys.stderr, flush=True)

    # Your destination coordinates
    print (str(Move[0]) + (" ") + str(Move[1]))

I wasnā€™t pulling global entities correctly.