Paulus_newbieus
Member
Content count
63 
Joined

Last visited
Community Reputation
131 NeutralAbout Paulus_newbieus

Rank
Member

Dealing with websocket message overload on client
Paulus_newbieus replied to Paulus_newbieus's topic in Networking and Multiplayer
Thanks for the help guys. You were correct  by turning off the Nagle algorithm, my jitter completely vanished! For interest of other readers, in .Net this is possible by toggling the NoDelay property to true (by default its false) on the System.Net.Sockets.Socket class. I believe this change will soon be integrated into the Fleck library by the project developer. Cheers 
Dealing with websocket message overload on client
Paulus_newbieus replied to Paulus_newbieus's topic in Networking and Multiplayer
OK, interesting. I cant see any obvious way to disable Nagle (never heard of it) or how to turn off delayedACK. I don't suppose you guys could point me to a good source of online explanation for these things? I do broadcast a single message to all my client connections once every 25 milliseconds, and I do actually already attach a time stamp to the message  I use this to work out the rate to animate (linear interpolation). So even though I have the time stamp, It's not yet clear to me how I can use this to rearrange my packets. At the moment, positions are just drawn straight away. Should I be buffering the updates, rearrange them depending on time stamps, and then draw them? This feels like yet more lag time. Appreciate the help guys! 
Dealing with websocket message overload on client
Paulus_newbieus replied to Paulus_newbieus's topic in Networking and Multiplayer
Aaah! Of course, why not, this sounds extremely likely. I must admit I was expecting them to arrive in the correct order. Running this simulation locally (debugging on my PC) with server local) I do not get this issue, so I did not consider the ordering to be different. I am using Fleck: https://github.com/statianzo/Fleck I am just using it in its default setup  I have not done any tweaking or tuning whatsoever, just running it out the box. 
Dealing with websocket message overload on client
Paulus_newbieus posted a topic in Networking and Multiplayer
I have a websocket server sending object positions to all clients at a fixed rate (say 40 Hz). Client side (HTML5 browsers) I receive these messages and draw the object (canvas) at that new position. My problem is that sometimes, if there is not a great deal of other JavaScript processing activity on the client, the objects seem to skip a bunch of updates and get transported over a large range. So instead of a nice smooth animation, I get stuttery movements. I have some code to handle lagging updates using linear interpolation  but this problem is different, this is not where the updates are coming in too slow, its where they are coming in too fast! How the heck do I solve this without resorting to decreasing the server update rate, which I really don't want to have to do?! Any suggestions greatly appreciated! 
So I loved all the previous Max Payne games and am really looking forward to the new one. I have started playing games on my console more and more, although I come from a heavy PC gaming background. My problem is that I cant decide whether to buy the game for PC (better graphics?) or my PS3 (couch comfort?)! What do you guys think?

