Download Game Design – From Concepts To Implementation

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

Artificial intelligence in video games wikipedia , lookup

Transcript
LUT Summer School 2013
Game Design – From Concepts To
Implementation
LUT Summer School 2013
Giacomo
Cappellini - [email protected]
Game Design – From Concepts to Implementation
Finite-state machines
START
A finite-state machine (FSM), or
simply a state machine, is a
mathematical model of computation
used to design both computer
programs and sequential logic
circuits.
It is conceived as an abstract
machine that can be in one of a
finite number of states.
STATE
A
STATE
C
~ Wikipedia
END
an hybrid approach is always possible
LUT Summer School 2013
Game Design – From Concepts to Implementation
STATE
B
What is a state?
From your point of view is just what your object is doing NOW
You may want that your object waits a mouse click before
doing something, and after 5 more second it disappears.
Wait mouse
click
Do something
for 5 seconds
These are all states
LUT Summer School 2013
Game Design – From Concepts to Implementation
Destroy itself
Transitions
Every sequential block of operations that works with time or
external events (like user inputs) can be designed as FSMs
Wait mouse
click
Do something
for 5 seconds
Destroy itself
The switch from one state to the next one is always triggered
by an event, and it creates a Transition
LUT Summer School 2013
Game Design – From Concepts to Implementation
Nothing new here
Yesterday you successfully completed an exercise where you
had to make a cube change the direction of the transition
after 5 seconds.
You have programmed this state machine:
Go Right for 5
seconds
LUT Summer School 2013
Game Design – From Concepts to Implementation
Go Left
What about this
Main
Menu
LUT Summer School 2013
Game Design – From Concepts to Implementation
Game
And this
Wait
player 1
input
Do player
2
animation
Do player
1
animation
Wait
player 2
move
LUT Summer School 2013
Game Design – From Concepts to Implementation
Finite-state machines can be hierarchical
Wait
player 1
input
Main
Menu
Do player
2
animation
Do player
1
animation
Wait
player 2
move
LUT Summer School 2013
Game Design – From Concepts to Implementation
Finite-state machines can run in parallel
Go Right for 5
seconds
Go Left
Wait mouse
click
Rotate Left
LUT Summer School 2013
Game Design – From Concepts to Implementation
Hints from the real world of game programming
•  Strategy and turn based games rules, can be easily designed
using a single FSM
•  Action or real-time games need more FSMs running in
parallel.
I’m not saying that action games are more difficult, but I’d
suggest you to start with a turn based game
LUT Summer School 2013
Game Design – From Concepts to Implementation
FSM = Rules!
Are you able to design the FSM for playing tic-tac-toe?
LUT Summer School 2013
Game Design – From Concepts to Implementation
FSMs in the Unity way
Unity has a witty way to build FSMs
Coroutines
Download: http://bit.ly/11OjDwH
LUT Summer School 2013
Game Design – From Concepts to Implementation
Goals
1.  Create a Coroutine that prints “Hello” on the console
(Debug.Log) every 2 seconds
2.  Create a Coroutine that moves a cube, it should move 1
unit on X when the user clicks on the left button, and -1 on
right click. Use Input.GetMouseButtonDown(N) where N is 0
for left and 1 for right.
3.  Create a Coroutine that moves a cube smoothly from
(0,0,0) to (10,0,0) in 5 seconds. HINT: use Vector3.Lerp like
in GoToWaypoint function
LUT Summer School 2013
Game Design – From Concepts to Implementation