---
title: CODE-DUEL
canonical_url: "https://www.modelscope.ai/studios/RobertDowneySyndrome/CODE-DUEL"
md_url: "https://www.modelscope.ai/studios/RobertDowneySyndrome/CODE-DUEL.md"
repository: RobertDowneySyndrome/CODE-DUEL
last_updated: 2026-11-04
sdk_type: gradio
sdk_version: 6.29.1
downloads: 0
stars: 1
---

# CODE-DUEL

> CODE-DUEL - An interactive demo by RobertDowneySyndrome on ModelScope. CODE DUEL turns boring, passive coding practice into a pixel-art boss fight inspired by the Chrome offline dinosaur game. Pick a language (Python, JavaScript or C++), a difficulty (Easy…

RobertDowneySyndrome/CODE-DUEL is an interactive demo (Studio) on ModelScope. built with gradio 6.29.1.

- **Repository**: RobertDowneySyndrome/CODE-DUEL
- **SDK**: gradio
- **SDK version**: 6.29.1
- **Downloads**: 0
- **Stars**: 1
- **Last updated**: 2026-11-04

Source: https://www.modelscope.ai/studios/RobertDowneySyndrome/CODE-DUEL

---

# CODE DUEL

A boss-fight programming quiz game built with Python and Gradio, styled after
the Chrome offline dinosaur game. Created for the CAICC 2026 competition and
deployed on ModelScope Studio (free CPU).

## The Problem

Most coding practice is passive and boring — you read a question, think about
it, maybe type an answer, and move on. CODE DUEL turns every question into a
real-time battle: a pixel-art boss looms on screen, a countdown ticks down,
and you must pick the right answer before time runs out. Wrong answers or
timeouts cost HP. Correct answers damage the boss. Defeat all three bosses to
win.

## How to Play

1. Choose a programming language (Python, JavaScript, or C++), difficulty,
   topic, and explanation language.
2. Press **START** to face the first boss: **BUG BEETLE** (60 HP).
3. Each question is multiple choice (A/B/C/D) with a countdown timer.
   - Answer quickly for a speed bonus.
   - Build a streak of 3 correct answers for combo damage.
   - Wrong answer: you lose 20 HP. Timeout: you lose 25 HP.
4. Defeat a boss to heal 15 HP and face the next one.
5. Three bosses in order: BUG BEETLE, NULL GHOST, KERNEL PANIC.
6. Player HP reaches 0 = game over. All three bosses defeated = victory.

## How GLM-5.2 Is Used

Questions are generated by the **zai-org/GLM-5.2** model through ModelScope
API-Inference (OpenAI-compatible endpoint at
`https://api-inference.modelscope.ai/v1`). The `openai` Python package sends
a streaming chat completion request asking the model to produce JSON-formatted
multiple-choice questions with code snippets, options, and explanations.

Only approved ModelScope models are ever called: **zai-org/GLM-5.2**,
**deepseek-ai/DeepSeek-V4-Pro-0813**, **stepfun-ai/Step-3.5-Flash**, and
**Qwen/Qwen3.8-27B**. The default is GLM-5.2.

### Built-in Fallback

If no token is set or the API is unavailable, the game automatically falls
back to a built-in bank of 24 hand-crafted questions (8 per language) so it
always works — no API key required to play.

## Running Locally

```bash
pip install -r requirements.txt
python app.py
```

Then open the URL shown in the terminal (default `http://0.0.0.0:7860`).

To use AI-generated questions, set the environment variable:

```bash
export MODELSCOPE_TOKEN=your_token_here
```

Without a token, the game uses the built-in question bank.

## Deploying to ModelScope Studio

1. Upload all files listed in `DEPLOY_FILES.txt`.
2. In Studio Secrets, add `MODELSCOPE_TOKEN` with your ModelScope API token.
3. The app starts automatically via `python app.py`.

The token is read **only** from the environment variable
`MODELSCOPE_TOKEN`. It is never hardcoded, printed, logged, or written to any
file. Gradio is provided by the Studio host — `requirements.txt` only lists
`openai`.
