.com.unity Forums

.com.unity Forums (http://forum.shrapnelgames.com/index.php)
-   Space Empires: IV & V (http://forum.shrapnelgames.com/forumdisplay.php?f=20)
-   -   Math problem (http://forum.shrapnelgames.com/showthread.php?t=10073)

tesco samoa August 7th, 2003 02:18 AM

Re: Math problem
 
geo you should grab one of those wheel systems for lotteries.

you need a 3 of n wheeler with a filter

cybersol August 7th, 2003 02:19 AM

Re: Math problem
 
Quote:

Originally posted by Jack Simth:
Let's see: Floor function for the numbers:

Pp = players per game
Np = Number of players (total)
Gp = Games per player
Tg = Total games

Gp = (Np - 1) / (Pp - 1)
Tg = (Np * Gp) / Pp
...
If Gp and Tg come out as positive integers, it should be doable - I'm not sure about the arrangement, however.

<font size="2" face="Verdana, Helvetica, sans-serif">I think this is the same as what I had a few Posts back, or am I missing something?

Edit: Oh sure add more http://forum.shrapnelgames.com/images/icons/icon7.gif

Quote:

Originally posted by Jack Simth:
Edit: Arrangement method:
Edit: Arrangement method:

1) List players
2) Variables
Pp = players per game
Np = Number of players (total)
Gp = Games per player
Tg = Total games
Sk = Skip (counting variable; internal use only)
3) Gp = (Np - 1) / (Pp - 1)
4) Tg = (Np * (Np - 1)) / (Pp * (Pp - 1))
5) Sk = 0
6) Group, skipping Sk
7) Sk = Sk + Pp
8) If Sk < Np, Goto 6

<font size="2" face="Verdana, Helvetica, sans-serif">Looks promising, but I don't understand exactly what you mean by group, skipping sk. Could you show the Np=13 and Pp=3 case I mentioned earlier as an example (since no one has shown it yet)?

[ August 07, 2003, 01:56: Message edited by: cybersol ]

Captain Kwok August 7th, 2003 02:23 AM

Re: Math problem
 
Quote:

Originally posted by tesco samoa:
geo you should grab one of those wheel systems for lotteries.

you need a 3 of n wheeler with a filter

<font size="2" face="Verdana, Helvetica, sans-serif">This is exactly what he needs! Some sort of calculator that will list all the possible combinations of numbers (i.e. players) for n number of players, and r number of players per game!

Jack Simth August 7th, 2003 02:45 AM

Re: Math problem
 
A few people posted while I was editing, so I'll put it back up:
Quote:

Arrangement method:

1) List players
2) Variables
Pp = players per game
Np = Number of players (total)
Gp = Games per player
Tg = Total games
Sk = Skip (counting variable; internal use only)
3) Gp = (Np - 1) / (Pp - 1)
4) Tg = (Np * (Np - 1)) / (Pp * (Pp - 1))
5) Sk = 0
6) Group, skipping Sk
7) Sk = Sk + Pp
8) If Sk < Np, Goto 6
<font size="2" face="Verdana, Helvetica, sans-serif">I might have an off by one error in line 7.

[ August 07, 2003, 09:16: Message edited by: Jack Simth ]

Ack August 7th, 2003 02:46 AM

Re: Math problem
 
Geoschmo is correct that you cannot use a combination equation for a round robin. This is from some website:

Example:

How many ways can we select three letters from the letters of RSTUV?

n = 5 r = 3

These are: RST, RSU, RSV, RTU, RTV, RUV, STU, STV, SUV and TUV.

From this you can see that, if RSTUV represented players, players would meet more than once (RS for example).

Permutation equations do not work for exactly the same reason.

Geoschmo,

I believe the only way you can avoid having players meet more than once is if the number of players is the square of the number of players per game. Actually another case is if the number of players is equal to the number of players per game (or 1 game). Anything other than this and you'll either having players facing each other multiple times or rounds where players do not play.

Next, the most possible games occurs if the number of players per game is equal to one. In this case the number of games is the summation of A (from A=1 to A= n-1). Where n is the total number of players. This is an important event.

So adjusting for the number of players, which should be a simple division, gives this:

