Created
September 14, 2024 01:04
-
-
Save hacklex/fbd904e5913279679e4759c1fcbcc05d to your computer and use it in GitHub Desktop.
test.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int size = 24; | |
(int aWins, int bWins, int draws, int indecisives) SequentialNonRandomTest() | |
{ | |
int topBound = 1 << size; | |
int aWins = 0; | |
int bWins = 0; | |
int draws = 0; | |
int indecisives = 0; | |
for (int i = 0; i < topBound; i++) | |
{ | |
int currentNumber = i; | |
bool IsASet(int k) => (currentNumber & (1 << k)) != 0; | |
bool IsBSet(int k) => (currentNumber & ((k < size / 2) ? k * 2 : (k - size / 2) * 2 + 1)) != 0; | |
bool twoConsecutiveTrue = false; | |
for (int k = 0; k < size-1; k++) | |
{ | |
if (IsASet(k) && IsASet(k + 1)) | |
{ | |
twoConsecutiveTrue = true; | |
if (!IsBSet(k) || !IsBSet(k + 1)) | |
{ | |
aWins++; | |
break; | |
} | |
else | |
{ | |
draws++; | |
break; | |
} | |
} | |
if (IsBSet(k) && IsBSet(k + 1)) | |
{ | |
twoConsecutiveTrue = true; | |
if (!IsASet(k) || !IsASet(k + 1)) | |
{ | |
bWins++; | |
break; | |
} | |
else | |
{ | |
draws++; | |
break; | |
} | |
} | |
} | |
if (!twoConsecutiveTrue) indecisives++; | |
} | |
return (aWins, bWins, draws, indecisives); | |
} | |
Console.WriteLine($"Size: {size}"); | |
var (aWins, bWins, draws, indecisives) = SequentialNonRandomTest(); | |
for (size = 24; size > 2; size--) | |
{ | |
var result = SequentialNonRandomTest(); | |
Console.Write($"{result.bWins}, "); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment