Battle Game is a modular, deterministic, tile-based tactics engine built for experimentation, AI development, and rapid prototyping of combat mechanics. It features mobile-friendly interaction, a clean rendering pipeline, and an extensible unit system with movement, attack ranges, zones, and team logic.
-
Two opposing teams battle on a grid-based board
-
Units have attributes such as:
-
movement
-
damage
-
defense
-
attack range (now min–max range bands)
-
special properties (transfer, collaboration, etc.)
-
-
Combat is deterministic: no randomness, no dice
-
Positioning, range bands, and zone control define the strategy
-
The game supports both play mode and edit mode for scenario building
-
Canvas-based renderer with fully drawn background and borders (no CSS artifacts)
-
Right-click context menu for placing units during edit mode
-
Dynamic team toggle with color-aware UI
-
Min–max attack range system (supports donut-shaped threat zones)
-
Coordinate overlays for debugging and development
-
Mobile-friendly interaction (tap-to-select, large hit targets)
-
Fully exportable board images (everything drawn directly on canvas)
-
Scalable layout for different resolutions and viewport sizes
-
Board rendered on an HTML5 ``
-
All visuals (background, borders, grid, units, overlays) drawn directly to the bitmap
-
No CSS-based drawing → exported images are complete
-
Right-click context menu built with lightweight DOM overlay
-
Unit definitions stored in key/value sets (e.g.,
classic_set()) -
Placement uses
placeUnit(r, c, team, key) -
Attack logic uses Manhattan distance with min–max range bands
-
Canvas resizing synchronized between CSS and internal resolution to avoid scroll issues
-
Optional viewport-scaled rendering for multi-resolution support
Edit mode enables rapid scenario creation:
-
Right-click a tile → open unit menu
-
Select a unit → instantly place it
-
Toggle team with the UI switch
-
Escape or right-click off → close menu
-
Coordinate overlays help with debugging and layout
-
All interactions update the board immediately
This mode is ideal for designing puzzles, AI test cases, or tactical scenarios.
-
Fog of war
-
Line-of-sight and cover mechanics
-
Terrain modifiers
-
Unit abilities and status effects
-
Undo/redo stack
-
Save/load scenarios
-
AI opponent with threat evaluation
-
Zoom and pan for large boards
-
Custom emoji-based unit glyphs
Battle Game is designed to be:
-
Deterministic — no hidden randomness
-
Modular — each subsystem isolated and replaceable
-
Extensible — new units, rules, and mechanics drop in cleanly
-
Mobile-friendly — touch-first interaction
-
Debuggable — overlays, ranges, and editor tools built-in
-
Exportable — board state can be saved as an image or serialized
Code
│ index.html
│ README.md
│
├───full
│ battle.css
│ battle.js
│ battle_chrome.js
│ battle_original.png
│ computer.js
│ index.html
│ maps.js
│ sets.js
│
├───mini
│ battle.js
│ battle_chrome.js
│ index.html
│
└───mobile
battle.js
battle_chrome.js
index.html
Battle Game is built around clarity, determinism, and expressive mechanics. The engine avoids hidden state, unpredictable behavior, and tangled logic. Every subsystem — rendering, input, unit logic, editor tools — is designed to be:
-
predictable
-
auditable
-
easy to refactor
-
easy to extend
This makes it ideal for long-running simulations, AI experiments, and mobile deployment.