• Keine Ergebnisse gefunden

What  can  go  wrong?      Where’s  the  problem?

N/A
N/A
Protected

Academic year: 2022

Aktie "What  can  go  wrong?      Where’s  the  problem?"

Copied!
18
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

R EAL   T IME   U SER I NTERACTIONS

What  can  go  wrong?      Where’s  the  problem?

(2)

Context

Examples  of  Game  AcCons SynchronizaCon  Strategies

(3)

Context:  Social  Games

Social  Games  are

• social:  play  with  your  friends  on  a  social  network

• casual:  5  minutes  are  enough  to  play

• easy:  simple  to  learn

• massive  in  scale:  played  by  millions  every  day

• everywhere:  can  be  played  using  a  web  browser

(4)

Context:  Basic  setup

The  server  is  more  than  just  a  database

• Client:  loads  complete  state  from  server  at  session   start,  all  state  changes  (acBons)  are  sent  to  server

• Server:  keeps  state  in  RAM,  all  client  acBons  are   replayed  and  validated,  state  is  updated  

accordingly,  persistence  can  be  ignored  (for  now)

• The  client  should  never  wait  on  a  server  response   when  execuBng  acBons  to  ensure  best  usability

(5)

Context:  User  InteracBon

Most  social  games  use  asynchronous  interacCon

• Player  A  sends  a  message  that  player  B  interacts   with  when  he  comes  online.

• Examples  are  Facebook’s  feedposts  and  requests.

• Think  of  a  message  inbox  that  is  processed  when  a   player  comes  online.

(6)

Context:  User  InteracBon

This  is  about  Real  Time  User  InteracCon

• Player  A  watches  player  B  doing  something,  i.e.  

their  client  display  the  other  players  acBons.

• Both  players  are  online  at  the  same  Bme.

• Since  the  game  is  browser  based  communicaBon   delays  of  up  to  2  (even  10!)  seconds  are  possible.

• Player  acBons  may  conflict  -­‐  like  two  players  trying   to  pick  up  the  same  item  from  the  floor.

(7)

Context:  Game  Concepts

Some  key  concepts  of  “our”  game  are:

• LocaBon:  Each  player  has  a  locaBon  that  she   manages.

• Visits:  Players  can  visit  friends’  locaBons:  Players   are  either  “at  home”  or  “at  a  friend’s  locaBon”.

• Offline:  A\er  some  inacBvity,  players  become  

offline.  This  means  that  other  player  can  no  longer   see  or  interact  with  them  (they  “le\”  the  game).

(8)

Context

Examples  of  Game  AcCons SynchronizaCon  Strategies

(9)

Examples  of  Game  AcBons

Imagine  this  scenario:

• Players  manage  their  garden  with  a  lot  of  fruit   trees.

• Players  can  chop  down  trees,  pick  fruits,  sell  fruits,   plant  new  trees  etc.

• Players  can  visit  other  player’s  locaBon  and  can  do   the  same  acBons  there  as  they  can  do  in  their  own   garden.

(10)

Examples  of  Game  AcBons

PosiCve  example:  Something  we  can  handle  easily

• Players  can  add  stones  to  a  stone  pyramid  at  the   bo]om  of  a  tree.  The  higher  the  pyramid  the  

more  fruits  any  player  can  pick  from  the  tree.

• Internally  this  would  probably  be  increment   operaBons  on  an  integer  keeping  track  of  the  

number  of  stones.  Easy  unless  you  have  overflow.

(11)

Examples  of  Game  AcBons

NegaCve  example:  A  conflict  we  cannot  handle

• Player  A  is  trying  to  chop  down  a  tree  while  player   B  is  trying  to  climb  that.

• Only  one  acBon  can  (or  should  :-­‐)  )  win.  Either  

player  A  or  B  should  do  their  acBon,  but  not  both!

(12)

Examples  of  Game  AcBons

Indifferent  example:  Something  we  might  handle

• 5  apples  lie  on  the  floor.  Both  player  A  and  B  try  to   pick  up  3.  Then  they  want  to  sell  them.

