Package cl.cromer.azaraka.ai
Interface PlayerAI
-
- All Superinterfaces:
Constants
,java.lang.Runnable
- All Known Implementing Classes:
PlayerAStarAI
,PlayerBreadthFirstAI
public interface PlayerAI extends java.lang.Runnable, Constants
This interface has Player specific AI code that is shared between AI implementations
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface cl.cromer.azaraka.Constants
Constants.AIHeuristic, Constants.LogLevel, Constants.PlayerAIType
-
-
Field Summary
-
Fields inherited from interface cl.cromer.azaraka.Constants
AI_HEURISTIC, APPEND_LOGS, CELL_PIXELS, CHESTS, ENEMIES, ENEMY_AI, EXPORT_SCENE, FONT, FONT_SIZE, GENERATE_SCENE, GLOBAL_LOG, HORIZONTAL_CELLS, LOG_TO_FILE, OBSTACLES, PLAYER_AI, PRETTY_JSON, TITLE, VERTICAL_CELLS, VOLUME
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
addDestination(State destination)
Add a destination to the list of destinationsdefault boolean
checkCondition(Scene scene, State goal)
Check conditions for the goal, if they are not met don't go after that goal yetdefault boolean
destinationArrived(Scene scene, State goal)
If the player arrived at a a goal this should be calleddefault void
doAction(Scene scene, java.util.List<State.Type> steps)
Do the player control actionsdefault State.Type
getOpenSpaceAroundPlayer(Scene scene)
Check if the spaces around the player are ope or not and return one of them randomlydefault double
heuristic(State start, State goal)
The heuristic to get the distance between the start state and the end state Manhattan Distance Used for 4 direction movements h = abs (current_cell.x – goal.x) + abs (current_cell.y – goal.y) Diagonal Distance Used for 8 direction movements h = max { abs(current_cell.x – goal.x), abs(current_cell.y – goal.y) } Euclidean Distance Used for distance between 2 points h = sqrt ( (current_cell.x – goal.x)2 + (current_cell.y – goal.y)2 )boolean
search(State start, State goal)
Search for the goal from a starting statevoid
sortDestinations()
Sor the destinations based on importance and distancedefault java.util.List<State>
sortDestinations(java.util.List<State> destinations, State initial)
Sort the destinations based on importance and distance-
Methods inherited from interface cl.cromer.azaraka.Constants
getLogger, initializeLogger, random
-
-
-
-
Method Detail
-
search
boolean search(State start, State goal)
Search for the goal from a starting state- Parameters:
start
- The start stategoal
- The goal state- Returns:
- Return true if there is a path or false otherwise
-
addDestination
void addDestination(State destination)
Add a destination to the list of destinations- Parameters:
destination
- The new destination
-
sortDestinations
void sortDestinations()
Sor the destinations based on importance and distance
-
heuristic
default double heuristic(State start, State goal)
The heuristic to get the distance between the start state and the end state Manhattan Distance Used for 4 direction movements h = abs (current_cell.x – goal.x) + abs (current_cell.y – goal.y) Diagonal Distance Used for 8 direction movements h = max { abs(current_cell.x – goal.x), abs(current_cell.y – goal.y) } Euclidean Distance Used for distance between 2 points h = sqrt ( (current_cell.x – goal.x)2 + (current_cell.y – goal.y)2 )- Parameters:
start
- The start stategoal
- The goal state- Returns:
- Returns the distance between the states
-
sortDestinations
default java.util.List<State> sortDestinations(java.util.List<State> destinations, State initial)
Sort the destinations based on importance and distance- Parameters:
destinations
- The destinations to sortinitial
- The initial state of the player- Returns:
- Returns the new sorted destinations
-
destinationArrived
default boolean destinationArrived(Scene scene, State goal)
If the player arrived at a a goal this should be called- Parameters:
scene
- The scenegoal
- The goal- Returns:
- Returns true if the goal is in a certain state or false if the goal is not truly reachable or usable
-
checkCondition
default boolean checkCondition(Scene scene, State goal)
Check conditions for the goal, if they are not met don't go after that goal yet- Parameters:
scene
- The scenegoal
- The goal- Returns:
- Returns true if the goal is obtainable or false otherwise
-
getOpenSpaceAroundPlayer
default State.Type getOpenSpaceAroundPlayer(Scene scene)
Check if the spaces around the player are ope or not and return one of them randomly- Parameters:
scene
- The scene- Returns:
- Returns a random direction to go
-
doAction
default void doAction(Scene scene, java.util.List<State.Type> steps)
Do the player control actions- Parameters:
scene
- The scenesteps
- The steps to follow
-
-