Multi-Group Network Game Project A Project By: Erez Gazit and Sagi Katz.

31
Multi-Group Network Multi-Group Network Game Project Game Project A Project By: Erez Gazit and Sagi Katz

Transcript of Multi-Group Network Game Project A Project By: Erez Gazit and Sagi Katz.

Page 1: Multi-Group Network Game Project A Project By: Erez Gazit and Sagi Katz.

Multi-Group Network Game Multi-Group Network Game ProjectProject

A Project By:

Erez Gazit and Sagi Katz

Page 2: Multi-Group Network Game Project A Project By: Erez Gazit and Sagi Katz.

AgendaAgenda

• Project description.• Project goals.• Overview of network platform.• Network platform explanations.• Overview of the game.• User interface overview.• The way it works.• Challenges and their solutions.

Page 3: Multi-Group Network Game Project A Project By: Erez Gazit and Sagi Katz.

Project descriptionProject description

The project is a multi-group networked version of the classic “Capture the flag” type of game.

It divides into two parts: – The network platform:

• The platform is responsible for communications between groups and within the groups.

– The game:• The implementation of the “capture the flag” algorithms

and its interfaces.

Therefore, this presentation also divides into two parts: The network platform presentation and a presentation of the game.

Page 4: Multi-Group Network Game Project A Project By: Erez Gazit and Sagi Katz.

Project GoalsProject Goals

Creating the multi-group networking platform.– It should be able to support:

• The connection establishment, and maintain communications.

• A wide variety of applications (Platform is generic).

Designing the game: “coOperation”. Creating a simple interface between the two parts

of the projects.

Page 5: Multi-Group Network Game Project A Project By: Erez Gazit and Sagi Katz.

The Network PlatformThe Network Platform

A multi-group networking platform.– Network communications are divided into a tree of

connections. Each session member is part of a group.

– All communications from session member go only to his group leader.

Each group has a group leader.– Group leader is also a session member in the group, and

sends data to his group leader – himself. Communications go through the session leader.

– Only group leaders send their data to session leader.– Some internal group messages are not sent to session leader.

Platform usage through multiple-groups strategic game.

Page 6: Multi-Group Network Game Project A Project By: Erez Gazit and Sagi Katz.

Why connection tree?Why connection tree?

Information security:– Internal group messages need never leave the group network.

Delay:– All messages need to pass a max of 4 arcs.

Synchronization:– Two levels of synchronization:

• Synchronization inside group.• Synchronization between groups.

Programming:– Each role can be implemented separately and in a different

thread than the other.

Page 7: Multi-Group Network Game Project A Project By: Erez Gazit and Sagi Katz.

Platform 1 on 1.Platform 1 on 1.

The network platform has three major parts:– Session construction.

• How do all the members of the session connect and assume their roles?

– Communications flow.• How does information get from one session member to

another member or group?

– Handling disconnections.• What happens when a Session member, Group leader or

Session leader disconnects?

Page 8: Multi-Group Network Game Project A Project By: Erez Gazit and Sagi Katz.

Step 1: Session construction:Step 1: Session construction:

Every member connects to external host server.– Host server address is ‘known’ to all.

Host server organizes the members into groups, and creates group leaders and the game leader.– Leader roles are usually given on a first come first

served method. Everyone disconnects from the external host with

knowledge needed for connecting to other session members.– When connecting to host server, each client sends port

numbers it will be listening to.

Page 9: Multi-Group Network Game Project A Project By: Erez Gazit and Sagi Katz.

1st connection:Session LeaderGroup 1 LeaderGroup 1 member

2nd connection:Group 2 Leader

3rd connection:Group 1 member

4th connection:Group 1 member

5th connection:Group 3 Leader

6th connection:Group 2 member

Host server

And so forth and so forth…

Page 10: Multi-Group Network Game Project A Project By: Erez Gazit and Sagi Katz.

Session Leader

Group Leader 1Also Session leader

Group Leader 2

Group Leader 3

Also Group Leader

Also Group Leader

Also Group Leader

Page 11: Multi-Group Network Game Project A Project By: Erez Gazit and Sagi Katz.

Step 1: Connection builder:Step 1: Connection builder:

Starts group leader and session leader hosts for future use.– Hosts used in case member becomes group leader or session

leader. Connects to external host.

– External host address is specified by user. Creates GUI for writing alias and selecting group (and role

in some cases).– First to connect also picks number of groups and number of

