Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 18 Oct 2005
Offline Last Active Yesterday, 11:49 PM

#5240676 Multy player Game limit per area

Posted by SimonForsman on 15 July 2015 - 09:49 PM

Really server side as long as you're not rendering the actions of players you could have a huge number of people in one spot from what I know. It's just making them appear on screen that is the issue.



Not really, more players in an area = more events occuring and more players that you need to send each piece of data to which cause outgoing bandwidth requirements to scale exponentially as you increase the number of players in an area.


When we hit MMO scale (10.000+ players) we can do a bit of fun math:


lets say we use 2 8 bit values for x,y (delta)  , don't use z and orientation as a 8 bit value and send each player the position and rotation of all other players 10 times per second then we would send 9999*10000*10*24 bits per second or ~24Gbps,


by splitting those same players up into 1000 instances/areas with 10 players each we would only use 1000*10*9*10*24 = ~2.16Mbps upstream bandwidth for the same number of players and the same update frequency. (most games will require you to send for more data per player but the difference in magnitude stays the same, 1 room with 10.000 players is roughly 1000 times more expensive to host than 1000 rooms with 10 players each if you use a basic approach to networking.


MMOs have to work around this problem by throttling updates based on distance and importance and designing things in such a way that players will spread out (you can't effectively throttle updates based on distance and importance if everyone is having an all out brawl in a small room) and if there is content that alot of players will be doing at the same time you may have to use instancing for that content or make sure players will naturally spread out within that content(There may also be gameplay reasons to use instancing (smaller battles make each players individual performance more important). I would strongly recommend against moving players between instances on the fly (it sounds like it can get incredibly messy as even though it is fairly easy to keep players who are in a group together it will be a nightmare to keep track of interactions between groups (if group A is fighting group B and group C is moving in to pick off whatever remains after the fight you can't really separate those groups either without disrupting gameplay), assign groups to an instance as they enter the content (i.e, as they pass through the dungeon entrance) or design the content in such a way that players will spread out by themselves and add safeguards to deal with high player concentrations.


For pvp dungeons where you want competing groups to fight over the price i would either create dungeons with 2 or more starting points(depending on how many groups I want it) and then treat them like WoW battlegrounds (players queue up for it and start when all groups are ready) or have people join an existing instance when they enter unless all currently running instances are either full or close to finished (probably having the enemy respawn rate and/or enemy power/numbers get reduced in sections the previous groups have pushed through to give those who enter late a good shot at catching up and fighting the ones who started before them without giving them a clear path)

#5239660 Game engine or programming luanguage?

Posted by SimonForsman on 10 July 2015 - 08:22 PM

When i tried to look this up on google some people said that if you know a programming luanguage you can make a better game because you are not limited by what Unity offers but games like:endless legend,cities skylines,rust are made in unity and seem like very good games.Can someone explain me how this works?Do they combine in some ways?


All general purpose engines use one or in some cases multiple programming languages, Those engines take care of the low level stuff (rendering, resource management, physics, sound, interactions with the underlying OS, etc) and provides various tools (level/scene editors, animation editors) + some functionality that lots of games will need (basic pathfinding, a few basic shaders, etc), You can't even make a pong clone in Unity without using a programming language, The editor only lets you create the paddles, walls and the ball and configure their appearance and physics properties and if you set the ball in motion using the editor the engine can make sure it bounces off the walls and paddles.  

You still need to write code that moves the paddles(atleast the AI one, you can probably find a controller component that works for the player paddle in the asset store), counts the score and resets the ball after a player scores.

#5238722 Massive Python Example Script

Posted by SimonForsman on 07 July 2015 - 02:16 AM

I'm not sure if Python supports overloading operators or passing class objects as parameters, forgive my ignorance here, but in languages that do this sort of thing is normally handled as an addition. For example in C++, rather than have a move() method, you would do:

Vec2 a(10, 20);
a += Vec2(5, 4);
In something like Javascript which would not support overloading, you tend to see (not a javascript guy either so this is probably wrong):
var a = new Vec2(10, 20);
a.add(new Vec2(5, 4));
Most of the things you would want to do with vectors when treating them as points in a Cartesian space have an equivalent mathematical interpretation that applies in the far more general sense, where "move" would be the wrong term but "add" is always correct.



in python you can implement the __add__ and __radd__ methods to overload the + operator.  x+y will try to call x.__add__(y) and if the method returns NotImplemented and x and y are of different types it will try y.__radd__(x) instead (if that also fails it will raise an exception)


something like:

class Vector2:
    def __add__(self, v):
        if not isinstance(v, Vector2):
            return NotImplemented
        return Vector2(self.x + v.x, self.y + v.y)
    def __iadd__(self, v):
        if not isinstance(v, Vector2):
            return NotImplemented
        self.x += v.x
        self.y += v.y
        return self
    def __mul__(self, v):
        if not isinstance(v, numbers.Number):
            return NotImplemented
        return Vector2(self.x * v, self.y * v)
    def __rmul__(self, v):
        return self.__mul__(v)
    def __imul__(self, v):

#5237129 If-else coding style

Posted by SimonForsman on 27 June 2015 - 12:11 PM



This isn't strictly game related, but I like you guys so I thought I'd post it here. I work with C# for my job, and we have to undergo code reviews. Yesterday I finished a work item and used code similar to the following in several places:

SomeType GetSomething 
        if (somecondition) 
            return something; 
            return null; 

My code review was completed as "needs work" on the grounds that the above code was "very misleading", which I don't get at all. I understand the "else" isn't necessary here, but I think it not only makes it much more readable, but perfectly follows the way the getter would work if you were to describe it in English: "If this is true, return that; otherwise, return null". Without the else, if you didn't look into the "if" block you might think that the getter ALWAYS returns null. With it, you instantly understand that either the "if" block executes and returns, or the "else" block executes and returns, without even looking at the contents of either of them.

Even if you consider the above to be unnecessary, I still don't get how you could call it misleading. It does exactly the same thing as the alternative he was suggesting (remove the else and just return), only it's much more explicit about it: which is the exact opposite of misleading.

Anyway, I just had to rant about that. I love my job, but everyone I work with is a very experienced coder from different backgrounds, and sometimes our ideologies conflict. What are your thoughts?



Personally i would invert the logic

get {
    if (!somecondition) {
        return null;
    //code goes here
    return something;


This keeps the primary exit point for the function at the bottom and the early return caused by some invalid state sits right at the top.

#5232460 VB.net limitation question

Posted by SimonForsman on 02 June 2015 - 02:45 PM

So if I understand correctly, I am safe to continue with VB.net for my MUDs, but should think about C# if I plan to add pixel-based movement? Most of the graphics in the game i'm working on currently are static images loaded from a file, with only a couple exceptions to some menu stuff that is animated.


Don't worry about it, VB.Net is fast, modern PCs are fast(and by the time you actually release something they will be even faster), pixel based movement and animation is computationally trivial and if you need to do some really heavy data mangling there is most likely a highly optimized low level library available that does it for you regardless of what language you use.


Unless you have a very good reason performance should be the last thing you consider when you choose a language, your primary concern should be platform support(The language you use must work well enough on your target platforms) and after that you should look at things that enhance your productivity (language features, tools, libraries, etc), performance is only a concern if your language makes it difficult to reach your performance targets (and you are almost guaranteed to run into a situation where your chosen language makes it slightly difficult to reach your performance target long before it makes it anywhere near impossible).


I would still recommend looking at C# though but not because it will make your applications magically faster (it won't) and not because it lets you write unsafe code to squeeze a bit of extra performance out(if you need to write alot of unsafe code you might aswell use a low level language) but because it is a very nice language to work with and it has a huge community and tons of great tools.

#5228439 High Score class issues

Posted by SimonForsman on 11 May 2015 - 03:50 PM

Hello, I am having some issues with saving the high score of a game. Can you guys tell me if there is something that looks wrong here? Also, is there a way to read the high score from the existing file when the game starts up, and then set it to a variable so I can display it on the screen? The text file was added as an existing item to the game, it is in the same location as the Game.cs and Game.ico files. Thanks in advance.

    internal class HighScore
        private int number;
        internal static bool onExit = false;

        internal void ReadHighScore()
            FileStream fileStream = File.OpenWrite("HighScore.txt");
            TextReader textReader = new StreamReader(fileStream);

            number = textReader.Read();


        internal void WriteHighScore()
            if (number < Klax.score)
                FileStream fileStream = File.OpenWrite("HighScore.txt");
                TextWriter textWriter = new StreamWriter(fileStream);

                File.WriteAllText("HighScore.txt", String.Empty);


        internal void Update()
            if (PauseMenuScreen.quit == true)       //This is suppposed to trigger the WriteHighScore function in the PauseMenuScreen class
            {                                       //When the user quits, the score will be saved if it is higher than the previous high score



The HighScore.txt file should be in the applications working directory (This is not necessarily the same as the directory containing your sourcecode), if you are using visual studio then the working directory when you run from the IDE will default to the project files directory, if you run from the commandline it will be the directory your executable is in.


The Read method of the textreader class reads a single character (so if your file contains 15345 the read method will return the 32 bit value for '1' (which should be 31 if your system uses any common encoding) , you want to use the ReadLine method instead to read the full line (since you are writing a textfile) and then use Convert.ToInt32(stringYouReadFromTheFile) to get a correct integer value from it.


(There might be other problems with your code aswell)

#5224585 how much xamarin and other cross platform api,s are good?

Posted by SimonForsman on 20 April 2015 - 06:33 PM

For Android, Xamarin runs the Mono Runtime side-by-side to the Dalvik (and/or Android) Runtime. 


I recommend checking out this doc:



For iOS, Xamarin uses an AOT (Ahead of Time) compiler.  

Unfortunately, I don't have a good link to send you that goes into more detail.


And if you're interested in metrics check out this blog post by an ex-googler: 




Those metrics are quite flawed though, J2Obj-C(Java auto-translated to Obj-C) outperforming Obj-C is a pretty clear sign that they are comparing apples and oranges, Xamarin however does perform reasonably well on both iOS and Android as long as you stick with the native API wrappers and don't use the horribly buggy and slow Xamarin.Forms(allthough being able to share your UI code between WP,Android and iOS might make it worth the hassle to get that junk working decently).

#5223243 How to protect the idea?

Posted by SimonForsman on 14 April 2015 - 03:51 PM

So, here's the deal, I've got an idea, and I want to protect it. By that, I am not talking about piracy protection, more like content protection.


Say there's a hypothetical scenario, a fiend hacks into my files and steals that which I plan to put into development, and that thing finds its way into big bucks publishing house and they end up hoarding million for something whose concept I conceived... how can I protect myself from such a scenario outside of making a patent, it being under lock and key?


Don't worry about others stealing your idea, most likely your idea falls into one of three groups:


1. ideas that won't work (too expensive, tech isn't ready, market doesn't want it, the idea is stupid, etc)

2. ideas that recently became feasible due to <something>

3. new ideas that were inspired by <something else>


if your idea falls into 1. but you know how to bring it to 2. then you don't have to worry about others stealing the idea itself, worry about keeping your solution to the problems secret instead (and if possible patent those solutions if they are patentable)


if your idea falls into 2 or 3 then you need to get off your ass and start working, even if you are the first in the world to have the idea and most others who get the idea wrongly place it in 1. you can be fairly certain that someone somewhere will come up with something similar and decide that it is worth persuing, if you sit around and wait someone will beat you.

#5223062 Difficulty of making a strategy mmo?

Posted by SimonForsman on 13 April 2015 - 07:43 PM

Actually, I don't think it would be impossible hard.

If you leave out that initial 'M', of course; the one that stands for 'Massive'.

I think it would be way easier than creating a single-player game because no matter how much Herculean efforts you put into AI, it won't beat human players (no matter how dumb tongue.png) - so, yes: go for it. smile.png

TBH, when it comes to browser/mobile style "MMO:s" that extra M isn't all that difficult, those games tend to only have indirect interactions between players which makes scaling out a heck of a lot easier than it is for MMOs with realtime interaction between players.

#5222597 Looking for step my step guide for visual studio

Posted by SimonForsman on 11 April 2015 - 07:36 AM

Okay, lets say you have a "go scout somewhere" button on screen. Which of the 2 engines will allow me to more easily code:

1) The AI automatically selecting the most suitable unit (or units, depending on designated area size and/if the character has enough skill for it) for the task,

2) Guiding the unit completely automatically until the LOS of the unit has covered every nook and cranny in the designated area at least once,

3) Run away if there is massive enemy presence,

4) Fight other scouts if they are there,

5) Do all of the above that is dependant on: A) Unit's particular skills and B) Character skills and perks


