Download TGD3351 Game Algorithms Tutorial 5 Briefly describe how a finite

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Game mechanics wikipedia , lookup

Deathmatch wikipedia , lookup

Artificial intelligence in video games wikipedia , lookup

Transcript
TGD3351 Game Algorithms
Tutorial 5
1. Briefly describe how a finite state machine (FSM) is used for decision-making in games.
2. The AI for an elf in an RPG game is designed with a simple FSM, as given below:
Note that the transitions between the 4 states appear to be complex due to the fact that
only 2 criteria are checked to determine the state it should belong to – health (marked
h in figure) and range of player (marked IR in figure for ‘In Range’). Given the Elf AI
class members and variables below, write an efficient short code snippet to represent
the FSM above. Note that it is possible to trim your criteria-checking logic so that it
runs more efficiently by avoiding redundant checking.
class ElfAI
{
public:
int type;
int state;
int row;
int column;
int health;
int strength;
int intelligence;
int magic;
int armed;
Boolean playerInRange();
int checkHealth();
};
int PoorHealth = 20;
3. Write a short code snippet (using switch-case statements) for the soldier FSM given in the
textbook. You can arbitrarily make use of some variables or functions of your own (no need
to implement) to check for certain conditions required by the FSM.
4. Give an example of how the following state machine techniques can be applied to game AI:
a) Hierarchical state machines
b) Combination of decision trees with state machines
5. Suggest a way how we can incorporate probabilities or even randomness into the transitions
of the FSM. Provide examples of how this is possible (or not possible).