members in group. Is usually also session leader. Writes all members’ data in global list to be used in

session. Disconnects from external host, sends data to net-manager

and exits.

Page 12: Multi-Group Network Game Project A Project By: Erez Gazit and Sagi Katz.

Step 2: Communications Flow:Step 2: Communications Flow:

Every member sends data to group leader. Group leaders collect data from all members, process it,

and send it to session leader.– Internal group messages are not sent to session leader, but

remain in group. Session leader collects data from all group leaders,

processes it, and sends it to group leaders.– Normal messages are only sent after all group leaders send

their messages.– Most messages are sent back ‘as is’, with the exception of

special messages (disconnections, etc.) Group leaders send data to group members. Each member uses its new data.

Page 13: Multi-Group Network Game Project A Project By: Erez Gazit and Sagi Katz.

Step 2: Net-manager:Step 2: Net-manager:

Receives global list of addresses from connection builder.– List used throughout the session and updated upon disconnections.

In charge of connecting clients to hosts and maintaining connections.

– Hosts and clients are external threads that send messages to functions in net-manager.

Presents simple send function to outside program.– Outside program only has to add header and dest. to message and run

send function. Contains routines for sending the messages:

– Currently, routine is group leader collects messages from all group members and sends to session leader who collects from all group leaders and sends all data back to group leaders.

Currently, outside program (game) determines interval between sending of messages.

Page 14: Multi-Group Network Game Project A Project By: Erez Gazit and Sagi Katz.

Handling disconnections:Handling disconnections:

“Normal” group player disconnection detected by group leader.– Message is sent through game leader informing of disconnection.– Player removed from group and from game.

Group leader disconnection detected by group and Session leader.– New group leader from group waits for group to connect and

announces disconnection to session leader.– Old group leader removed from group and from game.– If Group empty then session leader removes group, and removes old

group leader from game. Session leader disconnection detected by group leaders.

– New session leader is taken from old session leader group, or next group if empty.

– New session leader waits for connections from group leaders and resynchronizes game, and announces disconnection of old session leader.

Page 15: Multi-Group Network Game Project A Project By: Erez Gazit and Sagi Katz.

Handling disconnections:Handling disconnections:

Divides into two parts:– Intentional disconnection:

• Program sends message to all about disconnection and waits for everyone to disconnect from him, and closes client and host threads.

– Accidental disconnection:• Usually occurs when program abnormally exits, or computer locks

up.• The clients and hosts that detect disconnection send message to

all and close threads to disconnected member.

After a session member is disconnected, it is remarked in all other members’ global lists.

Page 16: Multi-Group Network Game Project A Project By: Erez Gazit and Sagi Katz.

Overview Of The GameOverview Of The Game “Capture the flag” kind of game

– The goal of each group is to get the flag of the other teams and get back to the base.

– The winning group is the one whose flag wasn’t taken.– Capabilities of the tanks:

• Moving around– Tanks can be moved in 4 directions (up,down,left,right)

• Shooting– Every player can shoot all the other players.– After being shot 10 times a player will be disabled (killed).– The base (which contains flags) of each team can be destroyed after 20

shots.

• Hiding– Every player can cloak so only his team members can see him.– When being in cloaked state, the player can’t make any moves. This is

a good way to make ambushes.

Page 17: Multi-Group Network Game Project A Project By: Erez Gazit and Sagi Katz.

User InterfaceUser Interface

Input methods:– Tanks may be moved and operated by clicking around the tank

to make it move, or double clicking to make the tank shoot.– Another way to control the tanks is pressing on the buttons on

the right side of the screen or just using the keyboard. Menus

– Connect• Connect• Disconnect• Exit

– Options– Help

• Instructions• about

Page 18: Multi-Group Network Game Project A Project By: Erez Gazit and Sagi Katz.

Connect menu– Connect:

• This will trigger the “connection builder” and ask the user which group he wants to join

• In case the user is the first user to join the game, he will be asked for the number of groups and the number of members in each group.

– Disconnect:• Choosing this option will disconnect the user from

the other users (he will be treated as if he died)

– Exit:• This will exit the program after disconnecting.

User InterfaceUser Interface

Page 19: Multi-Group Network Game Project A Project By: Erez Gazit and Sagi Katz.

Option menu– Choosing the “options” option will bring up

the pop-up menu shown below which contains the following:

• Host IP and host port number of the constant server which helps creating the game

