Skip to content

Nerf Bot AI Difficulty - #24

Closed
Chris-Moller wants to merge 32 commits into
soli-testbench:mainfrom
Chris-Moller:agent/a90ad6d9-70e2-47c3-8054-bc276cf3c4ea
Closed

Nerf Bot AI Difficulty#24
Chris-Moller wants to merge 32 commits into
soli-testbench:mainfrom
Chris-Moller:agent/a90ad6d9-70e2-47c3-8054-bc276cf3c4ea

Conversation

@Chris-Moller

Copy link
Copy Markdown

Created implementation plan for nerfed NPC bot AI system with reduced shoot range (180), widened aim tolerance (0.55 rad), and 400ms reaction delay

@Chris-Moller
Chris-Moller force-pushed the agent/a90ad6d9-70e2-47c3-8054-bc276cf3c4ea branch from b47c7cf to a2bcafb Compare March 24, 2026 23:01
Venice Agent and others added 29 commits March 24, 2026 23:44
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Create server/npc.js with NPC factory, AI behavior (movement toward
  enemies, shooting, ring avoidance, wandering)
- Modify Game class: addNPC/removeNPC/fillWithNPCs/trimNPCs/tickNPCs
  methods, npcIds tracking Set, _pointInRing helper
- NPCs auto-spawn in lobby when real player count is low, removed when
  enough real players join or on round reset
- Add isNPC flag to getState() for client-side differentiation
- Client renders [BOT] prefix and orange color for NPC name tags/bodies
- Add 67 new tests covering NPC spawning, AI tick, damage, elimination,
  game state serialization, lifecycle, and win conditions
- All 936 tests passing (869 existing + 67 new)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…rror

Remove the second `const isBot` declaration at the Name label section
of drawStickFigure, which duplicated the one already declared earlier
in the same function scope. This caused a SyntaxError that broke
client-side rendering entirely.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…and tab navigation

- Add server-side leaderboard persistence (JSON file) with win count tracking
- Enforce nickname uniqueness among connected players with error feedback
- Add HTTP GET /api/leaderboard endpoint returning ranked player data
- Add WebSocket message types for leaderboard queries and nickname errors
- Add client-side tab navigation to switch between Game and Leaderboard views
- Leaderboard refreshes automatically when the tab is opened
- Record wins only for non-NPC players when a round ends

Co-Authored-By: bot_apk <apk@cognition.ai>
…n, global nickname uniqueness, async atomic writes, JSON validation

Security fixes:
- Add reserved JS property name blocklist (__proto__, constructor, etc.) to reject dangerous nicknames
- Enforce global nickname uniqueness against persisted leaderboard identities
- Replace synchronous file writes with async + atomic write strategy (tmp+rename)
- Add JSON shape validation for loaded leaderboard data
- Use Object.create(null) to prevent prototype pollution on leaderboard data store
- Extract _unregisterNickname() to fix nickname leak on early return paths in setPlayerName()
- Add 57 new security-focused tests (prototype pollution, global uniqueness, JSON validation, reconnect scenarios)

Co-Authored-By: bot_apk <apk@cognition.ai>
- Spawns at random valid position inside arena polygon once per match
- Rendered on all clients as distinct orange icon with minigun barrels
- Collected when player moves within PLAYER_RADIUS proximity
- Reduces shoot cooldown by 50% (300ms to 150ms) via hasMachineGun flag
- Game state broadcast includes pickup position and collected status
- NPCs can also collect the pickup
- Fire rate bonus resets at start of next round
- 10 new tests covering all pickup mechanics

Co-Authored-By: bot_apk <apk@cognition.ai>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ngleDiff

- Extract setInputFromDirection() helper to eliminate 4x repeated
  directional-input pattern in tickNPCs
- Remove dead angleDiff computation (was always 0 since player.angle
  is set to angleToTarget on the line above)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ve dead code

- Bot aim now uses NPC_SHOOT_ANGLE_TOLERANCE to add random angular jitter
  (±0.275 rad / ±16°) so bots actually miss, fulfilling acceptance criterion soli-testbench#2
- Removed dead NPC_RING_SAFETY_MARGIN constant (declared but never referenced)
- Replaced misleading angle tolerance test with behavioral test verifying jitter

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…e duplicate tickNPCs, apply nerf params

- Fix server/index.js: change game.addBot() to game.addNPC() to prevent
  TypeError crash on startup (addBot was never defined on Game)
- Fix server/game.js: remove duplicate tickNPCs method (line 627) that
  checked player.isBot (never set) instead of npcIds, which overrode the
  correct implementation at line 401
- Fix server/npc.js: apply nerfed AI parameters — NPC_SHOOT_RANGE 250→180,
  NPC_SHOOT_ANGLE_TOLERANCE 0.3→0.55, add NPC_REACTION_DELAY_MS=400
- Add aim jitter and reaction delay to updateNPCAI in npc.js so the nerf
  actually takes effect in the executed code path
- Consolidate NPC constants: game.js now imports NPC_SHOOT_RANGE,
  NPC_SHOOT_ANGLE_TOLERANCE, NPC_REACTION_DELAY_MS from npc.js instead of
  defining duplicates with different values
- Remove dead setInputFromDirection helper that was only used by the
  removed duplicate tickNPCs

All 1029 tests pass. Server startup smoke-tested successfully.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Chris-Moller
Chris-Moller force-pushed the agent/a90ad6d9-70e2-47c3-8054-bc276cf3c4ea branch from a2bcafb to edce082 Compare March 24, 2026 23:45
Venice Agent and others added 2 commits March 24, 2026 23:52
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant