{"id":31642345,"url":"https://github.com/setrf/seedtovoid","last_synced_at":"2026-05-05T19:32:37.770Z","repository":{"id":315910126,"uuid":"1056308858","full_name":"setrf/seedtovoid","owner":"setrf","description":"Survival twist on Conway’s Game of Life - mobile‑first, pattern cooldowns, escalating threats, per‑difficulty leaderboards.","archived":false,"fork":false,"pushed_at":"2025-10-04T20:51:46.000Z","size":1341,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-20T04:42:45.870Z","etag":null,"topics":["canvas-2d","cellular-automata","game-of-life","react","typescript","vite","webgame","zustand"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/setrf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-13T20:15:03.000Z","updated_at":"2025-10-04T20:51:50.000Z","dependencies_parsed_at":"2025-09-21T15:50:32.350Z","dependency_job_id":"c3c2f1e3-f3c4-4ba5-b842-a21de310ad5a","html_url":"https://github.com/setrf/seedtovoid","commit_stats":null,"previous_names":["setrf/seedtovoid"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/setrf/seedtovoid","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/setrf%2Fseedtovoid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/setrf%2Fseedtovoid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/setrf%2Fseedtovoid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/setrf%2Fseedtovoid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/setrf","download_url":"https://codeload.github.com/setrf/seedtovoid/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/setrf%2Fseedtovoid/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32664905,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-05T11:29:49.557Z","status":"ssl_error","status_checked_at":"2026-05-05T11:29:48.587Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["canvas-2d","cellular-automata","game-of-life","react","typescript","vite","webgame","zustand"],"created_at":"2025-10-07T03:58:39.100Z","updated_at":"2026-05-05T19:32:37.764Z","avatar_url":"https://github.com/setrf.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Game of Life – Survival Edition\n\nA fast, touch‑friendly survival take on Conway’s Game of Life. You command a resilient green colony battling red threats that spawn, move, and escalate over time. Play on desktop or mobile with a canvas‑accelerated grid, bottom HUD, and an always‑visible pattern dock. Scores persist per difficulty, with optional Postgres storage.\n\n\n## Features at a Glance\n\n- Survival mode with escalating difficulty (“Level”) and threat waves\n- Always‑visible Pattern Dock with per‑pattern cooldowns\n- Mobile‑first UI: floating HUD (Play/Pause, Controls, Reset, 🏆), mini stats overlay\n- Canvas 2D renderer with adaptive grid sizing and crisp cell borders\n- Leaderboards per difficulty, plus an all‑time modal across difficulties\n- Onboarding splash with dynamic step sizing and quick controls tutorial\n- Keyboard shortcuts for power users (Space = Play/Pause, R = Reset)\n\n\n## Gameplay \u0026 Dynamics\n\n- Unit conversion rule: when red and green groups touch, the larger group converts the smaller one. Your colony survives as long as at least one green cell remains.\n- Threats: hostile patterns (e.g., gliders, LWSS, curated patterns) spawn near your cells. Spawn probability scales by difficulty and escalates with time.\n- Difficulty escalation (“Level”): every 10s of survival during play increases an internal level. Each level ramps:\n  - Spawn rate multiplier\n  - Max simultaneous threats\n  The current Level is visible in Stats and resets on defeat or reset.\n- Scoring: survival time and combat events contribute to score. Notifications highlight milestones (time, score, generations).\n- Patterns \u0026 cooldowns:\n  - Select from classic Life patterns (Glider, Block, Blinker, Beacon, Toad, R‑Pentomino, LWSS, Pulsar, Glider Gun).\n  - Each applies a cooldown that scales inversely with sim speed (higher speed → shorter real‑time cooldown).\n  - Cooldowns freeze while paused (both visually and in enforcement). Resuming shifts timestamps so remaining time is preserved.\n- Placement modes: stamping is default. Replace mode exists in the store and can be extended to UI if desired.\n- Controls:\n  - Play/Pause, Speed slider, Reset, Leaderboard modal.\n  - Touch devices: larger hit targets, manipulation‑safe touch events.\n\n\n## Mobile UX\n\n- Pattern Dock: always visible above the bottom HUD. Wraps into multiple rows; chips show full pattern names and a thin progress bar for cooldown. On ultra‑narrow screens chips condense but retain names.\n- HUD: floating bottom bar with Play/Pause, Controls (opens modal), Reset, and 🏆 Leaderboard. When Controls or Leaderboard is open, the game pauses and resumes after closing (only if it was running before).\n- Mini Stats: small glass overlay (top‑left) with SCR/GEN/THRT. The game canvas reserves bottom padding so it never sits under HUD/dock.\n\n\n## Client Architecture\n\n- Stack: React + Vite + Zustand (`subscribeWithSelector`) + Canvas 2D.\n- Core components:\n  - `Grid2D.tsx`: Canvas renderer. Adaptive sizing uses a `ResizeObserver` with throttling. It computes a grid that fills available space, clamps dimensions, and recomputes a pixel‑perfect `cellSize`. Grid lines and borders draw only when cells are large enough for clarity.\n  - `GameOfLife.tsx`: Page layout. Renders control panels (desktop), canvas, Game Over overlay, mobile HUD, pattern dock, and stats overlay.\n  - `GameControls.tsx`, `DifficultySelector.tsx`, `PatternSelector.tsx` (desktop), `StatsPanel.tsx`.\n  - Mobile‑only: `MobileHUD.tsx`, `MobilePatternDock.tsx`, `MobileControlsModal.tsx`, `MobileStatsOverlay.tsx`.\n  - Onboarding: `OnboardingModal.tsx` with dynamically sized steps.\n- Store: `client/src/lib/stores/useGameOfLife.tsx`\n  - State: grid data, timing, speed, survival stats, difficulty mode, escalation level, threat sets, cooldowns, progression (resources/unlocks primitives remain as scaffolding), notifications, stamping state.\n  - Timers: sim loop interval (based on speed), threat spawn interval, optional regeneration hooks.\n  - Pause semantics: `stop()` records `pauseTime` and sets `isRunning=false`. Cooldown checks and scaling use an “effective now” of `pauseTime` when paused, so time truly freezes. On `start()`, time spent paused is added to future timestamps to resume fairly.\n  - Grid ops: `step()` computes next generation, applies unit conversion and threat ownership diffusion, updates stats, and triggers game over on extinction.\n  - Pattern stamping: strict cooldown enforcement at click/touch; cooldown anchors to `pauseTime` when applied in a paused state.\n\n\n## Server \u0026 Storage\n\n- Dev server: `server/vite.ts` runs Vite in middleware mode (development) and serves the SPA. In production it serves static files from `dist/public`.\n- API routes: `server/routes.ts`\n  - `GET /api/high-scores?difficulty=easy|normal|hard` → top 10 scores for a difficulty\n  - `POST /api/high-scores` → create a score. Validated with zod against the shared schema.\n- Storage: `server/storage.ts`\n  - **Default is `FileStorage`** (JSON file persistence) - Stores scores in `data/high-scores.json`\n  - Alternative: `MemStorage` (in-memory, lost on restart)\n  - Alternative: `DBStorage` (PostgreSQL via Drizzle ORM)\n  - Toggle by changing the export at the bottom of the file\n- Schema: `shared/schema.ts` (Drizzle + zod)\n  - Table `high_scores` with fields: `id`, `username`, `score`, `timeSurvived`, `threatsDefeated`, `cellsPlaced`, `timestamp`, `difficulty`.\n\n### Storage Options\n\n**FileStorage (Default - Production)**\n- Persists scores to `data/high-scores.json`\n- Auto-creates directory structure on startup\n- Maintains ID sequence across restarts\n- No database required\n- Simple backup: copy JSON file\n\n**To enable Postgres (DBStorage)**:\n1. Set `DATABASE_URL` in the environment.\n2. Switch `export const storage = new FileStorage();` to `export const storage = new DBStorage();` in `server/storage.ts`.\n3. Apply the schema to your DB (Drizzle migrations or manual create) and restart the server.\n\n\n## Commands\n\n- Development: `npm run dev`\n  - Starts Express on port 3001 and Vite middleware; client is served via Vite; API proxied at `/api`.\n- Build: `npm run build`\n  - Builds client to `dist/public` (Vite), bundles server to `dist/index.js` (esbuild).\n- Production: `npm start`\n  - Runs Node on the bundled server; serves static client and `/api`.\n\n## Production Deployment\n\nThe application is deployed to `/opt/seedtovoid/` and runs as a systemd service.\n\n### Deployment Process\n\n```bash\n# 1. Build the application\nnpm run build\n\n# 2. Deploy to production\nsudo rsync -av dist/ /opt/seedtovoid/dist/\n\n# 3. Restart the service\nsudo systemctl restart seedtovoid.service\n```\n\n### Hot Deploy (Client Only - No Downtime)\n\nWhen only client files change (HTML, CSS, JS), deploy without restarting:\n\n```bash\n# Build only\nnpm run build\n\n# Deploy only static files\nsudo rsync -av dist/public/ /opt/seedtovoid/dist/public/\n\n# No restart needed - Express serves updated files immediately\n```\n\n### Service Management\n\n```bash\n# Check status\nsystemctl status seedtovoid.service\n\n# View logs\njournalctl -u seedtovoid -n 100 -f\n\n# Restart service\nsudo systemctl restart seedtovoid.service\n```\n\n### Environment Configuration\n\nLocated at `/etc/seedtovoid.env`:\n```env\nNODE_ENV=production\nPORT=4006\nNODE_PATH=/opt/seedtovoid/node_modules\n```\n\n### Data Persistence\n\n- **High Scores**: Stored in `/opt/seedtovoid/data/high-scores.json`\n- **Backup**: `sudo cp /opt/seedtovoid/data/high-scores.json ~/backup-scores-$(date +%F).json`\n- **Restore**: `sudo cp ~/backup-scores-YYYY-MM-DD.json /opt/seedtovoid/data/high-scores.json`\n\n\n## Configuration \u0026 Tuning\n\n- Difficulty presets: `DIFFICULTY_SETTINGS` in `useGameOfLife.tsx` control spawn rate multipliers, max threats, and escalation rate per mode.\n- Pattern cooldowns: defined in the store (and mirrored in UI helpers). Adjust per pattern and the speed scaling rule as needed.\n- Grid sizing: see `Grid2D.calculateOptimalGridSize()` for min/max grid dimensions and target cell sizes.\n- Mobile layout: most rules live in `client/src/index.css` under mobile media queries. The canvas reserves bottom padding so HUD/dock never overlap the interactive grid.\n\n\n## Keyboard \u0026 Touch\n\n- Keyboard: `Space` toggles Play/Pause, `R` resets; `H` reopens onboarding.\n- Touch: simple tap to toggle a cell or stamp the selected pattern. Hit targets are widened; `touchAction: 'manipulation'` avoids scroll interference.\n\n\n## Analytics\n\nThe application includes Google Analytics (G-740WZ4LG3W) for tracking:\n- Page views and user sessions\n- Gameplay interactions and events\n- Traffic sources and user behavior\n\nThe tracking code is loaded in `client/index.html` and automatically tracks page views. No additional configuration required.\n\n## Notes \u0026 Extensibility\n\n- Replace mode is wired in the store; surfacing it in UI is straightforward (toggle chip in Controls).\n- Resources/unlocks scaffolding exists in the store and logs; it's disabled in onboarding and not exposed in UI.\n- Cooldown/Level reset behavior:\n  - Cooldowns freeze when paused; resume honors the remaining time.\n  - Level resets to 0 on defeat and on reset/try‑again. Escalation resumes once playing.\n\n\n## Folder Structure\n\n- `client/` – React app (Vite). Key paths:\n  - `src/components/` – UI: grid, controls, modals, mobile overlays\n  - `src/lib/stores/useGameOfLife.tsx` – game state and logic\n  - `src/lib/patterns.ts` – classic Life patterns\n  - `src/index.css` – design system and responsive styles\n- `server/` – Express API + Vite middleware (dev) or static (prod)\n- `shared/` – DB schema and zod validator for high scores\n- `dist/` – build output (client in `public/`, server bundle in root)\n\n\n## License\n\nMIT\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsetrf%2Fseedtovoid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsetrf%2Fseedtovoid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsetrf%2Fseedtovoid/lists"}