Seeding a pseudorandomly generated game map
Paulus_newbieus replied to Paulus_newbieus's topic in General and Gameplay Programming
[quote name='alvaro' timestamp='1319549306' post='4876731'] You should try to find some material on bit manipulations in C or C++ somewhere else, for a more complete understanding. Let's analyze the expression ((x << 16) + y). (x << 16) means "take the value of x and shift it 16 bits to the left", or equivalently "multiply x by 65,536". This means that (1, 65536) and (2, 0) map to the same number. I don't know if this is acceptable to you, but my guess is that it's fine. The magic constant I used is simply a random odd 64bit number. You should use a random odd 32bit number if you are using 32bit arithmetic. The advantage of using a large random number instead of 65,536 here is that you can generalize the procedure to hash more information into the seed like this: [code] unsigned long seed = x; seed = seed * 10366439865051156459ul + y; seed = seed * 10366439865051156459ul + z; seed = seed * 10366439865051156459ul + w; // ... [/code] If you were to do that by shifting alone, the information about x would eventually get lost in overflow. There are situations where you need to hash information down to a single number and you need the result to look much more random (e.g., cryptographically signing a document), but I don't think you have to go crazy for your particular application. [/quote] Thanks, much appreciated guys. 
Seeding a pseudorandomly generated game map
Paulus_newbieus replied to Paulus_newbieus's topic in General and Gameplay Programming
[quote name='alvaro' timestamp='1319518235' post='4876607'] [quote name='Paulus_newbieus' timestamp='1319488546' post='4876462'] Thanks for suggestions guys. [quote name='Waterlimon' timestamp='1319476188' post='4876360'] Int=(int)short << 16 & short2 ??? [/quote] So short is the x coord and short2 is the y. You are bit shifting the x by 16 and adding it to the y, to make it a unique single value? This is so the point {1;2} will not result in the same seed as {2;1}, am I right? And alvaro, you are doing something similar. [/quote] I am doing something similar, but my code works. What Waterlimon posted has several issues. He probably meant to say `(short1 << 16) + short2' or `(short1 << 16)  short2'. With '&' you'll get 0. And you can't use `short' as a variable name. [/quote] Thanks for clarification and taking the time to help me out alvaro! I actually come from a VB .Net programming background (*hangs head in shame*) so could you please clarify with the symbols what's going on with the bit shift and addition i.e. should it be adding the results? Also, alvaro what's the [color="#006666"][font="CourierNew, monospace"][size="2"]10366439865051156459ul [/size][/font][/color]signify, and how would that be better than a bit shift? Many thanks! 
Seeding a pseudorandomly generated game map
Paulus_newbieus replied to Paulus_newbieus's topic in General and Gameplay Programming
Thanks for suggestions guys. [quote name='Waterlimon' timestamp='1319476188' post='4876360'] Int=(int)short << 16 & short2 ??? [/quote] So short is the x coord and short2 is the y. You are bit shifting the x by 16 and adding it to the y, to make it a unique single value? This is so the point {1;2} will not result in the same seed as {2;1}, am I right? And alvaro, you are doing something similar. 
Seeding a pseudorandomly generated game map
Paulus_newbieus posted a topic in General and Gameplay Programming
Hi, I am looking to build a pseudorandomly generated game level/map. A map is divided into blocks of areas, and using a seed I want to be able to regenerate the same content of any of these areas anywhere in my game map. So if I teleport to a faroff area, it will look the same as the next time I visit the same area after restarting the game. I know lots of games already use this mechanic, but my issue is with the fact that to seed a pseudorandom number generator you typically supply a single value such as an unsigned integer. What I have instead is an x,y grid coordinate, not a single value, because that is the only way I can think of how I would identify a map area, especially if the map is potentially infinite in size. For example, the first area may be 1,1. To the right is 2,1, and below is 1,2 etc. So I guess what I am asking is how can I use a coordinate as a seed? 
Using Square Root to calculate Area
Paulus_newbieus replied to Paulus_newbieus's topic in Math and Physics
Thanks for the feedback all, much appreciated! Quote: Someone already asked this, but I'll do it again: Why do you think you need the square root? Can you show us an example? I thought that I needed the square root because I was testing with nonAxisAligned rectangles. I have just tried with your simple example figures and I get the same result. Basically I became very confused because I am working in a "zoomed in" scale, and applying the square root seemed to give correct figures but I was in fact just plain wrong. Because I can not guarantee my rectangle will always be AA, I think this is really what I should be using: http://www.wikihow.com/CalculatetheAreaofaPolygon 
Using Square Root to calculate Area
Paulus_newbieus replied to Paulus_newbieus's topic in Math and Physics
Quote:Original post by Magpie OK the Area of a 4 sided figure, Square or Rectangle is Width * height. If you are using coordinates you need to calculate the distance of the width and the height. IE: Width will be W = Sqrt((X2X1)^2 + (Y2Y1)^2) Height will be H = Sqrt((X3X1)^2 + (Y3Y1)^2) So area is W * H Ahaha  Yes I am using a 2D coord system. This must be why I need the square root in there, because it needs to be the distance otherwise it doesn't make sense when I convert it to real world measurements. I can expand my actual function  this is what it is doing: Area = Math.Sqrt((m_MaxPoint.X  m_MinPoint.X) * (m_MaxPoint.Y  m_MinPoint.Y)) Does that sit with what you have said Magpie? 
Using Square Root to calculate Area
Paulus_newbieus replied to Paulus_newbieus's topic in Math and Physics
Hmm ... does it have something to do with my coordinates? Perhaps related, why would I also need to square root the result of a distance calculation? Public Function Distance(ByVal Point1 As PointF, ByVal Point2 As PointF) As Single Dim dx As Single = Point1.X  Point2.X Dim dy As Single = Point1.Y  Point2.Y Return Math.Sqrt(dx * dx + dy * dy) End Function 
To calculate the area of a 2D square or rectangle, you multiply the width by height. However, unless I then get the square root of this value the result is wrong! Public Overrides Function GetArea() As Single Return Math.Sqrt(ShapeWidth * ShapeHeight) End Function Why do I need to apply the square root?

pseudorandom game content  Where to start
Paulus_newbieus replied to Paulus_newbieus's topic in Graphics and GPU Programming
Yes but is it possible to know the sector seeds of a sector 287634 million miles away, just by say passing in a 3D point position parameter, instead of actually generating the entire galaxy up front? 
pseudorandom game content  Where to start
Paulus_newbieus posted a topic in Graphics and GPU Programming
I've been thinking about how you generate content for things like a game, but from a pseudorandom seed. The pseudorandom is important, because I want to be able to recreate the exact same thing if I know my seed value. Generally I know that if you seed a languages randomizer with a certain number, you will get the same sequence of values from the formula. This is of course really useful to store the definition of a game map and its contents just by knowing the seed. So with the seed alone I will be able to generate exactly the same game map on many different machines, without each machine actually having to know the definition of the map upfront. It just takes the seed, then loops through some method calls and constructs the map. I think games use a similar method already, in fact do I think Elite used something similar to generate all its planets? Anyway, the key here when using the random class and the seed is that we have to loop through some procedure. As we go through the loop, we are slowly building up the same content. Now, my question is, is it possible to look ahead into the future to determine what the random number output will be? Think about flying through space in Elite. Lets pretend the game has not yet ran through its routines to generate the entire galaxy, but you go into warp and appear somewhere far away. I come out of warp and appear next to a planet full of amazonians. Now, say I exited the game, reloaded the same map and went into warp at the same place. Would I still appear at the Amazonian planet? Is this possible to tell without knowing the content of the entire galaxy upfront, or is there some procedure that could hop us ahead to that point in space without having to iterate through a loop a bazillion times? I’ve started looking at Fractals and even Perlin noise – am I on the right path? Could you guys direct me to some good reading material please?