Grofit
October 23rd, 2009, 09:59 AM
Hey,
Im just trying to think if there is a *better* way of solving the scenerio im about to reel off, currently i cant think of one but it feels like it will just eat into CPU time...
First of all the client runs a 2d based game that is for all intents and purposes tileset based, although collisions are not done *per tile* its pretty similar, and its easy enough to just say that each tile which is 32x32 is split into 4 16x16 collision sections.
Now the game world is split up into > 100 areas, each area being a 2d zone of anywhere between 10x10 and 10000x10000 tiles, although its usually in the realm of a 1000 or so.
The server will have > 100 players connected at any one time and although it limits player chatter to surrounding areas in this scenario lets just pretend its done on a zone by zone basis. So if someone moves in Zone 1 only people in Zone 1 will need that update.
Now the main problem i have is that when the player clicks to move to position 800,200 and is currently at 100,100 i need to have the server validate if this movement is allowed before letting them carry it out. As there is no real way to know that a movement is valid unless there can be a path found between the current position and the end position it seems that i would need to do a path finding check for each movement. This makes me feel a bit iffy and this is where im not sure if there is a better way, but i cant see an obvious one...
The server will have the zones loaded in memory, although it only has a collision map style structure, as thats all it cares about, and will basically locate the players current waypoint and the players end point, if it finds a path it sends back a valid response to the client, then the client will run its own pathfinding to find its way to the position, as will all other clients who are listening to updates from the moving player...
Now in the above scenario i cant trust the client to validate the movement, so it seems like it HAS to fall to the server to do this, but as its going to be doing alot of other stuff too it seems like it could just keel over and die... ive got a basic A* algorithm implemented but it is not that efficient and is using Lists at the moment (as i just wanted to knock something quick and dirty together to check how fast/slow it was), and its pretty slow (realm of like 30ms for a simple path find) and im sure it can be speeded up a HUGE amount if i was to make everything structs and use some sort of priority queue... but i thought that i would just check here and see if anyone knows of a better way to do this sort of thing...
Also if this is the best/only way to do it, im not after the shortest path to the given target im just wanting to know if it is possible to reach the given point, so is there any better suited algorithm for doing this, so the clients could still use A* (although a much improved implementation of it), and the server could use some other algorithm to speed up the validation...
Sorry for all the waffling like normal, just want to give you a fuller scenario to work with :D
Im just trying to think if there is a *better* way of solving the scenerio im about to reel off, currently i cant think of one but it feels like it will just eat into CPU time...
First of all the client runs a 2d based game that is for all intents and purposes tileset based, although collisions are not done *per tile* its pretty similar, and its easy enough to just say that each tile which is 32x32 is split into 4 16x16 collision sections.
Now the game world is split up into > 100 areas, each area being a 2d zone of anywhere between 10x10 and 10000x10000 tiles, although its usually in the realm of a 1000 or so.
The server will have > 100 players connected at any one time and although it limits player chatter to surrounding areas in this scenario lets just pretend its done on a zone by zone basis. So if someone moves in Zone 1 only people in Zone 1 will need that update.
Now the main problem i have is that when the player clicks to move to position 800,200 and is currently at 100,100 i need to have the server validate if this movement is allowed before letting them carry it out. As there is no real way to know that a movement is valid unless there can be a path found between the current position and the end position it seems that i would need to do a path finding check for each movement. This makes me feel a bit iffy and this is where im not sure if there is a better way, but i cant see an obvious one...
The server will have the zones loaded in memory, although it only has a collision map style structure, as thats all it cares about, and will basically locate the players current waypoint and the players end point, if it finds a path it sends back a valid response to the client, then the client will run its own pathfinding to find its way to the position, as will all other clients who are listening to updates from the moving player...
Now in the above scenario i cant trust the client to validate the movement, so it seems like it HAS to fall to the server to do this, but as its going to be doing alot of other stuff too it seems like it could just keel over and die... ive got a basic A* algorithm implemented but it is not that efficient and is using Lists at the moment (as i just wanted to knock something quick and dirty together to check how fast/slow it was), and its pretty slow (realm of like 30ms for a simple path find) and im sure it can be speeded up a HUGE amount if i was to make everything structs and use some sort of priority queue... but i thought that i would just check here and see if anyone knows of a better way to do this sort of thing...
Also if this is the best/only way to do it, im not after the shortest path to the given target im just wanting to know if it is possible to reach the given point, so is there any better suited algorithm for doing this, so the clients could still use A* (although a much improved implementation of it), and the server could use some other algorithm to speed up the validation...
Sorry for all the waffling like normal, just want to give you a fuller scenario to work with :D