對應的純 Java 核心演進程式碼 (Java Implementation)
import java.util.*;
public class AbbreviatedWheelSystem {
public static void main(String[] args) {
// 模擬過去開獎歷史數據
List<List<Integer>> historyDraws = Arrays.asList(
Arrays.asList(4, 15, 23, 31, 42, 48),
Arrays.asList(12, 19, 25, 33, 39, 45),
Arrays.asList(8, 14, 22, 28, 35, 41)
);
System.out.println("=== 系統確認已載入過去各期號碼 ===");
runAbbreviatedWheel(historyDraws);
}
public static void runAbbreviatedWheel(List<List<Integer>> history) {
// 定義五個區間
int[][] ranges = { {1, 10}, {11, 20}, {21, 30}, {31, 40}, {41, 49} };
int[] zoneCounts = new int[5];
// 統計最近幾期各區間出現次數以找出最冷門(可能斷區)的區間
for (List<Integer> draw : history) {
for (int num : draw) {
for (int i = 0; i < ranges.length; i++) {
if (num >= ranges[i][0] && num <= ranges[i][1]) {
zoneCounts[i]++;
}
}
}
}
// 尋找最少開出的區間作為預測斷區
int minIndex = 0;
for (int i = 1; i < zoneCounts.length; i++) {
if (zoneCounts[i] < zoneCounts[minIndex]) {
minIndex = i;
}
}
System.out.println("預測斷區(刪除區間): " + ranges[minIndex][0] + "-" + ranges[minIndex][1]);
// 在其餘四個區間中各挑選膽碼湊齊 5 膽
List<Integer> fiveBals = new ArrayList<>();
Random random = new Random();
for (int i = 0; i < ranges.length; i++) {
if (i == minIndex) continue; // 跳過刪除區間
// 模擬從該區間選取一個代表號碼
int low = ranges[i][0];
int high = ranges[i][1];
int picked = low + random.nextInt(high - low + 1);
fiveBals.add(picked);
}
// 若不足5個(通常剛好4個區間各挑1-2個補齊5個)
while (fiveBals.size() < 5) {
int extraZone = (minIndex + 1) % 5;
int low = ranges[extraZone][0];
int high = ranges[extraZone][1];
int picked = low + random.nextInt(high - low + 1);
if (!fiveBals.contains(picked)) {
fiveBals.add(picked);
}
}
System.out.println("最終產生的 5 膽組合: " + fiveBals);
}
}