Spaces:
Running
Running
Ctrl+K
You are **DeepSite v2**, tasked with generating a production-ready **React 18 + TypeScript** single-page web app. ## 1 · Project Goals 1. **Mini-Games** — Build three provably-fair games: - **Dice** — 2 × d6; player chooses over/under threshold. - **Keno** — 80-number pool, draw 20; allow 1- to 10-spot bets. - **Plinko** — 8-row board; configurable peg layout & multipliers. 2. **Strategy-Simulation Engine** — Run any user-supplied strategy function for a chosen game; demo a **Martingale** strategy (Dice, target 7, start 1 unit) over **100 rounds**, starting bankroll = 1 000. 3. **Visual Strategy Dashboard** — Display charts, tables, and auto-generated insights, plus export options (CSV, XLSX, PNG, PDF). ## 2 · Tech & Stack | Layer | Library / Tool | |-------|----------------| | Build | Vite + pnpm | | Framework | React 18, TypeScript 5.x | | State | Zustand (+ Immer) | | Styling | Tailwind CSS + DaisyUI | | RNG & Fairness | `crypto.getRandomValues` + SHA-256 hash per round | | Charts | **Recharts** (`LineChart`, `BarChart`) | | Image Export | **html-to-image** (fallback html2canvas) | | PDF Export | **jsPDF** + `jspdf-autotable` | | Excel Export | **SheetJS (xlsx)`** | | CSV Export | **Papaparse** | | Testing | Vitest + React Testing Library | | Lint / Format | ESLint (airbnb-typescript) + Prettier | ## 3 · Functional Requirements ### 3.1 Game Modules Each game exposes: ```ts playRound(action: BetInput): RoundResult // provably-fair, returns seed hash Include typed hooks and animated UI: Dice: SVG dice animation + target slider. Keno: 80-button grid, payout-table modal. Plinko: Canvas (Konva.js) board, falling-puck physics. 3.2 Strategy-Simulation Engine ts Salin Edit runSimulation(gameId, strategyFn, initialBankroll, rounds=100): SimulationResult Collect: Ledger (array of RoundResult) Metrics: ROI %, win-rate, bankroll curve, max drawdown, Sharpe ratio, 95 % CI. 3.3 <StrategyDashboard /> Displays: LineChart bankroll vs round. BarChart win / loss distribution. Summary Table (ROI, win-rate, max-DD, Sharpe). Insights Panel — auto analysis & ≥ 3 improvement tips. Auto-analysis helper: ts Salin Edit analyzeStrategy(result: SimulationResult): StrategyInsight // classifies performance & returns improvement suggestions 3.4 Export & Persistence Buttons: Download CSV / Excel / PNG / PDF. PNG: htmlToImage.toPng(chartRef.current). PDF: combine title, PNG, and jspdf-autotable summary; optional “Include Insights”. LocalStorage: remember last bankroll, strategy, and game. 3.5 Demo Flow On first load: Auto-run Martingale on Dice (100 rounds). Show dashboard with charts, insights, and export buttons. 4 · Code Quality 100 % typed, no any. PEP-8-equivalent ESLint rules (airbnb-typescript). Google-style JSDoc for all public functions. Unit tests for each game, runSimulation, and analyzeStrategy. CI: lint + vitest. 5 · File Structure bash Salin Edit /src /games dice.ts keno.ts plinko.ts /sim engine.ts strategies.ts /analysis analyze.ts stats.ts /export exportCsv.ts exportXlsx.ts exportPng.ts exportPdf.ts /components ui/* /pages Home.tsx GamePage.tsx SimulationPage.tsx tests/ public/ README.md 6 · Deliverables Return one Markdown response containing every file in fenced code-blocks and a complete README.md with setup (pnpm i && pnpm dev), build (pnpm build), test (pnpm test), and extension guidelines. Do not output anything outside the code-blocks. markdown Salin Edit --- ### Key Improvements - **Visual + Multi-Format Export**: charts & ledger downloadable as CSV, Excel, PNG, or one-click PDF report. - **Auto Insight Engine**: delivers analytics-driven recommendations (e.g., cap Martingale progression, add stop-loss). - **Provably-Fair Client RNG**: SHA-256 seeds shown each round for transparency. - **Stack Aligned to DeepSite**: React 18, Zustand, Tailwind ensure fast build with DeepSite v2 presets. ### Techniques Applied Stack realignment • Modular hooks • DOM-to-image capture • PDF composition • Rule-based insights • Demo-first UX. ### Pro Tip After validating Martingale, clone `strategies/martingale.ts`, tweak progression or introduce a Kelly criterion; the dashboard auto-re-runs and exports updated analysis without altering core logic. ::contentReference[oaicite:0]{index=0} - Initial Deployment
6fe786e verified