-
Notifications
You must be signed in to change notification settings - Fork 2
Strategies
It's a key design to a role's behavior. A Strategy
is a kind of logic to determine the next action according to the game status.
The name
method returns the strategy name used in the src/config.json
file.
The action_lvls
method returns an array containing the level of recommendation for every action.
Assume:
Then action_lvls
returns:
I have implemented five kinds of strategies. They can be combined together.
Random
is the default strategy. All valid actions except stay will get random recommendation levels.
MoveAway
and MoveClose
only consider the next one step. They use the following estimate function to maximize or minimize the distance between the agent and enemy.
def dist(src: tuple[int, int], dest: tuple[int, int]) -> float:
return abs(src[0] - dest[0]) + abs(src[1] - dest[1])
WallDensity
tries to find a direction where the density of walls is lower.
AStar
tries to find the shortest path from the enemy to the agent, as the blue path shows.
At first, the enemy knows nothing about terrains, so AStar
assumes that all tiles are grass and finds an ideal path.
After the enemy learns terrains from its movements, AStar
will become more accurate.