• We  might  actually  let  both  players  sell  3  apples   because  it  “feels”  be]er  from  the  player  

perspecBve  than  “rolling  back”  one  acBon  and   thus  probably  failing  the  subsequent  sell  acBon.

(13)

Context

Examples  of  Game  AcCons SynchronizaCon  Strategies

(14)

SynchronizaBon  Strategies

A  player’s  client  running  in  a  browser  sends  hRp  

requests  to  a  central  server  whenever  it’s  game  state  is   changed  by  a  player  acCon.

The  game  servers  replays  (and  validate)  the  client   acCon  to  update  it’s  internal  game  state  of  that  

players.

Due  to  communicaCon  lags  (up  to  10  seconds)  the   internal  state  presentaCon  between  client(s)  and   server  is  only  eventually  consistent.

(15)

SynchronizaBon  Strategies

If  two  players  update  the  same  state,  i.e.  they  are  at   the  same  locaCon,  things  get  more  complex.

• Both  clients  and  the  server  have  different  views  on   the  state.

• Client  acBons  may  be  conflicBng,  i.e.  an  acBon  by   one  client  may  make  the  acBon  of  another  one  

impossible  or  affect  its  outcome.

• We  idenBfied  3  opBons  to  approach  this  problem.

(16)

SynchronizaBon  Strategies

OpCon  1:  PessimisCc  conflict  resoluCon

• Before  a  client  does  an  acBon  that  may  result  in  a   conflict,  it  checks  with  the  server  if  the  acBon  is   valid.  Very  similar  to  2-­‐phase-­‐commit  approach.

• The  server’s  state  is  relevant,  clients  have  only   views  of  the  server  state.

• Bad  for  player  experience  as  on  a  click  their  will  a   second-­‐long  delay  to  wait  for  the  server  response.

(17)

SynchronizaBon  Strategies

OpCon  2:  OpCmisCc  conflict  resoluCon

• Client  executes  the  acBon  and  informs  the  server   a\erwards.  Server  then  checks  the  acBon.  Client   may  need  to  roll  back  acBon  in  case  of  a  conflict.

• Conflict  handling  on  the  server  only,  client  may   need  to  rollback  changes.

• Bad  for  player  experience  as  player  acBon  may   suddenly  be  rolled  back.

(18)

SynchronizaBon  Strategies

OpCon  3:  Schizophrenic  conflict  resoluCon

• When  player  B  visits  player  A  a  copy  of  the  game   state  created,  so  that  both  have  their  own  copy.

• Own  acBons  are  simply  executed  and  acBons  by   other  players  are  checked  if  they  are  conflicBng.  

ConflicBng  acBons  are  simply  ignored.

• NegaBve:  Complex  and  conflicts  are  only  delayed   unBl  the  next  session  start  (but  are  less  obvious)

Referenzen

ÄHNLICHE DOKUMENTE

In summary, the absence of lipomatous, sclerosing or ®brous features in this lesion is inconsistent with a diagnosis of lipo- sclerosing myxo®brous tumour as described by Ragsdale

(single-label tree with additional node info, e.g. node type) Elements, attributes, and text values are nodes. DOM parsers load XML into main memory random access by traversing

Es wird keine Haftung übernommen für Schäden durch die Verwendung von Informationen aus diesem Online-Angebot oder durch das Fehlen von Informationen.. Dies gilt auch für

 By clicking on the third icon, the user will be able to go to the main feed of the application (feed), where random photos uploaded by other users will be displayed

In order to estimate the three components described in equation (2), which determine the sign of the asymmetry of the composite error, we must use a specification such that the shape

Das Zweite ist, dass mir im Umgang mit den Schülern im Laufe meiner 20-jährigen Berufstätigkeit doch be- wusster wird, dass beispielsweise die Anzahl der Schüler, die auch

The dead children of Syria command global, not just American, condemnation and action.. For America’s allies and partners in Asia,

9 The quantitative relation between value and price appears in Marx as a law of motion, in the average and over time: as the labour content of any commodity falls, so will