Skip to content

Commit

Permalink
Automatic upgradeSite link placement; ready for 0.3.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
bencbartlett committed May 9, 2018
1 parent 8688d1c commit 4658b7c
Show file tree
Hide file tree
Showing 30 changed files with 336 additions and 327 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ screeps.json
/.rpt2_cache
/tsc-out

# Ignore Overmind.ts
/src/Overmind.ts

# yarn lock file
/yarn.lock

Expand Down
21 changes: 17 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]

## Overmind [0.3.0] - 2018.5.9
### Added
- Lots of new content added to the [Wiki](https://github.com/bencbartlett/Overmind/wiki)!
- TerminalNetwork stat collection, which accumulates all `send()` calls and transfer costs by resourceType between origin and destination
Expand All @@ -16,14 +17,21 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Road routing hints (white/white flags) no longer have any effect. (The new routing algorithm uses a variant of this idea to merge roads more intelligently.)
- UpgradeSites now automatically calculate input location and no longer need to be placed in room planner
- MiningSites at outposts now automatically build container outputs without you needing to reboot room planner
- MiningSites in rooms now automatically upgrade their container to a link if necessary
- Automatic link placement
- MiningSites will replace their containers with links if above 10 path length from storage (prioritizing farthest)
- UpgradeSites will add a link if above 10 path length from storage if miningSites already have links
- UpgradeSites now have `link` and `battery` properties which request energy independently
- Added some version migration code in `sandbox.ts` which will reboot the room planner for each colony one at a time to account for the new changes
- Hauling directives and overlords for hauling large amounts of resources long distances (e.g. scavenging from abandoned storage)
- Finished coding LogisticsRequestDirectives: these flags act as requestor or provider targets and have a `store` property
- `provider == false`: requests energy to be dropped at a positiion
- `provider == true`: resources dropped at position or in a tombstone to be collected
- These directives are functional, but their automatic placement has been disabled until a future patch while I continue to improve the logistics system performance
- Preliminary contract module for making deals between players
- `Energetics` module, which will make high-level decisions based on energy distributions
- Colonies now have a `lowPowerMode` operational state, which scales back production of miners and transporters at RCL8 with full storage/terminal
- New version updater system alerts you when a new release of Overmind is available
- Currently only available on shard2; shard1 and shard0 support coming soon

### Changed
- Transporters now use a single-sided greedy selection at RCL<4, since stable matching only works well when the transporter carry is a significant fraction of the logisticsRequest target's capacity
Expand All @@ -32,11 +40,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- `TaskRepair` will now attempt to move to within range 2 if repairing a road; this should fix the move-stop-repair-move-stop-repair behavior of workers repairing remote roads
- TerminalNetwork now sends excess energy to room with least energy rather than non-full room with least send cost overhead
- More upgraders spawn when room is at very high energy capacity
- Changed how `colony.dropoffLinks` is computed
- Disabled stack tracing for all logging except errors; removed some annoying alerts ("transporter chooses request with 0 amount!")

### Removed
- Deprecated `TaskDeposit`; use `TaskTransfer` instead
- `TaskWithdrawResource` has replaced `TaskWithdraw`
- Removed the source for `Overmind.ts` and replaced it with an obfuscated, pre-compiled `Overmind_obfuscated.js`
- This is in preparation for implementing behavioral locks which will make Overmind more fair to new players
- See the header in `Overmind_obfuscated.js` for more details

### Fixed
- Bugfixes with `TaskDrop`, `TaskGoTo`, `TaskGoToRoom`
Expand Down Expand Up @@ -85,7 +97,8 @@ This release was initially deployed on 2018.3.2 but was re-versioned on 2018.3.1
### Added
- Initial pre-release of Overmind after 190 commits and about 80,000 additions.

[Unreleased]: https://github.com/bencbartlett/Overmind/compare/v0.2.1...HEAD
[Unreleased]: https://github.com/bencbartlett/Overmind/compare/v0.3.0...HEAD
[0.3.0]: https://github.com/bencbartlett/Overmind/compare/v0.2.1...v0.3.0
[0.2.1]: https://github.com/bencbartlett/Overmind/compare/v0.2.0...v0.2.1
[0.2.0]: https://github.com/bencbartlett/Overmind/compare/v0.1.0...v0.2.0
[0.1.0]: https://github.com/bencbartlett/Overmind/releases/tag/v0.1.0
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Overmind",
"version": "0.2.0",
"version": "0.3.0",
"description": "Overmind Screeps AI (pre-release)",
"author": "Ben Bartlett",
"repository": {
Expand All @@ -13,6 +13,7 @@
},
"scripts": {
"lint": "tslint \"src/**/*.ts\"",
"build-obfuscated-overmind": "tsc && javascript-obfuscator tsc-out/Overmind.js --output src/Overmind_obfuscated.js --compact false --self-defending true --string-array true --string-array-threshold 1 --string-array-encoding true",
"push-main": "rollup -c --dest main",
"push-pserver": "rollup -c --dest pserver",
"push-sim": "rollup -c --dest sim",
Expand Down
10 changes: 9 additions & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,20 @@ export default {
format: "cjs",
sourcemap: true
},

onwarn: function (warning) {
// Skip default export warnings from using obfuscated overmind file in main
if (warning.toString().includes('commonjs-proxy')) {
return;
}
// console.warn everything else
console.warn(warning.message);
},
plugins: [
clean(),
resolve(),
commonjs({
namedExports: {
'src/Overmind_obfuscated': ['_Overmind'],
'screeps-profiler': ['profiler']
}
}),
Expand Down
19 changes: 14 additions & 5 deletions src/Colony.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,19 @@ export class Colony {
// Instantiate spore crawlers to wrap towers
this.sporeCrawlers = _.map(this.towers, tower => new SporeCrawler(this, tower));
// Sort claimed and unclaimed links
let claimedLinkCandidates = _.compact([this.commandCenter ? this.commandCenter.link : null,
this.hatchery ? this.hatchery.link : null,
this.upgradeSite.input]);
this.claimedLinks = _.filter(claimedLinkCandidates, s => s instanceof StructureLink) as StructureLink[];
let claimedPositions = _.map(_.compact([this.commandCenter, this.hatchery, this.upgradeSite]),
hiveCluster => hiveCluster!.pos);
this.claimedLinks = _.filter(this.links, function (link) {
let nearbyClaimingThings = link.pos.findInRange(claimedPositions, 3);
if (nearbyClaimingThings) {
return nearbyClaimingThings.length > 0;
}
let nearbySources = link.pos.findInRange(FIND_SOURCES, 2);
if (nearbySources) {
return nearbySources.length > 0;
}
return false;
}) as StructureLink[];
this.dropoffLinks = _.filter(this.links, link => this.claimedLinks.includes(link) == false);
// Mining sites is an object of ID's and MiningSites
let sourceIDs = _.map(this.sources, source => source.ref);
Expand Down Expand Up @@ -235,7 +244,7 @@ export class Colony {
}

run(): void {
// 1: Run the colony overlord, must be run BEFORE all components are run
// 1: Run the colony overseer, must be run BEFORE all components are run
this.overseer.run();
// 2: Run the colony virtual components
_.forEach(this.hiveClusters, hiveCluster => hiveCluster.run());
Expand Down
178 changes: 0 additions & 178 deletions src/Overmind.ts

This file was deleted.

Loading

0 comments on commit 4658b7c

Please sign in to comment.