Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
cOnscienS: social and organizational framework for gaming AI
1. 23/12/2011 | 1 IA
cOncienS
Sergio
Alvarez
Sergio
Alvarez-‐Napagao(1)GIómez Gómez-‐SebasCà
(1),
Ignasi
,
gnasi
Javier
Vázquez-‐Salceda
(1)
Javier
Vázquez
João
dfasdf
(1)
{salvarez,igomez,jvazquez}@lsi.upc.edu
Universitat
Politècnica
de
Catalunya
ALIVE EU FUNDED PROJECT
ALIVE EU FUNDED PROJECT
martes 3 de enero de 12
2. 23/12/2011 IA
Commercial
games
AI
• Main
objecCve...
to
deliver
the
illusion
of
intelligence
• Categories:
– Movement
(pathfinding,
collision,
visibility)
– Individual
Behaviour
(NPCs)
– CollecCve
Strategy
(NPCs
groups)
ALIVE EU FUNDED PROJECT
martes 3 de enero de 12
3. 23/12/2011 IA
Pathfinding
• A*
(Dijkstra
1959;
Hart,
Nilsson,
Raphael
1968)
– SCll
improving,
sCll
used
in
the
industry
– Aligned
with
academic
AI:
D*,
IDA*,
GAA*,
...
– Example:
StarcraV
2
(A*
+
Queueing)
ALIVE EU FUNDED PROJECT
martes 3 de enero de 12
5. 23/12/2011 IA
So
what
about
behavior
and
strategy?
In commercial games, not much...
ALIVE EU FUNDED PROJECT
martes 3 de enero de 12
6. 23/12/2011 IA
So
what
about
behavior
and
strategy?
Scripting
private function UpgradeEx takes nothing returns nothing
local unit u = GetTriggerUnit()
local integer id = GetUnitTypeId(u)
call DisableTrigger(trg_upgrade)
call IssueImmediateOrderById(u, 851976)
endfunction
ALIVE EU FUNDED PROJECT
martes 3 de enero de 12
7. 23/12/2011 IA
So
what
about
behavior
and
strategy?
Hash Tables
std::map< int, CB > hashTable;
hashTable[ 1 ] = UpgradeEx;
...
hashTable[ 40000 ] = AttackUnit;
(*(hashTable[ a ]))();
ALIVE EU FUNDED PROJECT
martes 3 de enero de 12
8. 23/12/2011 IA
So
what
about
behavior
and
strategy?
Finite State Machines
a=1
doSomething1()
a=2
doSomething2()
a=3
a=3
doSomething4000()
a = 4000
...
a=N
doSomething3()
a=3
ALIVE EU FUNDED PROJECT
martes 3 de enero de 12
9. 23/12/2011 IA
So
what
about
behavior
and
strategy?
Rule Engines
(defrule
! (goal 16 0)
! (can-research-with-escrow ri-ballistics)
=>
! (release-escrow wood)
! (release-escrow food)
! (release-escrow gold)
! (release-escrow stone)
! (research ri-ballistics)
)
ALIVE EU FUNDED PROJECT
martes 3 de enero de 12
10. 23/12/2011 IA
So
what
about
behavior
and
strategy?
Decision Trees
ALIVE EU FUNDED PROJECT
martes 3 de enero de 12
11. 23/12/2011 IA
So
what
about
behavior
and
strategy?
Where is the reasoning?
ALIVE EU FUNDED PROJECT
martes 3 de enero de 12
12. 23/12/2011 IA
So
what
about
behavior
and
strategy?
Where is the reasoning?
IT’S GIVEN/HARDCODED BY THE DEVELOPER AT DESIGN TIME!
ALIVE EU FUNDED PROJECT
martes 3 de enero de 12
13. 23/12/2011 IA
What
is
usually
seen
in
commercial
games?
• Blind
specificaCons:
HOW
to
act,
not
WHY
Lack
of
flexibility
and
adapCveness
Strange,
predictable
behaviour
Low
reusability
Having
more
reusable
AI
engines
would
make
companies
invest
more
in
developing
be_er
AI
engines?
ALIVE EU FUNDED PROJECT
martes 3 de enero de 12
14. 23/12/2011 IA
What
is
usually
seen
in
commercial
games?
• Blind
specificaCons:
HOW
to
act,
not
WHY
– Lack
of
flexibility
and
adapCveness
– Strange,
predictable
behavior
Low
reusability
Having
more
reusable
AI
engines
would
make
companies
invest
more
in
developing
be_er
AI
engines?
ALIVE EU FUNDED PROJECT
martes 3 de enero de 12
15. • Blind specifications: HOW to act, not WHY
• Lack of flexibility and adaptiveness
• Strange, predictable behaviour
Low reusability
Having more reusable AI engines would make
companies invest more in developing better
AI engines?
martes 3 de enero de 12
16. • Blind specifications: HOW to act, not WHY
• Lack of flexibility and adaptiveness
• Strange, predictable behaviour
Low reusability
Having more reusable AI engines would make
companies invest more in developing better
AI engines?
martes 3 de enero de 12
17. 23/12/2011 IA
What
is
usually
seen
in
commercial
games?
• Blind
specificaCons:
HOW
to
act,
not
WHY
– Lack
of
flexibility
and
adapCveness
– Strange,
predictable
behavior
• Low
reusability
Having
more
reusable
AI
engines
would
make
companies
invest
more
in
developing
be_er
AI
engines?
ALIVE EU FUNDED PROJECT
martes 3 de enero de 12
18. 23/12/2011 IA
Example:
RTS
scripEng
private function UpgradeEx takes nothing returns nothing
WarcraV
3 local unit u = GetTriggerUnit()
(JASS) local integer id = GetUnitTypeId(u)
call DisableTrigger(trg_upgrade)
call IssueImmediateOrderById(u, 851976)
endfunction
rule getNextGathererUpgrade {
Age
of
int upgradeTechID=kbTechTreeGetCheapestUnitUpgrade(gathererTypeID,
Mythology
cUpgradeTypeWorkRate, -1, dropSiteFilterID, false, affectedUnitType);
(XSScript) int planID=aiPlanCreate("nextGathererUpgrade - "+id, cPlanProgression);
aiPlanSetVariableInt(planID, cProgressionPlanGoalTechID, 0, upgradeTechID);
aiPlanSetDesiredPriority(planID, 25);
aiPlanSetEscrowID(planID, cEconomyEscrowID);
aiPlanSetActive(planID);
}
ALIVE EU FUNDED PROJECT
martes 3 de enero de 12
19. 23/12/2011 IA
Example:
RTS
scripEng
wait_build 2 forge
StarcraV
upgrade 1 p_ground_weapon 70
(Broodwar
AI) upgrade 1 p_plasma_shield 70
wait 2700
wait_build 1 cybernetics_core
upgrade 1 p_armor 70
upgrade 2 p_plasma_shield 70
wait 3600
(defrule
Age
of
(goal 16 0)
Empires
II
-‐
(can-research-with-escrow ri-ballistics)
AOK
=>
(release-escrow wood)
(ScriptED) (release-escrow food)
(release-escrow gold)
(release-escrow stone)
(research ri-ballistics)
)
ALIVE EU FUNDED PROJECT
martes 3 de enero de 12
20. 23/12/2011 IA
Example:
RTS
scripEng
WarcraV
III StarcraV AoM AoK
Common
concepts:
unit,
building,
a_ack,
defend,
group,
patrol,
train,
research,
resource...
ALIVE EU FUNDED PROJECT
martes 3 de enero de 12
21. 23/12/2011 IA
What
is
usually
seen
in
commercial
games?
Having
more
reusable
(higher-‐level)
AI
engines
would
make
companies
invest
more
in
developing
be_er
AI
engines?
ALIVE EU FUNDED PROJECT
martes 3 de enero de 12
22. 23/12/2011 IA
There
is
some
hope
• Planning:
reasoning
to
achieve
goals
with
ac2ons
• HTN
(Hierarchical
Task
Networks)
• GOAP
(Goal-‐Oriented
AcOon
Planning,
Orkin
2005)
– F.E.A.R,
Condemned,
Fallout
3,
Empire:
Total
War,
Deus
Ex
3,
Just
Cause
2,
...
– This
idea
has
been
slowly
adapted
into
other
engines
• AI
engines
are
starOng
to
be
reused
in
a
consistent
basis
– Radiant
AI,
gamebyro
ALIVE EU FUNDED PROJECT
martes 3 de enero de 12
23. 23/12/2011 IA
Goal-‐Oriented
AcEon
Planning
ALIVE EU FUNDED PROJECT
martes 3 de enero de 12
24. 23/12/2011 IA
Goal-‐Oriented
AcEon
Planning
ALIVE EU FUNDED PROJECT
martes 3 de enero de 12
25. 23/12/2011 IA
Goal-‐Oriented
AcEon
Planning
(Condition + Priority) (Condition + Priority)
AttackFromCover Patrol
(Goal state description) (Goal state description)
(Condition + Priority)
(Condition + Priority) Investigate
Search (Goal state description)
(Goal state description)
“STRIPS-like” planner
Semantically annotated actions
(pre- and post-conditions)
ALIVE EU FUNDED PROJECT
martes 3 de enero de 12
28. 23/12/2011 IA
Goal-‐Oriented
AcEon
Planning
• Dynamic
planning
and
re-‐planning
– Outperforms
FSMs!
• Allows
to
reason
about
WHAT
to
do
– BUT
sCll
not
about
WHY
• Plans
only
cannot
properly
model
social
behavior
– Need
for
organizaEonal
structures
ALIVE EU FUNDED PROJECT
martes 3 de enero de 12
29. 23/12/2011 IA
Our
proposal:
going
even
higher
• It
is
possible
to
elaborate
soluCons
for
the
issues
of
– behaviour
control
– strategy
techniques
• ...
by
integraCng
models
based
on
OrganisaEonal
TheoreEcal
methods
• Expected
outcomes
– Methodology
and
tools
for
Game
AI
developers
– to
model
gaming
scenarios
using
social
structures
• Case
studies:
commercial
games
– Cheaper,
faster,
more
visible
ALIVE EU FUNDED PROJECT
martes 3 de enero de 12
30. 23/12/2011 IA
ALIVE EU FUNDED PROJECT
martes 3 de enero de 12
31. 23/12/2011 IA
HOW?
(available services)
ALIVE EU FUNDED PROJECT
martes 3 de enero de 12
32. 23/12/2011 IA
WHAT?
(possible actions, plans)
HOW?
(available services)
ALIVE EU FUNDED PROJECT
martes 3 de enero de 12
33. 23/12/2011 IA
WHY?
(motivations)
WHAT?
(possible actions, plans)
HOW?
(available services)
ALIVE EU FUNDED PROJECT
martes 3 de enero de 12
34. 23/12/2011 IA
ALIVE EU FUNDED PROJECT
martes 3 de enero de 12
35. 23/12/2011 IA
What
could
ALIVE
provide?
• High-‐level
schemas
to
reason
and
jusEfy
acCons
taken
by
NPCs
– Roles,
objecCves,
norms,
plans...
• Clearly
decouple
implementaCon
and
design
– Reusable
designs
· Minimal
changes
(e.g.
vocabulary)
· Lower
adaptaCon
cost
– Dynamic
re-‐organizaCon
techniques
• Not
a
replacement!
ALIVE EU FUNDED PROJECT
martes 3 de enero de 12
36. 23/12/2011 IA
ALIVE EU FUNDED PROJECT
martes 3 de enero de 12
37. 23/12/2011 IA
GAME
ENGINE
ALIVE EU FUNDED PROJECT
martes 3 de enero de 12
38. 23/12/2011 IA
Case
studies
• We
have
connected
ALIVE
to
several
games
– Sandbox
game:
GTA
IV
– Real-‐Time
Strategy:
WarcraV
III,
Lincity,
StarcraV
– Turn-‐Based
Strategy:
CivilizaCon
IV
– MMORPG:
WoW
– Other:
Sims
3
• EvaluaCon
of
proposal
– Realism,
flexibility,
adaptability
• Use
games
as
inputs
for
OrganisaConal
Research
ALIVE EU FUNDED PROJECT
martes 3 de enero de 12
39. 23/12/2011 IA
How
to
connect
with
games?
• ScripCng
languages
with
I/O
support
(e.g.
LUA)
• DLL
InjecCon
• Source
code
ALIVE EU FUNDED PROJECT
martes 3 de enero de 12
40. 23/12/2011 IA
How
to
connect
with
games?
• ScripCng
languages
with
I/O
support
(e.g.
LUA)
• DLL
InjecCon
• Source
code
ALIVE EU FUNDED PROJECT
martes 3 de enero de 12
41. 23/12/2011 IA
WarcraP
III
• Design
of
an
organizaEonal
model
• ImplementaCon
of
ALIVE-‐aware
agents
(pure
Java)
• ConnecCon:
DLL
InjecCon
+
sockets
• RTS
games
are
interesCng
for
us:
– Armies
in
RTS
are
directly
translatable
into
ALIVE
models
– These
models
can
be
shared
through
games
– ReorganizaEon
techniques
can
be
applied
– Visual
interface
for
real-‐Cme
simulaEon
ALIVE EU FUNDED PROJECT
martes 3 de enero de 12
42. 23/12/2011 IA
WarcraP
III:
Models
ALIVE EU FUNDED PROJECT
martes 3 de enero de 12
43. 23/12/2011 IA
WarcraP
III:
Agent
ALIVE EU FUNDED PROJECT
martes 3 de enero de 12
44. 23/12/2011 IA
WarcraP
III:
Agent
ALIVE
project
ALIVE EU FUNDED PROJECT
martes 3 de enero de 12
45. 23/12/2011 IA
ALIVE EU FUNDED PROJECT
martes 3 de enero de 12
46. 23/12/2011 IA
WarcraP
III:
Agent
• The
ALIVE
framework
provides
the
mechanisms
for:
– Perceiving
a
“state
of
the
world”
by
the
interpretaEon
of
events
– Reasoning
about
the
acEons
declared
in
the
CoordinaCon
Level
– Taking
into
account
the
organizaEonal
structures:
roles,
plans,
norms
· Following
them
if
the
organizaConal
constraints
are
self-‐beneficial!
– Enact
acEons
in
the
game,
through
the
patched
Service
Level
ALIVE EU FUNDED PROJECT
martes 3 de enero de 12
47. 23/12/2011 IA
World
of
WarcraP
• Emergent
narra2ve
use-‐case
• The
objecCve
is
to
break
the
concepEon
of
linear
narraEve
as
the
only
way
for
humans
to
author
a
story
• Basic
idea:
– To
balance
character
models,
events
sequences
and
narraCve
landmarks
to
create
a
more
open
narraEve
• Main
challenge:
– Virtual
environments
(games)
and
narraCves
exist
on
different
ontological
levels
– Difficult
to
treat
them
jointly
– Emergent
narraCve
is
a
direct
result
of
the
acEons
of
characters
– To
give
an
illusion
of
personality
to
both
players
and
non-‐players
ALIVE EU FUNDED PROJECT
martes 3 de enero de 12
48. 23/12/2011 IA
World
of
WarcraP:
architecture
ALIVE EU FUNDED PROJECT
martes 3 de enero de 12
49. 23/12/2011 IA
World
of
WarcraP:
player
classificaEon
• Play
styles
taxonomy
based
on
interacCon
between
players
– Achievers,
Explorers,
Socializers,
Killers
[Bartle]
• During
gameplay,
players’
behaviours
are
monitored
and
analized
to
classify
them
into
play
styles
– AcCons,
chat
logs,
achievements,
staCsCcs
• AcCons
and
states
are
tagged
at
design
Cme
in
terms
of
play
styles
– achiever
:
distractGatekeeper
– killer
:
killGatekeeper
• These
tags
are
used
by
Character
Agents
when
selecCng
the
acCons
to
reach
a
landmark
ALIVE EU FUNDED PROJECT
martes 3 de enero de 12
50. 23/12/2011 IA
World
of
WarcraP:
plot
generaEon
and
modificaEon
• InteracOvity
is
achieved
by
giving
enough
choices
to
the
player
to
give
an
illusion
of
free
will
• The
Plot
Agent
parCally
influences
the
player
via
missions
• If
the
player
gets
too
far
from
the
storyline,
its
Character
Agent
can
negoEate
changes
in
the
environment
to
keep
acCon
within
boundaries
– Problem:
the
plot
counted
on
the
player
to
kill
a
dragon
to
get
the
gem,
but
the
player
doesn’t
kill
it
– SoluCon:
infer
an
alternaCve
way
to
bring
the
gem
to
the
player
ALIVE EU FUNDED PROJECT
martes 3 de enero de 12
56. 23/12/2011 IA
Where
are
we
in
literature?
• OrganizaConal
modeling
has
been
explored
for
serious
games
• AdapCveness
in
games
is
not
new...
– ...but
we
propose
to
introduce
another
level
of
abstracCon
• GOAP
is
an
example
of
a
higher-‐level
mechanism
being
successful
• Opportunity
to
tackle
the
upcoming
real
challenges
of
industry
gaming
AI
[Jonathan
Schaeffer
@IJCAI’11]:
– RealisCc
NPC
behaviour
– Emergent
narraCve
ALIVE EU FUNDED PROJECT
martes 3 de enero de 12
57. 23/12/2011 IA
Conclusions
• Main
advantage:
specify
behavior
in
terms
of
why
to
do
something
• ObjecCve:
to
provide
a
methodology
and
tools
for
Game
AI
developers
– Release
game
enactors
as
open-‐source
• We
prioriCze
behaviour
improvement
over
performance
ALIVE EU FUNDED PROJECT
martes 3 de enero de 12
58. 23/12/2011 IA
What
are
we
doing
right
now?
• Emergent
narraCve
in
MMORPGs:
– Player
personality
analysis
· Data
mining
techniques
over
public
data
+
voluntary
surveys
– Missions,
quests
will
adapt
to
the
player’s
gaming
style
· Killer,
Socializer,
Achiever,
Explorer
[Bartle]
– Socially-‐aware
· NPCs
are
aware
of
their
social
role
· Roles
can
be
changed,
society
can
evolve
• CreaCng
more
complex
models
for
improved
realism
• Finding
metrics
for
correct
evaluaCon
of
our
proposal
– Ba_le
ALIVE
vs
ALIVE
with
organizaConal
adaptaCon
• h_p://kemlg.github.com/consciens
ALIVE EU FUNDED PROJECT
martes 3 de enero de 12