Results 1 to 3 of 3

Thread: Finding closely located points on a grid

  1. #1
    Jun 2009

    Finding closely located points on a grid

    I posted this in the Other topics category in the University Math section before posting here. I know that I'm just impatient, but I thought that posting it here too might have a higher chance of finding somebody with an answer.

    That said, this is my problem:

    I am currently a programming a server for a massive online game, and I want to make it as efficient as possible. The current problem I have to solve involves how the server checks for people close to a given player so that it can send the data about the other players to that player.

    The entire game runs on a huge grid, and each player has an absolute X and Y coordinate on this grid.

    Here's a simplified, real-world example:
    Jack is at point 1,2
    Jane is at point 9,5
    Bob is at point 3,2

    Everyone within 4 units of range of each other (calculated using the distance formula) can talk to each other.
    Figure out who is within talking range of who.

    Obviously, for this small data set, this is a pretty simple matter. However, the game server is going to be doing this with THOUSANDS of players. I want to know if the current way of doing this could be improved.

    Currently the logic that the computer does to determine who is within "talking distance" right now works like this:
    The server has a list of all of the players online, and the X and Y values of each on the grid. So, for each player in that list (remember, there's thousands), it compares its X and Y value to the X and Y value of each and every other player online, and determines whether they are in range. Then, it moves on and does this for the next player, and on, and on, until each single player has been individually compared to every other player online.

    If that made any sense to you, you can tell why the current way of doing things is woefully inefficient. In the ideal solution to this problem, the computer could find the players within range of every player without looping through the player lists at all.

    I tried to make things as simple as possible for people who don't know many computer terms. Is there any less computationally-intensive way of finding who is near who? Much appreciation in advance.

    Note: I'm only in 9th grade and have only taken geometry, so if needed I can look into some more advanced math if required to solve this problem. Some explanation of terms would be helpful though
    Follow Math Help Forum on Facebook and Google+

  2. #2
    MHF Contributor Amer's Avatar
    May 2009
    I do not know much in computer programs but you can make a circle of radius 4 unit around each player and any two circles intersect the talk can happened
    I think this will be more effective

    dose this make sense for you
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Jun 2009
    Detecting that intersection still requires a loop, though... Hmm... Your approach would work quite well if I had a powerful GPU doing the processing, but I can't imagine how you could make that work well on a CPU...
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Replies: 0
    Last Post: Mar 2nd 2012, 11:51 AM
  2. Replies: 1
    Last Post: Jul 20th 2011, 01:52 PM
  3. Finding words in a letter grid.
    Posted in the Math Puzzles Forum
    Replies: 1
    Last Post: Mar 30th 2011, 12:19 PM
  4. Replies: 0
    Last Post: Sep 7th 2010, 10:35 PM
  5. Replies: 3
    Last Post: Apr 11th 2009, 09:01 AM

Search Tags

/mathhelpforum @mathhelpforum