cs244b Review Session 1 Mazewar 4/3/2009

Assignment 1 – Mazewar
Review Session
CS244B Distributed Systems
April 4th, 2014
Wei Shi, Stanford University
1
Agenda

Logistics

Mazewar

Game rules

Protocol design

Implementation
2
Logistics

0% Teams: due April 4, 2014, 11:59pm - Jointly

40% Design: due April 10, 2014, 11:59pm - Jointly

40% Program: due April 21, 2014, 11:59pm - Individually

20% Questions: due April 21, 2014, 11:59pm – Individually

Demo tentatively the week of April 21

Will post sign-up sheet on Piazza

Local students: in myth clusters(Gates basement)

SCPD: at least one member comes to campus; others join remotely
3
Game Rules

Rat control


(Done) Movement with a,s,d,f
 (Done) Peek left/right with Mouse Left/Right button
 Launch missiles with Mouse Middle button
Scoring


Shoot projectile: -1
 Hit opponent: +11
 Opponent hits you: -5
Player’s view


(done) Map view that shows other players
Rat’s view that shows missile
4
Game Rules





Only one rat can occupy a square at a time
Rats hit by others should respawn at an unoccupied random
location instantly
Cool-down time for firing (time up to you)
Multiple missiles can occupy the same space (speed up to
you)
One projectile can hit at most one rat
5
What You are Given

Implementation of the graphics

Implementation of the basic control

Stub code for setting up UDP multicast

Event loop (void play())

Receives Packets

Keyboard events

Timer events (EVENT_TIMEOUT)

Default is 500ms, defined in winsys.cpp
6
What You Need to Edit

netInit()


Stub networking code in place
Most of your work will be editing play()

Main event loop

Receive packets and update local state

Change local state and send packets
7
Protocol Design

Team creates protocol, members implement
individually


At most three team members
Must be distributed

Can't have central point of failure

Over UDP Multicast

Must deal with lost packets in a reasonable way
8
Protocol Assumptions

Players know the UDP multicast group for the
game

No cheating

One standard maze

One game per UDP multicast group

Defined as MAZEPORT in mazewar.h

To be posted on Piazza after team registration
9
Protocol Hints

Determine shared state

Which state is shared by which clients?

How will sufficient consistency be maintained?


Who are the readers/writers of each piece of state?
Create the protocol which will define

Syntax - clients agree on format of messages

Semantics - clients agree on meaning of messages
Timing - clients agree on timing semantics

10
Protocol Hints

Use network byte order(use htonl(), etc.)

When are ACKs needed?


As opposed to "fire and forget" packets

A believes he shot B. Do they need to agree?

A, B both believe they shot C. What do they do?
Joining / Exiting game

How do players discover each other?

How should failures / network congestions be handled?
11
Protocol Hints

There’s absolutely no globally synchronous clock

Ensure inconsistencies don't accumulate

Think about the tradeoff of the size or frequency of
the packets
12
Protocol Example
Latex: \usepackage{bytefield}
13
Implementation Hints



Look at the code early

Implement some local functionality, e.g. launch missile

Will help you think about your protocol

Starter code is heavily influenced by CS249 framework
Start testing interoperability ASAP
Test with simulated packet loss (commented out in
starter code)
14
Implementation Hints

Develop/test/grade on myth clusters

ssh –X myth.stanford.edu (enable X forwarding)


If you wish to develop locally, you might encounter
errors.
Try sudo apt-get install

libxaw7-dev (if missing X11/Xaw/Cardinals.h)

libx11-dev (if missing X11/stringdefs.h or X11/xlib.h)
15
Starter Code
•
•
•
•
•
•
ssh –X myth.stanford.edu
cd /afs/ir.stanford.edu/class/cs244b/mazewar
cp MazewarSpring2014.tar.gz ~/<your directory>
cd ~/<your directory>
tar –zxvf MazewarSpring2014.tar.gz
Develop!
16
Mazewar
Demo
17
Questions?
Post your questions on Piazza
https://piazza.com/class#spring2014/cs244b
18