• Resolution choosing box• Performance scroll bar• Music on/off check box• Manual scrolling on/off check box

User InterfaceUser Interface

Page 20: Multi-Group Network Game Project A Project By: Erez Gazit and Sagi Katz.

Help menu– Choosing the “instructions” in the help menu

will bring up a pop-up window with internet explorer that shows the help files in HTML format

User InterfaceUser Interface

Page 21: Multi-Group Network Game Project A Project By: Erez Gazit and Sagi Katz.
Page 22: Multi-Group Network Game Project A Project By: Erez Gazit and Sagi Katz.

The Way It WorksThe Way It Works

Game_form

Game_manager

Net_manager(initalizes the

connections andmaintain them)

Game_algo

Game_object

Page 23: Multi-Group Network Game Project A Project By: Erez Gazit and Sagi Katz.

The Way It WorksThe Way It Works

game_manager

Send

processcommand

game_algo

Player(1,1) object

Player(2,1) object

Player(3,1) object

Player(n,1) object

Player(1,2) object

Player(2,2) object

Player(3,2) object

Player(n,2) object

External interactor

User

inpu

tUp

date

scr

een

Page 24: Multi-Group Network Game Project A Project By: Erez Gazit and Sagi Katz.

The Way It WorksThe Way It Works

net_managerClock (timer)

1 sec. intervals

inpu

t

command variables

previous commandsend

Page 25: Multi-Group Network Game Project A Project By: Erez Gazit and Sagi Katz.

Challenges And Their SolutionsChallenges And Their Solutions

Flickering effect– When scrolling the map there is an effect of

disappearing items.– This effect arises from the fact that the

background map takes a lot longer to draw on the screen than the objects on the map (like the tanks or flags).

– Solution: draw all the object that should appear on the screen into a buffer first.

Page 26: Multi-Group Network Game Project A Project By: Erez Gazit and Sagi Katz.

game_form write to buffer

draw toscreen

game_form

drawbackground to

screen

Page 27: Multi-Group Network Game Project A Project By: Erez Gazit and Sagi Katz.

Challenges And Their SolutionsChallenges And Their Solutions

Creating and managing the background map– We thought of 2 ways for implementing the map

• 1) Sprite mapping– The map is actually a matrix of numbers where each number

is actually an index to a bitmap.– Advantages:– This method is very effective when trying to cut back on

memory usage (it is used in many commercial games)– Scrolling is very fast– Disadvantages:– There is a need to create many small bitmaps to create the full

map and make sure that the bitmaps match.– Need to create the matrix and assign numbers for the bitmaps

Page 28: Multi-Group Network Game Project A Project By: Erez Gazit and Sagi Katz.

Challenges And Their SolutionsChallenges And Their Solutions

Creating the background map• 2) Treating the map as an object

– This way we just load the map and use offsets from the origin to specify a position (for scrolling and object placement)

– Advantages:– Easier to program (no need for any matrix building)– Easy to load and maintain the map– Disadvantages:– Consumes a lot of memory– There is a need to analyze the map (water detection)

Page 29: Multi-Group Network Game Project A Project By: Erez Gazit and Sagi Katz.

Challenges And Their SolutionsChallenges And Their Solutions

Problem of water detection:– We thought of 2 solutions:

• 1) Deciding between land and water by the color– Disadvantages:– Very hard to decide only by color– Limits the colors of the objects– Very hard to implement (many cases to be checked)

• 2) Creating a matrix that contains different values for land and water

– A matrix could be created by using applying threshold effect– Advantages:– Easy to create the matrix (load the B/W bitmap)– Pretty accurate– Very easy to program

Page 30: Multi-Group Network Game Project A Project By: Erez Gazit and Sagi Katz.

Challenges And Their SolutionsChallenges And Their Solutions

Page 31: Multi-Group Network Game Project A Project By: Erez Gazit and Sagi Katz.

Challenges And Their SolutionsChallenges And Their Solutions

Moving objects simultaneously on the screen– There is a difficulty in moving several objects on the screen

simultaneously– We didn’t want to create a thread for each moving tank (too

much overhead)– Our solution was to get and process all of the commands from

the network and wait for a “special” command that indicates an “end of a round”.

– Only after getting the special command do we act according to the commands that we got earlier. This way we have all the information to move all the objects together.

– The simultaneous moving of the objects is done by going over all the objects n times while moving each one of them 1/n of the way.