• 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
Truman

Server Side Programming

11 posts in this topic

Our game is going to have a turn based strategy battle system. Naturally, it would be really awesome to be able to battle your friends. So I am planning to write a Ruby on Rails server side program to coordinate connecting a player with a friend or random stranger for a single battle.

My goal is to keep the server load to a minimum, which means a few design decisions that make sense at the moment, but server stuff is a little new for me, so please feel free to tear holes in these decisions and/or enlighten me on issues I may have missed.

First off, it seems like a good idea to throttle down the frequency that the client side program checks the server for new information, say at most once per second.

Second, it seems like doing all battle calculations client side and then sending the results through the server to the other client would cut down the server load, and also simplify it so that I am not reproducing core C++ game logic in ruby on the server. This would probably work as follows, client A performs an attack that effects units 1 and 2 in the battle field, upload the attack name and the effects to the server. Client B checks the server and pulls the info, then simulates the attack, but in reality just applies the effects that client A uploaded. Rinse and repeat.

I like the simplicity of this process, but it seems fairly ripe for cheating. How easy would it be for the person controlling client A to fake the data sent to the server so that they actually do more damage than the game calculated (which would seem to get the two games out of sync and venture into undefined territory)? Is this really worth worrying about? The target will initially be iOS and Android, does this make it more difficult to cheat?

Are there any unknowns that I should be more worried about, like packet loss? I have a contingency plan to deal with people disconnecting, but there might be other things I haven't thought about.

I'm looking forward to hearing any thoughts.
0

Share this post


Link to post
Share on other sites
[quote]First off, it seems like a good idea to throttle down the frequency that the client side program checks the server for new information, say at most once per second.
[/quote]

This is one of the reasons that web stacks, like RoR or PHP or whatever, are poor matches for game-style networking that requires interactive, "push" notifications. You should come see me talk at GDC Europe in August on this exact topic :-)

[quote]How easy would it be for the person controlling client A to fake the data sent to the server so that they actually do more damage than the game calculated[/quote]

Very easy. It's done all the time in games that have client-side authority and are popular enough that players care.
2

Share this post


Link to post
Share on other sites
[quote name='hplus0603' timestamp='1341683258' post='4956687']
[quote]How easy would it be for the person controlling client A to fake the data sent to the server so that they actually do more damage than the game calculated[/quote]

Very easy. It's done all the time in games that have client-side authority and are popular enough that players care.
[/quote]

There are even generic tools (CheatEngine for example) That simplify this process to the point that even amateurs with no programming knowledge can cheat in these games with relative ease, so the game doesn't even have to be popular to get hit by cheaters if you do this.
0

Share this post


Link to post
Share on other sites
[quote name='Truman' timestamp='1341679085' post='4956666']
My goal is to keep the server load to a minimum, which means a few design decisions that make sense at the moment, but server stuff is a little new for me, so please feel free to tear holes in these decisions and/or enlighten me on issues I may have missed.
[/quote]

[quote name='Truman' timestamp='1341679085' post='4956666']
Second, it seems like doing all battle calculations client side and then sending the results through the server to the other client would cut down the server load, and also simplify it so that I am not reproducing core C++ game logic in ruby on the server. This would probably work as follows, client A performs an attack that effects units 1 and 2 in the battle field, upload the attack name and the effects to the server. Client B checks the server and pulls the info, then simulates the attack, but in reality just applies the effects that client A uploaded. Rinse and repeat.
[/quote]

Since this sounds like it's not a web-based game, I'd suggest developing/implementing much of the game logic in C++ on the server, and abandoning using HTTP and web scripting for this. Server-side may be new to you, and writing a multi-threaded server with game logic may be a difficult undertaking, but it achieves the best results. It's pretty fantastic the first time you connect to your own game server from a mobile device, or from any game client for that matter.

I have done some development on Android; for game lobbies and player authentication we send XML-based messages over a SSL/TLS layer to our own server; for turn-based we also use XML, and for live games we marshal game updates to/from the server in whatever binary format we want. We use Linux for our servers, and choose arbitrary ports for clients to connect to. In all cases the connections are live and interactive, unlike HTTP which requires you to present session data for each request and doesn't really give you simple bidirectional communication that is used in games.

