static void Main(string[] args) { List<Position> positionList = new List<Position>(); positionList.AddRange(new Position[] { Position.GreenGoal4, Position.GreenGoal3, Position.GreenGoal2, Position.GreenGoal1}); for (int p = (int)Position.Yellow6; p >= (int)Position.GreenStart; p--) { positionList.Add((Position)p); } positionList.AddRange(new Position[] { Position.GreenHome4, Position.GreenHome3, Position.GreenHome2, Position.GreenHome1 }); Position[] positionOrder = positionList.ToArray(); int len = positionOrder.Length; int homeStart = len-4; bool first = true; for (int i = 0; i < len; i++) { for (int j = Math.Max(i, 1); j < len; j++) { if (i == j && i >= homeStart) continue; for (int k = Math.Max(j, 2); k < len; k++) { if (j == k && j >= homeStart) continue; for (int l = Math.Max(k,3); l < len; l++) { if (k == l && k >= homeStart) continue; var pos = getStartPositions(); pos[0] = positionOrder[i]; pos[1] = positionOrder[j]; pos[2] = positionOrder[k]; pos[3] = positionOrder[l]; Situation sit = new Situation(pos); Situation s2 = new Situation(sit); if (s2.UnfoldMultiples(Piece.Green)) { continue; } int nomoves = 0; decimal ev = 0; if (first) { SaveValue(sit, 0); first = false; continue; } for (int roll = 1; roll <= 6; roll++) { Move[] moves = sit.GetMoves(Piece.Green, roll); if (moves.Length == 0) { nomoves++; } else { decimal value = Decimal.MaxValue; foreach(Move move in moves) { Situation s = new Situation(sit); s.ApplyMove(move); value = Math.Min(value, GetValue(s)); } ev += value; } } if (sit.GetNumberOfTries(Piece.Green) == 3) { ev = (5 * nomoves * nomoves + (36 + 6 * nomoves + nomoves * nomoves) * ev) / (216 - nomoves * nomoves * nomoves); } else { ev = (5 + ev) / (6 - nomoves); } SaveValue(sit, ev); Console.WriteLine(positionOrder[i] + " " + positionOrder[j] + " " + positionOrder[k] + " " + positionOrder[l] + ": " + ev); } } } } Byte[] bytes = new Byte[6 * dict.Count]; int offset = 0; foreach (KeyValuePair<int, decimal> kvp in dict) { Array.Copy(System.BitConverter.GetBytes(kvp.Key), 0, bytes, offset, 4); offset += 4; Array.Copy(System.BitConverter.GetBytes((Int16)(kvp.Value * 256)), 0, bytes, offset, 2); offset += 2; } File.WriteAllBytes("singleplayer.data", bytes); Console.ReadLine(); }
public void Test3ThrowsForFullyInGoal() { Position[] pos = getStartPositions(); pos[4] = Position.RedGoal3; pos[5] = Position.RedGoal4; Situation sit = new Situation(pos); Assert.AreEqual(3, sit.GetNumberOfTries(Piece.Red)); }
public void TestOnly1ThrowNormally() { Position[] pos = getStartPositions(); pos[12] = Position.YellowGoal3; Situation sit = new Situation(pos); Assert.AreEqual(1, sit.GetNumberOfTries(Piece.Yellow)); }
public void Test0ThrowsWhenFinishedButBeerLeft() { Position[] pos = getStartPositions(); pos[4] = Position.RedGoal3; pos[5] = Position.RedGoal4; pos[6] = Position.RedGoal2; pos[7] = Position.RedGoal1; Situation sit = new Situation(pos); sit.beers[(int)Piece.Red] = 3; Assert.AreEqual(0, sit.GetNumberOfTries(Piece.Red)); }