Where do I do pathfinding?

Started by
14 comments, last by Triad_prague 12 years, 5 months ago
I'm trying to build a simple test program that is basically a online games where players could walk and chat. the chatting part is not that hard, but the movement is quite stressing. basically, I'm confused at:
-where do I calculate/do the pathfinding? should the server do it and send the calculated waypoint to the client? or should the server only "validates" the path and let the client do the pathfinding?
-a follow up question from question #1:
a. assume I chose the server to do it, wouldn't it be bandwidth intensive to send the calculated path to the client and other players nearby?
b. assume I chose the server to only "validates", will there be a "difference" between the calculated path on the server and the client?
the hardest part is the beginning...
Advertisement
Send the start and end, have the clients compute it.

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal


Send the start and end, have the clients compute it.


so the client sends the start and end point, server validates and simulate it on the server, then tell the client to calculate it?
the hardest part is the beginning...
What are you making? Why does the server need to do anything related to paths?
Isn’t it the client who decides the start and end points of a path? Why do you want the server to tell the clients what the start and end points are?

Client decides start and end points.
Client makes path.
Client walks along path.

That is all.
The server keeps the client out of walls, but that has nothing to do with paths. Keeping the client out of walls is something that is done all the time regardless of the client’s “following path” status.


L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid


What are you making? Why does the server need to do anything related to paths?
Isn’t it the client who decides the start and end points of a path? Why do you want the server to tell the clients what the start and end points are?

Client decides start and end points.
Client makes path.
Client walks along path.

That is all.
The server keeps the client out of walls, but that has nothing to do with paths. Keeping the client out of walls is something that is done all the time regardless of the client’s “following path” status.


L. Spiro


well I said the client decides the start and end path, the server only "validates" (check if it's a valid movement) and the client simulate it. what worried me is how would I synchronize the position in the server. so I thought the server needs to simulate the movement too. that would be client and server simulate movement each in their own, but I'm not too sure if that's how it works in most online games :huh:
the hardest part is the beginning...
This would depend on your game. If it's a board game like chess you want the server validate or else the client could hack it to bypass the client side rule checks. Let's say they make their king move 6 spaces in a zigzag pattern because they were able to bypass the client side rules check. Locally they can do that all they want, but the server would validate that move and realize it's not valid and not update the server board or the opponents client board. So that cheating client is only cheating themselves because now they are out of sync with the server and other client.

Ideally the server would send back to the cheating client a 'no no' msg and move the piece back but chances are if they hacked their client they'll intercept that 'no no' msg and not let it get to the application.

You will want the server to do some kind of validation. It could just be sanity checks like making sure the King in chess only moves 1 tile.

This would depend on your game. If it's a board game like chess you want the server validate or else the client could hack it to bypass the client side rule checks. Let's say they make their king move 6 spaces in a zigzag pattern because they were able to bypass the client side rules check. Locally they can do that all they want, but the server would validate that move and realize it's not valid and not update the server board or the opponents client board. So that cheating client is only cheating themselves because now they are out of sync with the server and other client.

Ideally the server would send back to the cheating client a 'no no' msg and move the piece back but chances are if they hacked their client they'll intercept that 'no no' msg and not let it get to the application.

You will want the server to do some kind of validation. It could just be sanity checks like making sure the King in chess only moves 1 tile.


Do you have to worry about cheating in your chat application? If not, then I wouldn't fret about it too much. Have the pathing be done on the client side. When the client updates the server, the server will check to see if the client is in a valid location. If he is not in a valid location, send back a response that tells them where they should be. The simplest way for the server to do this would be to just send back the player's last known valid position. When the client receives this information it should either: Calculate a new path from the position the server responded with, or simply stop moving altogether. This will get the job done.

It could allow the player to cheat, though. Consider a situation like this:


W: Wall
".": Valid position
@: Player
X: Destination

WWWWWWWWWWW
W....W.....W
W....W.....W
W..@.W..X..W
W....W.....W
W....W.....W
WWWWWWWWWWWW


There is no valid path for the player to the destination X. They're each blocked by walls on both sides. With only validating positions and not paths, the player could send the server a packet with its position inside that unreachable room, and the server would allow it. You can somewhat mitigate this by setting a maximum distance the player can travel between server updates, but that won't work all the time and can cause the client to seem laggy if it can't get updates to the server that often. Another potential solution is to, on the server, draw a line from the player's last known position and the new position and ensure that all positions along the line are valid positions. You could also prevent another kind of cheating using this method by making sure that this line is no longer than the distance the player could actually move in the time between now and when the player was at the last known position.
I'm confused because it sounds like we are saying the same thing. Have the server do validations/sanity checks.

I'm confused because it sounds like we are saying the same thing. Have the server do validations/sanity checks.


We are. That's the only sane way to do it. I guess we're all just giving ways he could do it on the server
What are you making? Why does the server need to do anything related to paths?[/quote]
Uh well the server needs to tell the other people where this player wants to walk. Send the start and end points to all the players. You could still have some lag though that someone doesnt get the walk command right away and then you will still have some lag issues.

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal

This topic is closed to new replies.

Advertisement