Jump to content

Tournament Generate

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
6 replies to this topic

#1
Whitey

Whitey

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 255 posts
Okay i am trying to make this generate for 4 8 and 16 size tournaments.
Here is my example
http://clansi.net/test2.php

but as you can see that would take alot of space and the runtime slow.
I also want to learn to generate it for learning purpose's

Also i can see a math equation in it
Round 1 starts at box 1 (having 0 being the round name) then goes adding 2 after that for each name
Round 2 has 2 Space at the start (The spaces consecutive in round 1) and adds 4 consecutive.. (it doubles) the math equation is used throught the whole pattern

Given Start 1
Take the number before double it (2)
then use 2 and take that number and double it (4)
hard to explain but this is just babling haha just if you can help me generate that tournment by actually inputting any number that would be great

#2
John

John

    Writes binary right handed and hex left handed

  • Moderators
  • 6,321 posts
The first thing I would do is work out a relationship between the number of teams playing and the number of rounds played.

#3
Whitey

Whitey

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 255 posts
Well if i do it by 4 - 8 - 16 it would be 3 - 4 - 5

#4
John

John

    Writes binary right handed and hex left handed

  • Moderators
  • 6,321 posts
How about if you did it by "n" - any arbitrary number? Then what would it be (in terms of n).

#5
Whitey

Whitey

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 255 posts
Thats really hard to make i am confusing myself when trying to make it

#6
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
Try looking at it like this:

Teams : Rounds

1     : 0

2     : 1

3-4   : 2

5-8   : 3

9-16  : 4

17-32 : 5

In particular, notice that the high values are powers of two

Edited by WingedPanther, 27 August 2008 - 12:44 PM.
formatting

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#7
Orjan

Orjan

    Writes binary right handed and hex left handed

  • Moderators
  • 3,299 posts
number of rounds is the same as the highest bit has in the byte-value that has a 1

ex:
11 = 00001011; 4th bit is set with means we will have 4 rounds
23 = 00010111; 5th bit is set -> 5 rounds

then it's "just" to write a nice procedure to calculate this...

	function highbit($a) {
		$highbit = 0;
		$bitcomp = 1;
		for ($i=1; $i<16; $i++) {
			if ($a & $bitcomp) {
				$highbit = $i;
			}
			$bitcomp = $bitcomp << 1;
		}
		return $highbit;
	}

this function works for up to 16384 players, if more needed, just change the value in the for-loop, from 16 to a higher value. Just put number of players as parameter to the function. highbit(57) would give 6 (max 64) and highbit(23) would give 5 (max 32)

Edited by Orjan, 28 August 2008 - 03:42 AM.
Added an function