Back



TurboMax RetroGaming
Literature
The Connect4AI project
The plan is to build a platform to test machine learning techniques to build a Connect4-bot that outperforms humans and rule-based systems. Task one is to set up a competition for Connect4-bots. To start with those are random and rule based, later learning bots will be added.
First problem: how to set up a competition? Spent at least twenty hours to come up with the following extremely inefficient algorithm.
I ran it for an 8-way competition and for a 10-way competition. I wanted 12-way, but that computes a few weeks on my system.
As said... it's not very efficient.






public static void Main(string[] args)
{
int compSize = 10;
StreamWriter sw = new StreamWriter("10way_comp.txt");
List>> Competition = new List>>();
List Number = new List();
for (int n = 0; n {
Number.Add(n);
}
for (int R1 = 1; R1 < compSize+1; R1++)
{
Number[1] = R1;
Console.WriteLine("R1: " + R1);
for (int R2 = 1; R2 < compSize+1; R2++)
{
Number[2] = R2;
for (int R3 = 1; R3 < compSize+1; R3++)
{
Number[3] = R3;
for (int R4 = 1; R4 < compSize+1; R4++)
{
Number[4] = R4;
for (int R5 = 1; R5 < compSize+1; R5++)
{
Number[5] = R5;
for (int R6 = 1; R6 < compSize+1; R6++)
{
Number[6] = R6;
for (int R7 = 1; R7 < compSize + 1; R7++)
{
Number[7] = R7;
for (int R8 = 1; R8 < compSize + 1; R8++)
{
Number[8] = R8;
for (int R9 = 1; R9 < compSize + 1; R9++)
{
Number[9] = R9;
for (int R10 = 1; R10 < compSize + 1; R10++)
{
Number[10] = R10;
//check all different
List distinct = Number.Distinct().ToList();
if (distinct.Count == compSize + 1)
{
List> Round = new List>();
for (int n = 0; n < compSize / 2; n++)
{
List newGame = new List();
newGame.Add(0);
newGame.Add(0);
newGame.Add(0);
newGame[1] = Number[2 * n + 1];
newGame[2] = Number[2 * n + 2];
Round.Add(newGame);
}
bool newRound = true;
//check Newround
foreach (List> theRound in Competition)
{
foreach (List theGame in theRound)
{
//if newgame in theround then newRound is false
foreach (List theNewGame in Round)
{
if ((theNewGame.Contains(theGame[1]) && (theNewGame.Contains(theGame[2]))))
{
newRound = false;
}
}
}
}

if (newRound)
{
//print & add
Console.WriteLine("ADDED ");
Competition.Add(Round);
for (int n = 1; n < compSize + 1; n++)
{
Console.Write(Number[n]);
sw.Write(Number[n]);
}
Console.WriteLine();
sw.WriteLine();
}
// else
// {
// Round.Clear();
// }
// distinct.Clear();
// newRound = true;
}
}
}
}
}
}
}
}
}
}
}
sw.Close();