Skip to content

Commit 8566f4c

Browse files
Fix formatting and finalize CodeBreaker.Bot.Benchmarks project
Co-authored-by: christiannagel <[email protected]>
1 parent fb6b858 commit 8566f4c

File tree

3 files changed

+28
-28
lines changed

3 files changed

+28
-28
lines changed

src/services/bot/CodeBreaker.Bot.Benchmarks/AlgorithmBenchmarks.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ public class AlgorithmBenchmarks
1818
private List<int> _reducedGame6x4Values = null!;
1919
private List<int> _reducedGame8x5Values = null!;
2020
private List<int> _smallGame6x4Values = null!;
21-
21+
2222
private int _testSelection6x4;
2323
private int _testSelection8x5;
2424
private int _testSelection5x5x4;
25-
25+
2626
private Dictionary<int, string> _colorNames6x4 = null!;
2727
private Dictionary<int, string> _colorNames8x5 = null!;
2828
private Dictionary<int, string> _colorNames5x5x4 = null!;
@@ -33,17 +33,17 @@ public void Setup()
3333
// Initialize full possible values for different game types
3434
_fullGame6x4Values = BenchmarkTestData.CreateGame6x4PossibleValues();
3535
_fullGame8x5Values = BenchmarkTestData.CreateGame8x5PossibleValues();
36-
36+
3737
// Create reduced lists simulating games in progress
3838
_reducedGame6x4Values = BenchmarkTestData.CreateReducedPossibleValues(_fullGame6x4Values, 100);
3939
_reducedGame8x5Values = BenchmarkTestData.CreateReducedPossibleValues(_fullGame8x5Values, 200);
4040
_smallGame6x4Values = BenchmarkTestData.CreateReducedPossibleValues(_fullGame6x4Values, 20);
41-
41+
4242
// Create test selections
4343
_testSelection6x4 = BenchmarkTestData.CreateTestSelection(GameType.Game6x4);
4444
_testSelection8x5 = BenchmarkTestData.CreateTestSelection(GameType.Game8x5);
4545
_testSelection5x5x4 = BenchmarkTestData.CreateTestSelection(GameType.Game5x5x4);
46-
46+
4747
// Create color name mappings
4848
_colorNames6x4 = BenchmarkTestData.CreateColorNames(GameType.Game6x4);
4949
_colorNames8x5 = BenchmarkTestData.CreateColorNames(GameType.Game8x5);

src/services/bot/CodeBreaker.Bot.Benchmarks/BenchmarkTestData.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,12 @@ public static List<int> CreateReducedPossibleValues(List<int> fullList, int targ
102102
// Create a reduced list by taking every nth element
103103
var step = fullList.Count / targetSize;
104104
var reducedList = new List<int>(targetSize);
105-
105+
106106
for (int i = 0; i < fullList.Count && reducedList.Count < targetSize; i += step)
107107
{
108108
reducedList.Add(fullList[i]);
109109
}
110-
110+
111111
return reducedList;
112112
}
113113