That part is about as hard regardless of which engine/framework you choose, you will most likely have to write most of the code for it yourself, AI is normally not an engine feature.


with unity you could do it using a separate mostly empty gameobject with your high level AI script and have it send off messages with the high level orders to the units (and your UI buttons can pass messages to the high level AI) and then give each unit a script that acts on those orders and make their own lower level decisions.

#5220014 The Atomic Man: Are lockless data structures REALLY worth learning about?

Posted by SimonForsman on 29 March 2015 - 01:26 PM

Hi all

I've been investing quite some time into reading about and experimenting with multithreading in C++ and in general and it seems lockless (or supposedly wait free) data structures and algorithms comes up a lot. A good understanding of the new memory model in C++ and atomics seem necessary for any kind of implementation of lock-free programming, and after reading the top response in this thread:



Is it REALLY necessary to know much about lock-free stuff? Or can I just skip it for the time being, knowing that lock-free programming is a "thing" and leave it at that?



No it is not necessary but it is beneficial. (lock free code can perform significantly better in some situations).

#5216045 Saving old gamestates

Posted by SimonForsman on 12 March 2015 - 07:23 AM

Personally i would skip the copying for a system like this and instead make the old game states immutable. then you can quite easily have multiple threads update the game state (all can read the previous state without synchronization since it is immutable and as long as you don't try to update the same object from multiple threads you can do unsynchronized writes aswell.

#5215024 curious question, how good is Source engine?

Posted by SimonForsman on 06 March 2015 - 03:18 PM

Now that Source 2 is (or going to be) free for content developers (what about game developers?), I would like to ask if some of you have experience with Source. How does it compares to Unity/Unreal in terms of perfomance, features, tools and ease of use?


That seems like a fairly pointless question, Source 2 hasn't been released yet and Source is 11 years old now, at this point it would pretty much be all speculation, feature wise i would expect it to be on par with the competition though (anything else would be silly)

#5212950 Best tutorials for beginner to expert Unity Java?

Posted by SimonForsman on 25 February 2015 - 01:50 PM


Java Unity

Unless there was a really big announcement that I missed, that isn't a thing. 


JavaScript is supported. And there are lots of books and web sites that cover it.


Java and JavaScript are radically different, related only by name as people tried to cash in on another language's popularity. 



Strictly speaking its not JavaScript either, UnityScript is alot closer to JScript.Net and treating it like Javascript is a pretty bad idea. Alot of valid javascript code is invalid in Unity and you should always prefer to use static typing and generics(if necessary) in Unity rather than relying on dynamic typing like you would with JavaScript (it is significantly slower).


Personally i would recommend using C# instead since it is more commonly used. (more resources available and more people who can help you if you get stuck)

#5210165 Bad practice: GLfloat vs float?

Posted by SimonForsman on 11 February 2015 - 05:54 PM

As I work more and more on my application, adding classes, method, and etc, I noticed something.

Whenever I need a float variable, whether its a class attribute or a pass in param, I am defaulting to making it a GLfloat type.


I started doing this because all the OpenGL methods would take in GL**** type variables. But is this a bad thing to do? Am I limiting myself in anyway?


Should I be type casting variables to there GL**** type equivalent? Even if its not necessarily GLfloat, EG GLuint or GLvoid


That really depends on how you intend to use them, the size of float, double, int, long, etc are implementation defined and can vary between platforms and even between compilers on the same platform, in c++ the only guarantee you have is that double is atleast as big as a float and a long double is atleast as big as a double.


OpenGL however specifies that GLhalf is exactly 16 bits, GLfloat is always exactly 32 bits, and GLdouble is always 64bits, if you are targeting multiple platforms it is a very good idea to ensure that your datatypes are consistent (otherwise your rendering output can differ greatly between platforms) even though most compilers today will use 32 bits for float and 64 bits for double there may be exceptions.