• Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
saman

saman

mazegame

Just doing a little test run over here
Public
Like
mazegame
Home
Code
3
README.md
game.js
H
index.html
Branches
1
Pull requests
Remixes
History
Environment variables
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
README.md
Code
/
README.md
Search
10/2/2025
Viewing readonly version of main branch: v7
View latest version
README.md

Coin Collection Game

A turn-based strategy game where you compete against an AI monster to collect coins on a grid-based map.

How to Play

  • Objective: Collect as many coins as possible before the monster does
  • Controls: Use arrow keys (↑↓←→) to move your character
  • Game Flow:
    1. You move first using arrow keys
    2. After each of your moves, the monster automatically moves
    3. The game ends when all 5 coins are collected
    4. Winner is determined by who collected the most coins

Game Features

Grid Generation

  • 10x10 grid with randomly placed walls (20% of tiles)
  • Ensures there's always a path between player and monster starting positions
  • Player starts in top-left corner (👤)
  • Monster starts in bottom-right corner (👹)

AI Monster Behavior

  • Uses Dijkstra's algorithm to find the shortest path to the nearest coin
  • Moves optimally toward coins, making strategic decisions
  • Will compete directly with the player for coin collection

Visual Elements

  • Player: 👤 (blue)
  • Monster: 👹 (red)
  • Coins: 🪙 (gold)
  • Floor tiles: Light gray
  • Wall tiles: Dark gray
  • Score tracking: Real-time display of player score, monster score, and remaining coins

Game Mechanics

  • Turn-based movement (player moves, then monster moves)
  • Collision detection with walls
  • Automatic coin collection when stepping on coin tiles
  • Game over screen with final scores and winner announcement
  • "New Game" button to restart with a fresh randomly generated map

Technical Implementation

  • Frontend: Vanilla JavaScript with HTML5 and CSS3
  • Styling: TailwindCSS for responsive design
  • Pathfinding: Dijkstra's algorithm for monster AI
  • Grid Generation: Procedural generation with connectivity validation
  • Game State: Complete turn-based game loop with win/lose conditions

Controls

  • ↑ Arrow Up: Move player up
  • ↓ Arrow Down: Move player down
  • ← Arrow Left: Move player left
  • → Arrow Right: Move player right
  • New Game Button: Start a new game with fresh map and reset scores

Enjoy the challenge of outsmarting the AI monster!

FeaturesVersion controlCode intelligenceCLIMCP
Use cases
TeamsAI agentsSlackGTM
DocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Open Source Pledge
Terms of usePrivacy policyAbuse contact
© 2026 Val Town, Inc.