How sanusmxgame/thimbles-ai-tool works
Project Type and Purpose
• Type: Browser-side AI / computer-vision helper tool with an optional local simulator
• Purpose:
– Live overlay on third-party Thimbles games via a Tampermonkey user script
– Offline/local simulation via static files and a minimal Python server
Main Components
a. Client Browser Environment
• Tampermonkey extension (runs the user script)
• Native JavaScript environment (index.html + logic.js + tracking.js)
• TensorFlow.js integration for ML inference
b. User Script Layer
• thimbles-cup-highlighter.user.js (injected into the target page)
• Hooks into the DOM, captures canvas frames, calls the detection logic
c. Core Logic & Tracking
• logic.js – prediction orchestration (cup location + provably-fair decoding)
• tracking.js – frame-by-frame canvas analysis and visual tracking routines
d. Offline Simulation
• index.html + style.css – a self-contained UI for simulating the game
• simulator.js – reads data/incoming.json, feeds frames into tracking.js
• data/incoming.json – canned game frames and metadata
• server.py – Python’s http.server to host the static assets
e. External Dependencies
• TensorFlow.js (for optional training and inference)
• Tampermonkey (script injection)
Relationships & Data Flows
• Live Mode Flow:
1. User navigates to Odds96 Thimbles game
2. Tampermonkey script injects thimbles-cup-highlighter.user.js
3. Script captures the canvas element’s frames
4. Frames > tracking.js → identifies cup positions
5. logic.js decodes “provably fair” data & runs TensorFlow.js model
6. Overlay highlights the correct cup in real time
• Offline Mode Flow:
1. User runs python -m http.server (server.py)
2. Browser loads index.html + style.css
3. simulator.js reads data/incoming.json
4. simulator.js pipelines frames through tracking.js & logic.js
5. UI displays results on the local page
Architectural Patterns & Principles
• Modular separation between:
– Script injection layer (Tampermonkey)
– Core detection logic (logic.js + tracking.js)
– Data source layer (live canvas vs. incoming.json)
• Clear extension points: swap in different ML models (TensorFlow.js), plug in new simulation data
• Single responsibility per file:
– tracking.js only handles computer-vision tasks
– logic.js orchestrates flow and ML interactions
– simulator.js abstracts offline data feeding