scalata.application.usecases.enemyusecases
Members list
Type members
Classlikes
Executes the enemy attack phase.
Executes the enemy attack phase.
==== Algorithm ====
-
Fetch the current
Playerfrom the session. -
For every alive enemy in the room:
-
Compute the four-tile neighbourhood around the enemy (
neighboursFiltered). -
If the player’s position lies in that neighbourhood, apply
enemy.attack(player). -
Return the player after all damage has been accumulated (purely functional fold).
The method is pure: it produces a new Player instance without mutating the session or the room.
Attributes
- Supertypes
Calculates one AI movement step for every living enemy inside the supplied room.
Calculates one AI movement step for every living enemy inside the supplied room.
==== Key steps ====
- Generate Prolog facts – encode the grid size, obstacles (items + other enemies), enemies’ positions and the player location/visibility.
- Run Prolog rules (breadth-first search) – compute the cost-to-player for every reachable tile and derive
best_moves_all/1. - Conflict resolution – group candidate moves per enemy, keep only the cheapest ones, then greedily pick non-overlapping destinations.
- Apply moves – return a new scalata.domain.world.Room with updated enemy positions.
The function is pure: it builds a Prolog engine, computes the moves and returns a modified room; the original room and session remain unchanged.
Attributes
- Supertypes