Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (576)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: 1 [2]
  ignore  |  Print  
  Questions on Network Implementation  (Read 5352 times)
0 Members and 1 Guest are viewing this topic.
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 816
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #30 - Posted 2012-11-18 07:50:39 »

Cas decided to use ints for most logic, and it's more than enough accuracy. We didn't even resort to (cumbersome) fixed point decimals. Just make your base unit small enough (like 1mm or less). For most 2D games, this is enough, and makes your game deterministic across clients/platforms (assuming latency doesn't affect logic).

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline delt0r

JGO Knight


Medals: 27
Exp: 18 years


Computers can do that?


« Reply #31 - Posted 2012-11-20 15:53:54 »

If your using UDP and don't know what the 2 generals problem is, or what flow control is, or why TCP has the handshaking it does to establish a connection, then i guarantee that as soon as the network is poor enough for you to notice packet loss with TCP. Your UDP solution will collapse.

Sure it works well when everything is peaches and roses. But that is *not* the same as faster/better than TCP. And what did you gain? Even AAA titles are moving to TCP now. And many of these titles have pretty crappy network code. 

Of course there are situations where UDP works well. Fixed rate full state per packet is one of them.

I have no special talents. I am only passionately curious.--Albert Einstein
Offline teletubo
« League of Dukes »

JGO Ninja


Medals: 48
Projects: 4
Exp: 8 years



« Reply #32 - Posted 2012-11-20 18:47:31 »

You have a server with an authoritative game state from some time in the past Si. At set intervals, for any period of time in which it has inputs from all of its clients, it will simulate the game state to a new authoritative state at time Sf, and then send this to all of its clients.

The clients will then revert their game states to Sf, discard all cached inputs before Sf, and then use the remaining ones to interpolate the game state up to time N, the actual current game time. To simulate the other client players, they will simply guess based on the last input given to them.

Whenever the clients update, they will continue to cache inputs for that period of time, and also send their inputs to the server.


So does that sound about right? Is there anything I can do to improve how a client guesses what the other clients are doing? Or just improve it in general?

 

I don't think there's an specific answer to your question, until you drill down to what kind of game you want to make. Some strategies might work better for some kind of games, and some for the other.

To be honest I don't believe what you described could be very good, except for turn based games, unless the tick rate of your server is extremely high (which would easily saturate your network).

In a real-time game I would recommend the server to run the game as it were in the client: full logic at N ticks per second, process the player inputs as they come, broadcast it to everybody.

Now here it comes when I said the type of game:
If it is a FPS, let's say Quake, players are likely to keep moving, rotating, dodging,shooting, at a very high rate; so you might want to have a packet being sent very often updating the players position.  

However, if you have an action-rpg, think of Diablo, you don't need such high rate of packages. (now I'll tell you from experience. This is exactly how I implemented my online game Reign of Rebels).
You basically just need a package when an entity moves, or attacks (or performs any significant action).
Let's say you have entity A standing on point  10,23  and the player (or the AI) directs it to move to point (14, 25). The client will send the message that it wants to move, server receives it and broadcasts this. Just 1 package exchange and you'll have the entity performing the exact same move on the client and on server. When the entity hits is target, it will stay there until further orders are given. No need to send a shitload of packages telling that the entity A is standing in position 14,25.  
This strategy might even work in some more fast paced games where your Physics/pathfinding is deterministic.

Of course you would use some interpolation tricks to make things smooth (some of which I discussed here ), but this is definitely a solution for this kind of game.

Maybe if you show us a video of a game similar to yours, we can give better suggestions on how to implement it.

As for TCP/UDP: Just go for TCP. You have already too much to worry in the making of a game, just let TCP handle some of the headache for you.



Pages: 1 [2]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Longarmx (38 views)
2014-10-17 03:59:02

Norakomi (28 views)
2014-10-16 15:22:06

Norakomi (24 views)
2014-10-16 15:20:20

lcass (28 views)
2014-10-15 16:18:58

TehJavaDev (52 views)
2014-10-14 00:39:48

TehJavaDev (54 views)
2014-10-14 00:35:47

TehJavaDev (42 views)
2014-10-14 00:32:37

BurntPizza (64 views)
2014-10-11 23:24:42

BurntPizza (36 views)
2014-10-11 23:10:45

BurntPizza (78 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!