05/23 Phase 16
This commit is contained in:
+45
-3
@@ -19,7 +19,7 @@ from db.models import (
|
||||
delete_prediction, delete_all_predictions,
|
||||
)
|
||||
from core.predictor import (
|
||||
hot_numbers, due_numbers, weighted_random, monte_carlo, positional_pick,
|
||||
hot_numbers, due_numbers, weighted_random, monte_carlo, positional_pick, quick_pick,
|
||||
)
|
||||
from core.checker import check_ticket, parse_numbers
|
||||
from core.exporter import export_predictions_excel, export_predictions_csv, ensure_exports_dir
|
||||
@@ -33,6 +33,7 @@ _STRATEGIES = {
|
||||
"Weighted Random": weighted_random,
|
||||
"Monte Carlo": monte_carlo,
|
||||
"Positional": positional_pick,
|
||||
"Quick Pick": quick_pick,
|
||||
}
|
||||
|
||||
_DESCRIPTIONS = {
|
||||
@@ -41,6 +42,7 @@ _DESCRIPTIONS = {
|
||||
"Weighted Random": "Random pick weighted by each number's historical frequency.",
|
||||
"Monte Carlo": "10,000 simulated draws — pick the most often-selected numbers.",
|
||||
"Positional": "Most frequent number at each draw position (1–5).",
|
||||
"Quick Pick": "Pure random selection — no historical data required.",
|
||||
}
|
||||
|
||||
_TICKET_COUNTS = [str(n) for n in range(1, 11)]
|
||||
@@ -115,8 +117,12 @@ class PredictorScreen(ttk.Frame):
|
||||
values=_TICKET_COUNTS, state="readonly", width=4,
|
||||
).pack(side="left", padx=(4, 0))
|
||||
|
||||
ttk.Label(bar, text="Exclude:", padding=(12, 0, 0, 0)).pack(side="left")
|
||||
self._exclude_var = tk.StringVar()
|
||||
ttk.Entry(bar, textvariable=self._exclude_var, width=14).pack(side="left", padx=(4, 0))
|
||||
|
||||
self._gen_btn = ttk.Button(bar, text="Generate", command=self._generate)
|
||||
self._gen_btn.pack(side="left", padx=(14, 0))
|
||||
self._gen_btn.pack(side="left", padx=(12, 0))
|
||||
|
||||
# Results treeview
|
||||
tree_frame = ttk.Frame(parent)
|
||||
@@ -164,6 +170,11 @@ class PredictorScreen(ttk.Frame):
|
||||
)
|
||||
self._save_btn.pack(side="right")
|
||||
|
||||
self._copy_btn = ttk.Button(
|
||||
bottom, text="Copy", command=self._copy_tickets, state="disabled"
|
||||
)
|
||||
self._copy_btn.pack(side="right", padx=(0, 4))
|
||||
|
||||
ttk.Button(bottom, text="Clear", command=self._clear
|
||||
).pack(side="right", padx=(0, 4))
|
||||
ttk.Button(bottom, text="Export CSV", command=self._export_csv
|
||||
@@ -325,10 +336,12 @@ class PredictorScreen(ttk.Frame):
|
||||
self.update_idletasks()
|
||||
|
||||
try:
|
||||
tickets = [strategy_fn(self._game_id) for _ in range(count)]
|
||||
excl = self._parse_exclude()
|
||||
tickets = [strategy_fn(self._game_id, exclude=excl) for _ in range(count)]
|
||||
self._tickets = tickets
|
||||
self._display(tickets)
|
||||
self._save_btn.config(state="normal")
|
||||
self._copy_btn.config(state="normal")
|
||||
self._status_var.set(f"{len(tickets)} ticket{'s' if len(tickets) != 1 else ''} generated.")
|
||||
logger.info("[PREDICT] %d ticket(s) generated via %s", count, self._strategy_var.get())
|
||||
except Exception as e:
|
||||
@@ -360,6 +373,34 @@ class PredictorScreen(ttk.Frame):
|
||||
self._refresh_saved()
|
||||
logger.info("[PREDICT] Saved %d prediction(s) to DB", saved)
|
||||
|
||||
def _parse_exclude(self) -> set:
|
||||
raw = self._exclude_var.get().strip()
|
||||
if not raw:
|
||||
return set()
|
||||
result = set()
|
||||
for tok in raw.replace(",", " ").split():
|
||||
try:
|
||||
result.add(int(tok))
|
||||
except ValueError:
|
||||
pass
|
||||
return result
|
||||
|
||||
def _copy_tickets(self):
|
||||
if not self._tickets:
|
||||
return
|
||||
game = get_game_by_name(self._game_var.get())
|
||||
show_bonus = game is not None and game["bonus_count"] > 0
|
||||
lines = []
|
||||
for i, t in enumerate(self._tickets, 1):
|
||||
nums = " ".join(f"{n:02d}" for n in t["numbers"])
|
||||
line = f"Ticket {i}: {nums}"
|
||||
if show_bonus and t["bonus"] is not None:
|
||||
line += f" + {t['bonus']:02d}"
|
||||
lines.append(line)
|
||||
self.clipboard_clear()
|
||||
self.clipboard_append("\n".join(lines))
|
||||
self._status_var.set("Copied to clipboard.")
|
||||
|
||||
def _on_gen_row_select(self, _event=None):
|
||||
for w in self._gen_detail.winfo_children():
|
||||
w.destroy()
|
||||
@@ -383,6 +424,7 @@ class PredictorScreen(ttk.Frame):
|
||||
for w in self._gen_detail.winfo_children():
|
||||
w.destroy()
|
||||
self._save_btn.config(state="disabled")
|
||||
self._copy_btn.config(state="disabled")
|
||||
self._status_var.set("")
|
||||
|
||||
def _export_excel(self):
|
||||
|
||||
Reference in New Issue
Block a user