Skip to content

Conversation

@ShadyMccoy
Copy link

No description provided.

ShadyMccoy and others added 18 commits September 12, 2023 16:58
* basic harvesting and carrying modules
* add basic construction
* abstract class RoomProgram to be extended by specific routines
* some initial abstractions for spawn queues
* rework bootstrap and energy mining for abstract room routine

* roomroutine creepid init moved to super constructor
put any object instead of serialized string into memory

* create construction sites on source mine energy piles
basic construction op
have bootstrappers upgrade in spare time

* prototype room maps (#2)
* Simplify getRoomRoutines
* Optimize initEnergyMiningFromSource
* Remove redundant logging and streamline the loop:

* recheck existence of room objects
* use webpack to deploy to screeps
Critical fixes:
- Fix spawn queue never cleared after spawning (RoomProgram.ts)
- Fix routes never saved to instance (EnergyCarrying.ts)
- Fix wrong memory key 'sourceMines' -> 'energyMines' (EnergyCarrying.ts)
- Fix Construction throwing on completed sites
- Fix GOAP selectAction inverted logic (Agent.ts)

Significant fixes:
- Fix RoomMap created every tick but never stored (main.ts)
- Fix calcSpawnQueue doesn't reset queue (Construction.ts)
- Fix potential null dereferences in Construction.ts
- Fix sourceMine accessed before null check (EnergyMining.ts)
- Add carrier assignment to energy routes

Logic fixes:
- Fix wrong path direction in bootstrap.ts
- Fix _.min used incorrectly for finding closest items
- Fix duplicate interface definitions in custom.d.ts

RoomMap flood fill algorithm fixes:
- Remove unused import
- Fix start tiles remaining at -1
- Fix average calculation excluding wall tiles
- Use proper UNVISITED/BARRIER constants

Code quality:
- Remove debug console.log statements
- Remove dead/commented code
- Convert lodash forEach to native array methods
- Export GOAP classes for reuse

Co-authored-by: Claude <noreply@anthropic.com>
* Add headless testing infrastructure for Screeps simulations

This sets up a complete local testing environment for running
Screeps colony simulations without deploying to live servers:

- Docker Compose stack with screeps-launcher, MongoDB, Redis
- Shell script (sim.sh) for server control (start/stop/deploy/etc)
- ScreepsSimulator class for programmatic HTTP API access
- Scenario-based test framework with example tests
- GameMock for lightweight unit testing without full server
- npm scripts and Makefile for easy CLI access
- Documentation in docs/headless-testing.md

* Fix TypeScript build issues and add mock demo

- Update tsconfig.json to only include src/ for main build
- Fix webpack to exclude test/ and scripts/ directories
- Fix type issues in GameMock.ts and ScreepsSimulator.ts
- Add mock-demo.ts to demonstrate GameMock usage

---------

Co-authored-by: Claude <noreply@anthropic.com>
* Enhance RoomMap with advanced spatial algorithms from santa branch

Port valuable algorithms from the santa branch while preserving
the existing working gameplay and testing infrastructure:

- Add inverted distance transform for better open area detection
- Add peak detection algorithm to identify optimal base locations
- Add peak filtering to ensure appropriate spacing between peaks
- Add BFS territory division for zone-based creep management
- Export Peak and Territory interfaces for external use
- Add helper methods: getPeaks(), getBestBasePeak(), getTerritory()
- Improve visualization with peak labels and territory coloring
- Keep legacy flood fill for backwards compatibility

These algorithms provide sophisticated room analysis for:
- Automated base placement suggestions
- Zone-based resource allocation
- Multi-room expansion planning (future)

* Add comprehensive santa branch review document

Analyze the updated santa branch (commit a1df26b) which includes:
- MarketSystem with ScreepsBucks internal economy
- Concrete routine implementations (Harvest, Transport, Build, Upgrade)
- Restored unit tests with proper Screeps mocks
- Enhanced Colony with ROI tracking and action planning

Recommendations:
- Already ported: Distance transform, peak detection, territory division
- Next candidates: Requirements/outputs pattern, test mock enhancements
- Defer: Full Colony/Node architecture, MarketSystem, A* planning

The selective cherry-picking approach remains the right strategy.

* Port requirements/outputs pattern and enhanced mocks from santa branch

RoomRoutine enhancements:
- Add ResourceContract interface for requirements/outputs
- Add PerformanceRecord for ROI tracking
- Add getRequirements(), getOutputs(), getExpectedValue() API
- Add recordPerformance() and getAverageROI() for tracking
- Enhanced serialization to persist performance history

EnergyMining updates:
- Define requirements: 2 WORK, 1 MOVE, spawn time
- Define outputs: ~10 energy/tick
- Custom calculateExpectedValue() with spawn cost amortization

Test mock enhancements:
- Full RoomPosition mock with getRangeTo, getDirectionTo, etc.
- PathFinder.CostMatrix mock for spatial algorithms
- All common Screeps constants (FIND_*, LOOK_*, TERRAIN_*, etc.)
- setupGlobals() helper for test initialization
- createMockRoom() factory for room-based tests

---------

Co-authored-by: Claude <noreply@anthropic.com>
* Enhance RoomMap with advanced spatial algorithms from santa branch

Port valuable algorithms from the santa branch while preserving
the existing working gameplay and testing infrastructure:

- Add inverted distance transform for better open area detection
- Add peak detection algorithm to identify optimal base locations
- Add peak filtering to ensure appropriate spacing between peaks
- Add BFS territory division for zone-based creep management
- Export Peak and Territory interfaces for external use
- Add helper methods: getPeaks(), getBestBasePeak(), getTerritory()
- Improve visualization with peak labels and territory coloring
- Keep legacy flood fill for backwards compatibility

These algorithms provide sophisticated room analysis for:
- Automated base placement suggestions
- Zone-based resource allocation
- Multi-room expansion planning (future)

* Add independent review of santa branch

Comprehensive analysis comparing origin/master vs origin/santa:

Key findings:
- Santa adds valuable spatial algorithms (inverted distance transform,
  peak detection, BFS territory division)
- Santa removes critical infrastructure:
  - Working gameplay (bootstrap, mining, construction)
  - Testing stack (docker-compose, scenarios, GameMock)
  - ~1,718 lines of testing infrastructure deleted
- Colony/Node implementations are incomplete stubs
- Agent class reduced from 141 lines (GOAP) to 26 lines (simple loop)

Recommendation: Cherry-pick algorithms, reject wholesale merge

* Add comprehensive santa branch review document

Analyze the updated santa branch (commit a1df26b) which includes:
- MarketSystem with ScreepsBucks internal economy
- Concrete routine implementations (Harvest, Transport, Build, Upgrade)
- Restored unit tests with proper Screeps mocks
- Enhanced Colony with ROI tracking and action planning

Recommendations:
- Already ported: Distance transform, peak detection, territory division
- Next candidates: Requirements/outputs pattern, test mock enhancements
- Defer: Full Colony/Node architecture, MarketSystem, A* planning

The selective cherry-picking approach remains the right strategy.

* Port requirements/outputs pattern and enhanced mocks from santa branch

RoomRoutine enhancements:
- Add ResourceContract interface for requirements/outputs
- Add PerformanceRecord for ROI tracking
- Add getRequirements(), getOutputs(), getExpectedValue() API
- Add recordPerformance() and getAverageROI() for tracking
- Enhanced serialization to persist performance history

EnergyMining updates:
- Define requirements: 2 WORK, 1 MOVE, spawn time
- Define outputs: ~10 energy/tick
- Custom calculateExpectedValue() with spawn cost amortization

Test mock enhancements:
- Full RoomPosition mock with getRangeTo, getDirectionTo, etc.
- PathFinder.CostMatrix mock for spatial algorithms
- All common Screeps constants (FIND_*, LOOK_*, TERRAIN_*, etc.)
- setupGlobals() helper for test initialization
- createMockRoom() factory for room-based tests

* Update review with post-merge analysis

The 697Jr branch successfully implemented the cherry-pick strategy:

Ported from santa:
- Inverted distance transform algorithm in RoomMap.ts
- Peak detection and BFS territory division
- Requirements/outputs pattern in RoomProgram.ts
- Enhanced mock infrastructure for testing

Preserved:
- All working gameplay (Bootstrap, EnergyMining, Construction)
- Docker-based testing infrastructure
- ScreepsSimulator and GameMock
- GOAP Agent architecture

Result: +1,075 lines enhancing code, 0 working code deleted

---------

Co-authored-by: Claude <noreply@anthropic.com>
- Implement PeakClusterer with Delaunay-inspired territory adjacency heuristic
- Implement NodeBuilder to create nodes from clustered peaks
- Implement EdgeBuilder with territory adjacency connectivity
- Implement GraphBuilder to assemble complete world graphs
- Add room-agnostic world graph system foundation
- Supports multi-room graphs with cross-room edges
- GraphAnalyzer: Comprehensive graph metrics (connectivity, territories, balance)
- Graph health checks (isolated nodes, articulation points, coverage gaps)
- Per-node metrics (degree, closeness, betweenness, redundancy)
- GraphVisualizer: Multi-mode room visualization for debugging
  - Node visualization with territory-based sizing
  - Edge visualization with distance labels
  - Territory boundaries (Voronoi regions)
  - Debug mode showing internal metrics
  - Color schemes (default, temperature, terrain)
- Tools for empirical refinement and validation
- example.ts: 8 detailed usage examples covering all major operations
  - Building and analyzing graphs
  - Multiple visualization modes
  - Storing graphs for optimization
  - Monitoring graph health over time
  - Comparing configurations for empirical refinement
  - Placeholders for future creep routing

- README.md: Complete guide covering:
  - Architecture and design principles
  - Usage patterns with code examples
  - Empirical refinement cycle for tuning heuristics
  - Metrics reference and interpretation
  - Common issues and fixes
  - Performance considerations
  - Related systems and integration points

Phase 1 foundation complete and ready for testing on actual maps
Core Features:
- Colony interface: Represents a connected component of the world graph
  - Isolated from other colonies (no edges between them)
  - Tracks status (nascent/established/thriving/declining/dormant)
  - Manages resources and operations
  - Controls multiple rooms

- ColonyManager: Create/merge/split colonies
  - buildColonies(): Detect connected components and create colonies
  - mergeColonies(): Combine two colonies into one
  - splitColonyIfNeeded(): Handle disconnection events
  - updateColonyStatus(): Auto-update based on resources

- WorldState: High-level colony management API
  - Global world state singleton (getGlobalWorld)
  - Rebuild all colonies from controlled rooms
  - Track total resources across all colonies
  - Detect and handle colony merging/splitting
  - Persist/load colony metadata to memory

- 8 new usage examples (Examples 9-16):
  - Creating colonies from world graph
  - Managing world state
  - Tracking individual colony status
  - Detecting and merging adjacent colonies
  - Updating resources from game state
  - Persisting world to memory
  - Visualizing colonies
  - Handling colony splits

Enables strategic gameplay at colony level, not just room/node level
- Restructured to explain three-level abstraction:
  - Level 1: Graph (spatial representation)
  - Level 2: Colonies (game state, isolated components)
  - Level 3: World (strategic overview, management)

- Updated architecture section to show full pipeline
- Added usage examples for colony management
- Updated files section with organization by level
- Added explanation of multi-colony scenarios:
  - Multiple isolated bases
  - Expansion detection
  - Merge/split handling
@ShadyMccoy ShadyMccoy closed this Dec 20, 2025
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.

2 participants