EnemyMovementUseCase
scalata.application.usecases.enemyusecases.EnemyMovementUseCase
class EnemyMovementUseCase extends CreatureUseCase[Room, 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
- Graph
-
- Supertypes
Members list
In this article