Coder Social home page Coder Social logo

netgame's Introduction

# Netgame
This is a toy game made to experiment with network synronization algorithms.

## Compiling and Running
Compile:
 javac Main.java

Test without the network:
 java Main

Test with the network
 java Main host >/dev/null &
 java Main client localhost

Remove all the generated files:
 rm *.class *.java

## Game States and Their Representation
Game state information:
 The board size is 10x10.
 Each piece can be empty, solid, a rocket, or a player.
 Players and rockets have a direction: NSEW.
 Players have an id =>> 0-15
 Rockets have a lifetime:
  They start with 9 points and lose one every time they move.
  When they have 0 points, they explode.

State representation:
 The game state is stored and transmited as an array of 100 bytes.
 This is a row-major matrix, one byte per tile.
 They byte corresponding to each tile contains:
  2 bits (low) for the type.
  2 bits (middle) for the direction.
  4 bits (high) for an arguments.
   Either a player id or rocket points depending on the type.

## Actions and the State Update Algorithm
There are 6 possible actions: Turn(north, south, east, west), walk, and shoot.
 Each player may act once per turn.
 Actions are stored as a direction and a location (which player).
 This is encoded in 32 bits.
  3 bits (low) for the action.
  7 bits (low) for the location.
  21 bits (high) for the timestamp (turn number)

The state is updated like this:
 TODO

## Network Message Format
All parts of the message format are a byte unless otherwise specified.
Here are the possible messages:
Sent by clients:
 HI =>> Try to connect to a the server.
 PLAY =>> Ask the server for a player to control.
 BYE =>> Disconnect from the server.
 DO timestamp(int) id action =>> Try to perform an action.
Sent by servers:
 PLACE id pos =>> Gives the client a new player to control.
 STATE timestamp(int) board(byte[100]) =>> Announce a new state to a client.
 FULLBOARD =>> Refuse a new client because there isn't enough space on the map.
 FULLPLAYERS =>> Refuse a new client because all 16 ids are taken.
 END =>> Close the server session.

## Timing and Syncronization
TODO

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.