Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Deploy to GitHub Pages

on:
push:
branches: [main]
workflow_dispatch:

# Allow only one deployment at a time
concurrency:
group: "pages"
cancel-in-progress: false

permissions:
contents: read
pages: write
id-token: write

jobs:
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Configure Pages
uses: actions/configure-pages@v4

- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v3
with:
# Serve entire repository root (index.html, styles.css, script.js, death-clock-core.js)
path: '.'

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
27 changes: 27 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Tests

on:
push:
pull_request:

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Run tests with coverage
run: npm run test:ci
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules/
coverage/
*.log
.DS_Store
123 changes: 122 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,122 @@
# game
# AI Death Clock 💀

> **Live site:** `https://nitrocode.github.io/game/`

A GitHub Pages visualisation that shows the environmental cost of global AI token consumption — featuring live counters, milestone tracker, token-growth chart with projections, and a prompt/PR scoring section.

Created by **RB**.

---

## Features

| Feature | Details |
|---------|---------|
| **Live counter** | Estimated global AI tokens consumed since Jan 2020, ticking in real-time |
| **Session counter** | Tokens consumed globally since *you* opened the page |
| **Environmental milestones** | 7 thresholds (trees → bees → water → coral → glaciers → ocean → extinction) with triggered status, progress bars, and consequence descriptions |
| **Growth chart** | Historical data + 18-month projection on a log scale (Chart.js) |
| **Predictions table** | Predicted calendar dates for each milestone |
| **Dark / Light mode** | Toggle button; dark mode is the default |
| **Prompt & PR scoring** | Collapsible section showing the rubric, recommendations, and score improvement |

---

## Running Locally

```bash
# Clone and open
git clone https://github.com/nitrocode/game.git
cd game
# Serve with any static server, e.g.:
npx serve .
# Then open http://localhost:3000
```

---

## Running Tests

```bash
npm install
npm test # runs Jest with coverage
npm run test:ci # CI mode (fails on coverage drop)
```

Tests are in `tests/death-clock.test.js` and cover all pure functions in `death-clock-core.js`.

---

## Deployment (GitHub Pages)

### One-time setup required after merging to `main`

1. Go to **Settings → Pages** in this repository.
2. Under **Source**, select **GitHub Actions**.
3. Push or re-run the `Deploy to GitHub Pages` workflow.
4. The site will be live at `https://nitrocode.github.io/game/`.

> ⚠️ The workflow file (`.github/workflows/deploy.yml`) is already included.
> Only step 2 (enabling GitHub Actions as the Pages source) needs to be done manually once in the repository settings.

---

## Prompt & PR Score

| | Score |
|---|---|
| **Prompt (initial)** | 74 / 100 |
| **Prompt (after recommendations)** | 94 / 100 |

### Recommendations addressed

| Recommendation | Impact | Status |
|---|---|---|
| Define "life essential" categories explicitly | +2 pts | ✅ Done |
| Specify exact token thresholds for each milestone | +4 pts | ✅ Done |
| Define preferred charting library (Chart.js) | +2 pts | ✅ Done |
| Cite data sources for environmental correlations | +2 pts | ✅ Done |
| Specify test framework (Jest) | +3 pts | ✅ Done |
| Include GitHub Pages deployment configuration | +4 pts | ✅ Done |
| Specify responsive-design requirements | +3 pts | ✅ Done |
| Define visual style | +1 pt | ✅ Done |

### Recommendations not yet addressed

| Recommendation | Impact |
|---|---|
| Specify minimum test-coverage percentage | +3 pts |
| List specific test scenarios in prompt | +2 pts |

---

## Architecture

```
.
├── index.html ← Main GitHub Pages entry point
├── styles.css ← Dark/light theme, animations, layout
├── death-clock-core.js ← Pure functions (no DOM deps; testable)
├── script.js ← DOM manipulation, Chart.js, RAF loop
├── package.json ← Jest config & dev deps
├── tests/
│ └── death-clock.test.js
└── .github/
└── workflows/
├── deploy.yml ← GitHub Pages deployment
└── test.yml ← CI test runner
```

---

## Environmental Data Sources

| Metric | Source |
|--------|--------|
| Energy per token (~0.0003 kWh / 1K tokens) | Google/DeepMind inference benchmarks, MLPerf |
| CO₂ per kWh (0.4 kg) | IEA global average grid intensity 2024 |
| Water per token (~0.5 L / 1K tokens) | Microsoft sustainability report 2023 |
| CO₂ per tree (~21 kg/year) | US Forest Service estimates |
| Historical token growth | OpenAI usage blog, Epoch AI, AI Index 2024 |

> All figures are illustrative estimates intended to communicate scale, not precise measurements.
Loading
Loading