@@ -132,13 +132,13 @@ public static Dictionary<int, string> CreateColorNames(GameType gameType)
132132
{
133133
var colorNames = new Dictionary<int, string>();
134134
int key = 1;
135-
135+
136136
if (gameType == GameType.Game5x5x4)
137137
{
138138
// Create shape+color combinations
139139
var colors = new[] { "Red", "Green", "Blue", "Yellow", "Orange" };
140140
var shapes = new[] { "Circle", "Square", "Triangle", "Diamond", "Star" };
141-
141+
142142
foreach (var shape in shapes)
143143
{
144144
foreach (var color in colors)
@@ -151,17 +151,17 @@ public static Dictionary<int, string> CreateColorNames(GameType gameType)
151151
else
152152
{
153153
// Color-only games
154-
var colors = gameType == GameType.Game8x5
154+
var colors = gameType == GameType.Game8x5
155155
? new[] { "Red", "Green", "Blue", "Yellow", "Orange", "Purple", "Pink", "White" }
156156
: new[] { "Red", "Green", "Blue", "Yellow", "Orange", "Purple" };
157-
157+
158158
foreach (var color in colors)
159159
{
160160
colorNames[key] = color;
161161
key <<= 1;
162162
}
163163
}
164-
164+
165165
return colorNames;
166166
}
167167
}

src/services/bot/CodeBreaker.Bot.Benchmarks/GameScenarioBenchmarks.cs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class GameScenarioBenchmarks
1515
{
1616
private List<int> _initialValues6x4 = null!;
1717
private List<int> _initialValues8x5 = null!;
18-
18+
1919
[GlobalSetup]
2020
public void Setup()
2121
{
@@ -41,14 +41,14 @@ public List<int> SimulateMidGame6x4_Move3()
4141
// Simulate mid-game with some black matches
4242
var values = _initialValues6x4.ToList();
4343
var selection1 = BenchmarkTestData.CreateTestSelection(GameType.Game6x4);
44-
44+
4545
// First move: no matches
4646
values = values.HandleNoMatches(GameType.Game6x4, selection1);
47-
47+
4848
// Second move: 1 black match
4949
var selection2 = 0b_001000_000100_000100_000100; // Different first position
5050
values = values.HandleBlackMatches(GameType.Game6x4, 1, selection2);
51-
51+
5252
// Third move: 2 white matches
5353
var selection3 = 0b_000100_001000_000100_000100; // Rearranged colors
5454
return values.HandleWhiteMatches(GameType.Game6x4, 2, selection3);
@@ -61,12 +61,12 @@ public List<int> SimulateLateGame6x4_Move5()
6161
// Simulate late game with high precision
6262
var values = _initialValues6x4.ToList();
6363
var baseSelection = BenchmarkTestData.CreateTestSelection(GameType.Game6x4);
64-
64+
6565
// Apply multiple filtering operations
6666
values = values.HandleNoMatches(GameType.Game6x4, baseSelection);
6767
values = values.HandleBlackMatches(GameType.Game6x4, 2, 0b_001000_000100_000100_000100);
6868
values = values.HandleWhiteMatches(GameType.Game6x4, 3, 0b_000100_001000_010000_000100);
69-
69+
7070
// Final precise move
7171
return values.HandleBlackMatches(GameType.Game6x4, 3, 0b_001000_010000_000100_100000);
7272
}
@@ -86,13 +86,13 @@ public List<int> SimulateMidGame8x5_Move3()
8686
{
8787
// Simulate more complex 8x5 game progression
8888
var values = _initialValues8x5.ToList();
89-
89+
9090
// Move 1: Some white matches
9191
values = values.HandleWhiteMatches(GameType.Game8x5, 3, 0b_000100_001000_010000_100000_000010);
92-
92+
9393
// Move 2: Black matches
9494
values = values.HandleBlackMatches(GameType.Game8x5, 2, 0b_001000_000100_010000_000010_100000);
95-
95+
9696
// Move 3: More precise filtering
9797
return values.HandleBlackMatches(GameType.Game8x5, 4, 0b_000100_001000_000010_010000_100000);
9898
}
@@ -107,14 +107,14 @@ public List<int> SimulateWorstCaseFiltering()
107107
{
108108
// Scenario where filtering operations don't reduce the list much
109109
var values = _initialValues6x4.ToList();
110-
110+
111111
// Multiple operations that don't filter much
112112
for (int i = 0; i < 5; i++)
113113
{
114114
var selection = 0b_000001_000001_000001_000001 << i; // Different selections
115115
values = values.HandleWhiteMatches(GameType.Game6x4, 1, selection);
116116
}
117-
117+
118118
return values;
119119
}
120120

@@ -124,11 +124,11 @@ public List<int> SimulateBestCaseFiltering()
124124
{
125125
// Scenario where filtering operations reduce the list significantly
126126
var values = _initialValues6x4.ToList();
127-
127+
128128
// Operations that should filter aggressively
129129
values = values.HandleBlackMatches(GameType.Game6x4, 3, BenchmarkTestData.CreateTestSelection(GameType.Game6x4));
130130
values = values.HandleBlackMatches(GameType.Game6x4, 3, 0b_001000_010000_100000_000010);
131-
131+
132132
return values;
133133
}
134134

@@ -142,13 +142,13 @@ public int SimulateCompleteGame6x4()
142142
{
143143
var values = _initialValues6x4.ToList();
144144
int moveCount = 0;
145-
145+
146146
// Simulate a complete game until very few values remain
147147
while (values.Count > 10 && moveCount < 8)
148148
{
149149
moveCount++;
150150
var selection = 0b_000100_000100_000100_000100 << (moveCount % 6);
151-
151+
152152
switch (moveCount % 4)
153153
{
154154
case 0:
@@ -168,7 +168,7 @@ public int SimulateCompleteGame6x4()
168168
break;
169169
}
170170
}
171-
171+
172172
return values.Count;
173173
}
174174

0 commit comments

Comments
 (0)