Pg = players per game
n = total number of players

# games = (1/Pg) Summation (A=1 to A=n-1)

Solving a few cases:

Pg = 1, n = 1: # games = 1
Pg = 4, n = 2: # games = 3 (wrong, should be 6)
Pg = 9, n = 3: # games = 12

In summations, having variation between the odd and even entries is fairly common. So you need another equation for the even values, which I'm not going to work out tonight.

I suspect there is a more graceful solution by using some series expansions. Try looking at Taylor, Binomial, Geometric, etc. Series Expansions to find a better solution. To help you along, try determining the number of games required for 25-5 and 36-6.

One more quick thing. The number of games per round is simply n/Pg. So another option would be to use this and find a series that describes the number of rounds.

tesco samoa August 7th, 2003 02:48 AM

Re: Math problem
 
i posted this earlier

i have a question along this line

say you have 24 numbers and you want to sort them in combinations of 4 where each number only appears once with each other how many combinations would that be ???

now if some one wanted to whip up a little program that does that ( but i can select the numbers (say up to 50), combinations ( 2 to 12 ) and uniqueness ( say once to 6 times ) and can produce a text file output i would be forever thankful

And in VB and send me the source http://forum.shrapnelgames.com/images/icons/icon7.gif

tesco samoa August 7th, 2003 02:49 AM

Re: Math problem
 
i posted this earlier

i have a question along this line

say you have 24 numbers and you want to sort them in combinations of 4 where each number only appears once with each other how many combinations would that be ???

now if some one wanted to whip up a little program that does that ( but i can select the numbers (say up to 50), combinations ( 2 to 12 ) and uniqueness ( say once to 6 times ) and can produce a text file output i would be forever thankful

And in VB and send me the source http://forum.shrapnelgames.com/images/icons/icon7.gif

Ack August 7th, 2003 02:56 AM

Re: Math problem
 
The only hard part about that would be using VB. I switched to Perl and haven't used anything else in about 2 years.

Oh yeah. I believe the even equation is simply:

Pg = players per game
n = total number of players

# games = [(1/Pg) Summation (A=1 to A=n)] + 1

Ack August 7th, 2003 03:01 AM

Re: Math problem
 
Duh! Algorithm.

1. Drop each combination into an array of n elements. Where n is the number of players per game.
2. Sort each array numerically.
3. Compare each array to the next and discard in duplications.
4. Output the remaining arrays into a text file.

Ugly and inefficient, but a P4 should make short work of it.

LGM August 7th, 2003 04:38 PM

Re: Math problem
 
I guess I missed Erax's solution for 9 players. To appears that how you pick your combinations matters. My alogorythm finds combinations in a certain manner so it only works for certain numbers. A different method might find other solutions.

An exhaustive method would build all combinations and start eliminating redundant combaintions and each iteration it would pick a different combination of redundants to eliminate. This makes the problem even messier.

I tried doing 9 on paper myself and I couldn't do it. Probably because I did it much the same way I programmed it.

Good news for Geosmo is we have known solutions now for 7,9,15, and 31. Maybe someone else can figure out solutions for 11, 13, 17, 19, ...

I know the even numbers will not work because player 1 must play every other player in three player games. Therefore the number of players opposing player one must be a multiple of 2. Adding in player 1 makes the total number of players an Odd number.

[ August 07, 2003, 15:41: Message edited by: LGM ]

LGM August 7th, 2003 04:57 PM

Re: Math problem
 
I had an SEIV turn to do Last night (my gracious host is running turns manually while PBW is down). Maybe tonight I can tackle writting a program to find combinations for Geo.

It is an interesting problem. This time I will probably write it in Delphi and make it a Windows executible. I'll need to arrange my data a bit better to back track when I get stuck down a blind alley looking for a solution.

I'll publish the code. Delphi code should be fairly easy for C++ or Java programmers to understand as the language is somewhat similiar.

Erax August 7th, 2003 05:31 PM

Re: Math problem
 
Quote:

I tried doing 9 on paper myself and I couldn't do it. Probably because I did it much the same way I programmed it.
<font size="2" face="Verdana, Helvetica, sans-serif">I did it graphically. I set the players up like this :

1 2 3
4 5 6
7 8 9

Then connected them first horizontally, then vertically, then along the diagonals (you have to imagine that the numbers 'wrap around' for the diagonals). To my surprise, this solved it for nine players.

tesco samoa August 7th, 2003 05:43 PM

Re: Math problem
 
http://www.singlix.com/download/combinator.html

has the source code for the routine that determines pairing of numbers

It is in turkish but stepping though it will be ok

Hakuen Kage August 7th, 2003 08:05 PM

Re: Math problem
 
(Loser showed me this thread this morning, I hope I'm not imposing.)

If you were doing it standard elimination style, then it would just be powers of 3. Since each contest would require three participants, you would need three games to fuel each contest. So it would work with 3, 9, 27, 81, 243, 729...

If you want each person to actually play each other person only once, then it's a bit tougher.

In order to determine the number of games it will take for everyone to play everyone, do the following (exactly as Cybersol suggested):

n = Number of players
x = number of games each player must play
z = number of players per game

x = (n-1)/(z-1)

In each game, each player removes two (or the number of people in each game minus one) people from the pool of people that they must play. They obviously don't have to play themselves, so you have to remove from from the total.

From this, we can see that the set with a solution is an odd integer (since x has to be an integer). It is of the form 2x + 1, which in fact means, it is a positive odd integer. Positive because the number of games played must be positive.

Let's try 5. Find x and write down the first player x number of times like so:

1
1

Now go to player two. Since you can't have them playing each other more than once, you need to record it as follows:

1,2
1
2

Proceed to 3

1,2,3
1,
2
3

4:

1,2,3
1,4
2,4
3

5:

1,2,3
1,4,5
2,5
3,4

Here we come to an additional limitation on the number of players required. In this case, we have 10 elements which are not going to fit evenly into games where only three people play at a time. The number of elements must also be divisible by 3 (z).

e = number of elements

e = x * n
or
e = x * [x*(z-1)+1)]

Since e has to be divisible by z

e mod(z) = 0

We can simplify for our particular case

e = 2x^2 + x

So, for all values of x where:

(2x^2 + x) mod(3) = 0

Should be the solutions to your problem. Some of you programmers should be able to write a program to solve that in a heartbeat.

I believe the solutions you will come up with (based on intuition) are that the numbers will be of of the form 3r + 1 and 3r. So all numbers divisible by 3 should work (duh) and all those numbers plus one should work.

Okay, I just verified the 3r + 1 solution set and it works. If someone wants that proof, I'll more than happily post it.

This solves the problem for the number of games that each player must play. So the number of players it works for can be easily backtracked.

2x + 1 = n

So the solution sets for the number of players will be 6r + 1 and 6r + 3. This can actually be seen quite easily by looking at Cybersol's Last post.

With that in mind, someone should be able to easily write a program that uses the method in my example above to arrange the matches. Randomizing it would be tricky, but is still quite doable. Sadly, I can only code in Pascal and I don't have a compiler handy.

Edit: I got my friend's handle wrong. Oops.

[ August 07, 2003, 20:58: Message edited by: Hakuen Kage ]

Loser August 7th, 2003 09:57 PM

Re: Math problem
 
Somebody asked for a mathematician?
Is he great or what?
Somebody give the teacher an apple.

SamuraiProgrammer August 9th, 2003 03:11 AM

Re: Math problem
 
Quote:

Originally posted by Slynky:
One of the good things about chess and its rating system (see my remark about one possible way to have a rating system in SE4 in the "New League" thread) is the wonderful way tournements can be run. Using the rating of the player, you just use Swiss-System pairing and get a tourney done in 4-5 rounds...considering anywhere from 15-30 people.
<font size="2" face="Verdana, Helvetica, sans-serif">I play in bridge tournaments where there are 'Swiss' events. It works pretty well in that as you win, you play against people that are winners (and more apt to be at your level). As you lose, you play against others who did not win (and more apt to be at your level).

It ends up being an event that, after the first few rounds, you end up playing against your own level of competition. This makes the matches more enjoyable. Everyone wants to feel competitive.


All times are GMT -4. The time now is 06:58 AM.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©1999 - 2025, Shrapnel Games, Inc. - All Rights Reserved.