As long as the server makes the important decisions and the client just sends the player's intentions and presents/displays/animates the results, you can limit or prevent cheating. If the client can be modified to make better decisions or precise calculations for the player to their benefit, then even in the best scenario, a player can "cheat". If the game is designed such that there is no perfect or precise decision for a modified client to make, then you can effectively prevent cheating.
2

Share this post


Link to post
Share on other sites
But is this whole memory scanning (like CheatEngine) a real issue on mobile devices? It seems like these are a bit more locked down and more difficult to mess with, but maybe I am just being naive.

Assuming that the internal variables of the client side C++ program can not be modified while the program is running, and only the HTTP posts are being faked, could I do some sort of verification thing like this. Say Player A attacks one of Player B's units. Client A (presumably) calculates the damage correctly, but Player A fakes the HTTP post to say that he did more damage. Then Client A on it's next interaction with the server, double checks that the posted damage corresponds with its own internally calculated value. If the values differ, penalize Player A for cheating.

I guess this all assumes that Player A cannot modify the program state while it is running. Is this a fair assumption (at least for iOS and Android)? What are the holes in my argument?

I could see how the server side C++ program would create a more professional and cheat proof user experience, but it seems like it would magnify the server load by orders of magnitude.
0

Share this post


Link to post
Share on other sites
Cell phones can be "rooted" and cheats installed, but those are so far less pervasive than PC cheats. You have to make a judgement call here.
The described mechanism for detecting cheating wouldn't work, because the person who fakes the HTTP post for one turn, can easily fake it for the next turn, too. In fact, player A doesn't need to be running your client at all; he could just be posting the right set of HTTP requests.
If you compare player A and player B, and they have different outcomes, you don't know which one is cheating, and which one isn't. Or maybe there's just a bug in the program -- you shouldn't ban players for your own bugs.

1

Share this post


Link to post
Share on other sites
For some reason I was making the assumption that the flops coming from my game calculations would represent a significant server load, but when you put it into the context of running the Ruby stuff plus the reality that communication is going to be the real server load, it makes a lot more sense to try to limit the communication traffic. And if HTTP is a lot more verbose than setting up a socket, then it seems like a better idea to learn about some socket programming.

I am thinking about writing the client side program in Lua using [url="http://getmoai.com/"]Moai[/url]. Does anyone have any recommendations for the server side program? I am comfortable with C++, Python, and Lua. From some initial research, it looks like [url="http://www.zeromq.org/"]ZeroMQ[/url] comes highly recommended. My main concern with it is its LGPL license. It seems to be safe to dynamically link to it, and I know how to do this on Unix based systems, but I'm not so familiar with packaging and distribution procedure on Windows and mobile devices (this is probably not the best place to ask this, I know).

Does anyone else have any other recommendations for writing a scalable server side program?
0

Share this post


Link to post
Share on other sites
I suggest you to write the server with c++ and use winsock or berkley sockets. Bjeez guide to network programming explains everything you basically need to know about socket programming and little bit of planning how to write the networking will make it scalable. Once you learn to use them you really do not need anything else, except writing way to handle the packets which those higher level networking libraries offer.

One thing i find funny about ZeroMQ is that they say their transport system is faster than TCP, but under it they say that the messages are also carried over TCP. Really fucked up marketing. inprof, IPC are inter process communication systems and multicast afaik means just sending the packet to many clients. Edited by TMKCodes
0

Share this post


Link to post
Share on other sites
After some reading, it looks like for the most part, you are not allowed to do dynamic linking on iOS, so it looks like ZeroMQ is out. Any other suggestions for cross-platform scalable game servers? I would prefer to not reinvent the wheel with this.
0

Share this post


Link to post
Share on other sites
I dont know about iOS, but i know that friend wrote networking for kingdom island iOS game and used poco for networking and i think he also used moai.
0

Share this post


Link to post
Share on other sites
For a turn based game just make a server and run your full game logic on the server for each match, you can get a 1GHz VPS for $30/mo which should be able to run thousands of your game servers. Enet is statically linked so you can use it.
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