Go Back   Forum Care Forums > Development Reference Area > Visual Basic

Reply
 
LinkBack Thread Tools Display Modes
auto-generate a fixture list
Old
  (#1)
Laphan
Guest
 
Posts: n/a
Default auto-generate a fixture list - 06-04-2007, 08:57 AM

Hi All

This is a strange request, but I just cannot fathom how to do it.

In theory the requirement is very basic, but in practise its a noodle!!

I have 10 team names like so:

Team A
Team B
Team C
etc ..

I want to create a sort of fixture list that makes sure that each team
'plays' each other just once at home (ie, on the left side) and once away
(ie, on the right side), eg:

Team A v Team B
Team C v Team D
etc..

for what will be 9 weeks (??)

I then want to put this into an Access DB, which is easy enough, but the
former problem is a lot harder.

My initial idea was to enter all the permutations and then use a random
number generator to pick 10 matches for each week's fixture, but this was a
crap idea because I can get the same team's matches listed 4 or 5 times in
the same week.

Any ideas?

Rgds

Laphan





   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Re: auto-generate a fixture list
Old
  (#2)
Mike and Jo
Guest
 
Posts: n/a
Default Re: auto-generate a fixture list - 06-04-2007, 08:57 AM


"Laphan" <EMAIL REMOVED> wrote in message
news:3fdcbfc8_3@127.0.0.1...
> Hi All
>
> This is a strange request, ... [snip]
> I have 10 team names like so:
>
> Team A
> Team B
> Team C
> etc ..
>
> I want to create a sort of fixture list that makes sure that each team
> 'plays' each other just once at home (ie, on the left side) and once away
> (ie, on the right side), eg:
>
> Team A v Team B
> Team C v Team D
> etc..
>
> for what will be 9 weeks (??)
>


That would be 18 Weeks in total:
Team A plays B - J 1 Time at home then Team A plays B- J 1 Time away.


> I then want to put this into an Access DB, which is easy enough, but the
> former problem is a lot harder.
>
> My initial idea was to enter all the permutations and then use a random
> number generator to pick 10 matches for each week's fixture, but this was

a
> crap idea because I can get the same team's matches listed 4 or 5 times in
> the same week.
>
> Any ideas?
>
> Rgds
>
> Laphan


A good way to approach this is to view two columns, Home and Away

First Column A - E, Second Column F - J
Now Each incrementing week rotate the letters one position clockwise, while
leaving A in the same postion each week for the first 9 weeks. This will
give the first 9 Weeks, invert the results for the last 9 Weeks. Ie A Week
1 at home become A Week 10 away.

Mike


   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: auto-generate a fixture list
Old
  (#3)
edoepke
Guest
 
Posts: n/a
Default Re: auto-generate a fixture list - 06-04-2007, 08:57 AM

Try using a Unique Random Number Generator. This will not repeat the same
number.

Generating Random numbers can be very useful at time, however, a randomly
generated number from a seed number can generate or repeat the same number
if a full list or array on numbers is required. This procedure will generate
a Unique Random Number. This means the generated number will not be
repeated. If the seed for the Random Number were 250, then 250 numbers will
be randomly generated without repeating any of the random generated numbers.

Here is one you might use.

Public Sub GenerateNumber()
On Error GoTo ErrorHandler
Dim AC As Integer
Dim I As Integer
Dim R As Integer
Dim Response
'Define the flagged array
Dim ACount(250)
'Define the string variable
Dim ANum(250)
'Define the RANDOM number seed
AC = 25
'Set the flags to FALSE
For I = 1 To AC
ACount(I) = False
Next I

'Iteration
For I = 1 To AC
Jump1:
'Exit the generator
If I > AC Then Exit Sub
'Generate RANDOM number from a base defined by AC
R = Int((AC * Rnd) + 1)
'Test the flag for TRUE
If ACount(R) = True Then
GoTo Jump1
End If
'Test the flag for FALSE
If ACount(R) = False Then
'Set the flag to TRUE
ACount(R) = True
'***ign the RANDOM number to an array
ANum(I) = R
'Do what you want with the generated number here.
'You can call another routine if desired
DisplayNumber

End If
Next I
Exit Sub


ErrorHandler:
Response = MsgBox(Err.Description)
End Sub


"Laphan" <EMAIL REMOVED> wrote in message
news:3fdcbfc8_3@127.0.0.1...
> Hi All
>
> This is a strange request, but I just cannot fathom how to do it.
>
> In theory the requirement is very basic, but in practise its a noodle!!
>
> I have 10 team names like so:
>
> Team A
> Team B
> Team C
> etc ..
>
> I want to create a sort of fixture list that makes sure that each team
> 'plays' each other just once at home (ie, on the left side) and once away
> (ie, on the right side), eg:
>
> Team A v Team B
> Team C v Team D
> etc..
>
> for what will be 9 weeks (??)
>
> I then want to put this into an Access DB, which is easy enough, but the
> former problem is a lot harder.
>
> My initial idea was to enter all the permutations and then use a random
> number generator to pick 10 matches for each week's fixture, but this was

a
> crap idea because I can get the same team's matches listed 4 or 5 times in
> the same week.
>
> Any ideas?
>
> Rgds
>
> Laphan
>
>
>
>
>



   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Contact Us - Forum Care Forums - Archive - Top