using System.Collections.Generic;
public int[] 固定十字 = { 2, 7, 10, 11, 12, 13, 14, 17, 22 };
public int[] 區塊A = { 0, 1, 5, 6 };
public int[] 區塊B = { 3, 4, 8, 9 };
public int[] 區塊C = { 15, 16, 20, 21 };
public int[] 區塊D = { 18, 19, 23, 24 };
public int[] 盤面 = new int[25];
public Dictionary<int, double> 開獎機率 = new Dictionary<int, double>();
public List<int> 開獎數字 = new List<int>();
public 賓果遊戲(Dictionary<int, double> 獎號機率)
public void 旋轉區塊(int[] 區塊, int 旋轉次數)
for (int i = 0; i < 旋轉次數; i++)
for (int row = 0; row < 5; row++)
得分 += 檢查期望連線(row * 5, row * 5 + 1, row * 5 + 2, row * 5 + 3, row * 5 + 4);
for (int col = 0; col < 5; col++)
得分 += 檢查期望連線(col, col + 5, col + 10, col + 15, col + 20);
得分 += 檢查期望連線(0, 6, 12, 18, 24);
得分 += 檢查期望連線(4, 8, 12, 16, 20);
private double 檢查期望連線(params int[] 位置)
if (開獎機率.ContainsKey(盤面[i]))
for (int a = 0; a < 4; a++)
for (int b = 0; b < 4; b++)
for (int c = 0; c < 4; c++)
for (int d = 0; d < 4; d++)
Array.Clear(盤面, 0, 盤面.Length);
public int 計算實際得分(List<int> 實際數字)
for (int row = 0; row < 5; row++)
得分 += 檢查實際連線(row * 5, row * 5 + 1, row * 5 + 2, row * 5 + 3, row * 5 + 4, 實際數字);
for (int col = 0; col < 5; col++)
得分 += 檢查實際連線(col, col + 5, col + 10, col + 15, col + 20, 實際數字);
得分 += 檢查實際連線(0, 6, 12, 18, 24, 實際數字);
得分 += 檢查實際連線(4, 8, 12, 16, 20, 實際數字);
private int 檢查實際連線(int pos1, int pos2, int pos3, int pos4, int pos5, List<int> 實際數字)
int[] 連線 = { pos1, pos2, pos3, pos4, pos5 };
if (實際數字.Contains(盤面[pos]))
public static void Main(string[] args)
Random rnd = new Random();
Dictionary<int, double> 開獎機率 = new Dictionary<int, double>
賓果遊戲 game = new 賓果遊戲(開獎機率);
for (int i = 0; i < 1000; i++)
Console.WriteLine($"第 {i + 1} 局:");
List<int> 前三個數字 = new List<int>();
int 隨機數字 = rnd.Next(2, 23);
if (!前三個數字.Contains(隨機數字))
int[] 最佳旋轉策略 = game.找到最佳旋轉策略();
game.旋轉區塊(game.區塊A, 最佳旋轉策略[0]);
game.旋轉區塊(game.區塊B, 最佳旋轉策略[1]);
game.旋轉區塊(game.區塊C, 最佳旋轉策略[2]);
game.旋轉區塊(game.區塊D, 最佳旋轉策略[3]);
int[] 得分分佈 = new int[100];
for (int j = 0; j < 100; j++)
List<int> 第四第五個數字 = new List<int>(前三個數字);
while (第四第五個數字.Count < 5)
int 隨機數字 = rnd.Next(2, 23);
if (!第四第五個數字.Contains(隨機數字))
int 實際得分 = game.計算實際得分(第四第五個數字);
for (int k = 0; k < 100; k++)
Console.WriteLine($"第 {i + 1} 局的平均得分: {平均得分}\n");