• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Rasterman

Generic C memory compression / packing

7 posts in this topic

I'm working on a new networking project, a RTS game, and going with a server client model. To sync the clients I am planning to use delta comparisons on the server, only update client view units quickly, and use selective memory packing, meaning only sending bytes, words, or dwords that have changed. To do this I wrote some very simple packer/unpacker routines, and will have some custom ones for faster updates. I was just curious if anyone knows of any articles or other forum threads on this subject? The only thing I could find was an article here http://sirisian.com/blog/binary-packet/ but it is regarding packing bit by bit, which I am not going to do since I think it would be too CPU intensive for a mobile game.
0

Share this post


Link to post
Share on other sites
Google's Protocol Buffers might be interesting, although I'm not sure how they measure up in terms of relative computational efficiency on a mobile device.
2

Share this post


Link to post
Share on other sites
[quote name='Rasterman' timestamp='1333581154' post='4928327']
The only thing I could find was an article here [url="http://sirisian.com/blog/binary-packet/"]http://sirisian.com/.../binary-packet/[/url] but it is regarding packing bit by bit, which I am not going to do since I think it would be too CPU intensive for a mobile game.
[/quote]
CPU intensive for who? The client is basically just sending input that might only a be a few bytes. It depends on how twitchy your game is, but since you mentioned mobile I'll assume it's not a 400 apm RTS game. Then for getting the state I'm imagining a fixed update rate that's fairly low like 200 ms at the most? (5 updates per second). Assuming you're not updating hundreds of units at once and are doing sane delta updates I don't think you'd hit anything that would be that CPU intensive to deserialize coming from the server.

That said I wrote these two writers. [url="http://ideone.com/G8rxs"]C++ version[/url]. [url="http://ideone.com/StlDA"]C# version[/url]. They are simple binary writers/readers which I wrote for someone that was developing between languages. Basically what's going to help you more than anything is sane delta compression. Not sending anything the client already knows about. Your server should be 100% aware of what the clients know and intelligent in building the per client packets. (I'd give you more information, but I removed my old articles online relating to this so I could rewrite them. Been meaning to get back to that).

// edit also I see my robots.txt isn't stopping people from finding my blog. Interesting.
1

Share this post


Link to post
Share on other sites
Thanks for your input, both useful posts :) After reading your binary-packet article again, that is basically what I am doing, except for boolean values I'm simply using a byte rather than misaligning the data and packing it bit by bit, I'm packing it byte by byte. And I think it may be too CPU intensive for the server, since the server will also run on a mobile device, and be doing all of the game simulation, and overhead for calculating data deltas for all clients. If I have to limit the number of clients to 1 that is not a problem, and currently my game does support 1000 mobile units per players, up to 4 players, but if that needs to be limited for network play that is not a problem either.

I'm thinking using delta updates and only updating quickly for units in the clients currently active viewport will hopefully be enough to limit the bandwidth. I'm adding this to an already completed and mature game, so don't have the luxury of making a predictive system. My goal also isn't to make a 100% perfect sync, as long as its playable and pretty close I will be happy.
0

Share this post


Link to post
Share on other sites
Spent the day testing delta bandwidth. Last test was 2 players with 200 offensive units total (400 including buildings), it averages about 400 kB/s with an estimated 25% of waste, this is for all 400 units every frame. If I backoff the static units and the units outside of the clients viewport to update less it drops down to 60-150 kB/s with 25% waste, so with simple optimization I could get that down to 50-100 kB/s, that seems pretty reasonable. This is at an update rate of 30 fps, so if the game can handle less updates automatically say 5 fps then that would drop to 10-20 kB/s.
0

Share this post


Link to post
Share on other sites
150 kB/s is at least 20x too much for an RTS. If you use an input-synchronous model (a la Age of Empires, Starcraft, Warcraft, etc) then you only need to send commands, and re-calculate unit movements/actions on all clients.
0

Share this post


Link to post
Share on other sites
[quote]I could get that down to 50-100 kB/s, that seems pretty reasonable.[/quote]

For a 30 minute session, that's ~180 megabytes. So 6 hours of gameplay will break 1GB/month limit that many devices come with. Some low-end plans only come with 100MB of data or so. These numbers start approaching video on demand.

At $0.1 per MB over that, it would be $36 per hour of gameplay. That is, simply put, insane. Unless you're running a 1-900- business. Honest advice, if planning on distributing such an app, it better come with a huge warning, or you may bankrupt people.

For a RTS, with dedicated protocol, think tens of bytes per second instead.


Even if costs weren't a problem, network reliability is. A small delay will mean corresponding pile-up of data, which isn't biggest problem, but considering the way naive serialization works it may cause bursts of multiple megabytes on spikes.
1

Share this post


Link to post
Share on other sites
FYI my game is now working in multiplayer [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] Took 50 days, now testing over LAN and with simulated lag. Turned out to work better than I had anticipated using state change notifications, which amounts to about 3KB/s of data with 50-100 units, and upwards of 15KB/s with 500 units. The client isn't perfect, units sometimes get out of position and are lerped to their correct locations. For adding networking to such a complicated game after the fact I am pretty happy with it. I also do a full update on one unit per timeslice, which I should probably increase if the connection is on broadband. Edited by Rasterman
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0