RCWeb Tankwar App

The RCWeb Tankwar App (app/tankwar) is a fast-paced Canvas-based multiplayer arena shooter built upon the Asymmetric Pattern. It features complex 2D geometric physics, procedural wall generation, and a sophisticated AI flocking/combat engine.

Icon

icon

Screenshot

screenshot

What it does

  • Procedural Arenas: Automatically generates randomized wall structures (rebuildWalls()) every time the game resets, forcing players to navigate tight corridors and utilize physical cover to survive.
  • Strict Geometric Physics: Tanks and bullets cannot pass through walls. The engine rigorously resolves velocity vectors against boxes and circles to prevent glitching through corners.
  • Advanced AI Agents: If human players leave the game, sophisticated "Demo" tanks take over. These AI tanks don't just wander; they compute intercept vectors, seek cover, dodge incoming bullets, and retreat if heavily pressured.
  • Dynamic Camera/Scaling: The canvas strictly recalculates its render bounds to perfectly match devicePixelRatio, ensuring high-fidelity rendering whether viewed on a 1080p laptop or a 4K television.

How it works

The core script.js relies extensively on multi-pass loop evaluations to manage complex collision bounding and artificial intelligence decision trees.

  • Rigid Collision Resolution: To process movement, the engine calculates a tentative nextX and nextY. The resolveWallMovement physics pipeline strictly checks circleHitsAnyWall on individual axes first. If a tank hits a wall smoothly, it effectively sliding along the perpendicular axis rather than completely dead-stopping, making steering feel fluid in tight spaces.
  • Multi-tiered AI Scoring: The chooseDemoSteering brain tests 12 separate movement angle candidates per tick. For each angle, it recursively calculates scoreDemoCandidate, factoring in deep strategic variables such as computeCoverScore, computeEnemyPressure, and computeBulletDangerAt to mathematically output the most optimal survival maneuver.
  • Intercept Calculation: AI agents don't shoot where players currently are, they shoot where players are going to be. predictDemoIntercept loops an iterative velocity matrix calculation based on the bullet's travel speed (cfg.bulletSpeed) versus the enemy's current heading to lead targets precisely.
  • State Interpolation: Uses delta time (dt) mapped explicitly against a lastFrameTime timestamp in requestAnimationFrame ensuring all logical object speeds (moveSpeed = 320 pixels per second) resolve perfectly on any Hz refresh rate monitor.
DocumentationServer TelemetryServer StatsServer HTTP LogServer WebSocket Log