Starlight-30036225 / Ai-Assignment

Assets from Code the Classics
0 stars 0 forks source link

Costs and penalties to search algorithm, #8

Open Starlight-30036225 opened 5 months ago

Starlight-30036225 commented 5 months ago

I want to add an additional cost or penalty to a space.

Like avoiding enemies and benefits for getting additional fruits

Starlight-30036225 commented 5 months ago
for fruit in game.fruits:
    if fruit.y > 440:
        continue
    returnMap[int(fruit.y * (NUM_ROWS / HEIGHT))][int(fruit.x * (NUM_COLUMNS / WIDTH))] = -10

for robot in game.enemies:
    if robot.y > 440:
        continue
    returnMap[int(robot.y * (NUM_ROWS / HEIGHT))][int(robot.x * (NUM_COLUMNS / WIDTH))] = 4

Adding this to the map generation assigns values. These will need to be changed later. These values are added to the combined total. This means passing through a fruit is preferable and passing a robot is negative