# Weights by proximity

This topic is 2957 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hey,

This might sound a bit odd, but I'm working on a simulation of sorts and having a slight mental block.

This would probably be best described if I used a real life sort of example (note, this is not a school assignment or similar).

Imagine you have 100 of some currency (I'll use dollars).
You walk into a room that has a random number of people in it, all in random locations.
Your objective is to pass out all your money, making sure everyone gets some of it.
The catch is, you are to give more money to people that are closer to you (not just more, but proportional).

So as an example, if there are 2 people in the room, and you know 1 is 5 feet from you and the other is 10 feet from you, the one 5 feet from you should get double the amount you give to the other person. In this case, you'd give the nearest guy 66.66 dollars and the other guy 33.33.

What would be the appropriate method to distribute the money when you do not know the number of people, but you do know how far each one is from you?

I hope that makes some sort of sense. Thanks for any and all help.

Edit:
Nevermind. I think I've got it. My only issue now is that the farther the 'people' are away, the less the distance impacts how much they would receive (that's trivial though).

##### Share on other sites
If you want to distribute the money inverse proportional to the distance, then assign the weight w[sub]n[/sub] = 1/distance to person number n. Then, normalize the weights so they add up to unity: w'[sub]n[/sub] = w[sub]n[/sub]/sum(w[sub]n[/sub]). Now you just distribute the money as 100 dollars * w'[sub]n[/sub] to person n.

The method works for any weighing, just change the 1/distance to whatever weighting function you want.

##### Share on other sites
Ding. What he said. The kicker, of course, is that you have to know how many people there are and their respective distances before you can run the calculation.

Now if you REALLY want to have fun, distribute people around the room so that the path that you choose to take from one to the next affects the distance. You aren't measuring the distance from your starting place to each person, you are measuring the distances from each person to the next. Doable, but it just takes some iteration.

Now if you REALLY want to stab yourself in the eyes, use the Traveling Salesman problem to determine which is the most efficient path through the n people in the room.

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 15
• 21
• 21
• 11
• 9