Giter Club home page Giter Club logo

screeps's Introduction

TooAngel NPC / bot / source code for screeps

CircleCI npm version Maintainability discord

This project is a code base for screeps a strategy sandbox MMO game. The codebase is a fully automated player and covers all important features provided by the game.

Nowadays there are a couple of other automated screeps bot around. The TooAngel bot layed the groundwork for bots on the private server and the full automation idea. It was the first full automated open source code base and invented the idea of an community driven merge processes as well as a full automated bot deploy process.

Pull Requests are automatically merged (World Driven) and deployed to the Screeps TooAngel account.

Use cases

There are different occasions where you get into contact with the TooAngel NPC / bot / source code.

Note

This is not a good example for code quality or structure, most LOCs written while fighting or other occasions which needed quick fixes or in the ingame editor (getting better :-)). But I think there are a couple of funny ideas. Every contribution is welcome.

Features

Design

More details of the AI design

Links

screeps's People

Contributors

aceofaces avatar brutalbic avatar connorzg avatar darkdestry avatar dependabot[bot] avatar domkeykong avatar evanito avatar gewure avatar jetbalsa avatar kahojyun avatar karlthepagan avatar kill4free avatar labrown avatar lexxicon avatar morwoen avatar mschultheiss83 avatar nevrdid avatar octaflop avatar odoucet avatar pieterbrandsen avatar riftlurker avatar samogot avatar somotaw avatar sparr avatar stu43005 avatar tooangel avatar totalschaden avatar tsstudio avatar tsungen avatar xenoamess avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

screeps's Issues

E11S8 - first source setup blocks second source

TypeError: Cannot read property 'findNearPosition' of undefined
    at Room.updatePosition (config_room_routing:95:23)
    at wrappedFunction [as updatePosition] (screeps-profiler:85:39)
    at Room.getPath (config_room_routing:246:10)
    at wrappedFunction [as getPath] (screeps-profiler:85:39)
    at Creep.moveByPathMy (config_creep_routing:265:24)
    at wrappedFunction [as moveByPathMy] (screeps-profiler:85:39)
    at Creep.followPath (config_creep_routing:259:15)
    at wrappedFunction [as followPath] (screeps-profiler:85:39)
    at Creep.handle (config_creep:52:16)
    at wrappedFunction [as handle] (screeps-profiler:85:39)```

Improve code structure

Many for loops can be replace by lodash filter.

Checks for structures can be replaced by tables:

     let hostileStructures = creep.room.find(FIND_HOSTILE_STRUCTURES, {
        filter: function(object) {
          let table = {
            [STRUCTURE_RAMPART]: true,
            [STRUCTURE_EXTRACTOR]: true,
            [STRUCTURE_WALL]: true,
            [STRUCTURE_CONTROLLER]: true
          };
          return !table[object.structureType];
        }
      });

Creeps idle around with multiple dropped energy

Creep need to prioritize large dropped energy instead of closest non-zero. Otherwise if one carry is dead and sourcer is dropping 2k+ energy, the harvester(s) will idle around due to other sourcer dropping closer energy around <5 instead of going to the most energy.

Unnecessary dependencies

You have these mandatory dependencies in your package.json:

{
    "grunt": "~0.4.5",
    "grunt-screeps": "1.2.0",
    "grunt-sync": "^0.6.2",
    "screeps-profiler": "^1.1.1"
  }

They are installed on every server when users install your bot via the Workshop or npm. I guess it is better to move them to devDependencies instead.

Error: Unknown module 'creep_upgrader'

When starting a new room, nothing happens unless I comment out the prepareMemory function.
Here is the full error:

Error: Unknown module 'creep_upgrader'
at Object.brain.prepareMemory (config_brain_memory:66:20)
at main (main:18:9)
at Object.module.exports.loop (main:44:5)
at __mainLoop:1:52

Im only GCL 1, i get the feeling that lack of CPU power has something to do with this.

Contribution & git workflow

My edited suggestion :)

Contribution

All kind of contribution is welcome, issues, contact via channels, pull requests.

Priority

  • Make contribution as easy as possible
  • Easy to understand contribution ideas
  • History looking good, would be nice

Flow

  • Start by forking TooAngel/screeps
  • Make your own branch off the latest master
  • Start a pull request with the prefix [WIP] if you want ongoing reviews during development
  • Work on your feature until you think its ready push your commits if you want ongoing reviews
  • Rebase your whole feature interactively, using squash or fixup on all merge commits you have made and anything else you would like to edit
  • Rebase your feature off latest master
  • Test your feature or have someone test it for you, push your commits if you want reviews
  • If master has been updated start again from the first Rebase step
  • Run npm install in your repository if you havent already done so, then grunt dev
  • Push commits
  • Remove [WIP] prefix from your pull request
  • Await reviews
  • If there are issues, prefix the pull request again and start again from first rebase step
  • Await merge to master and pray everything works \o/
  • Remove the feature branch

Details

There is only one eternal branch - master

  • All other branches (feature, hotfix, and whatever else you need) are temporary and only used as a convenience to share code with other developers and as a backup measure. They are always removed once the changes present on them land on master.

Features are integrated onto the master branch without having any merge commits in them

  • This ensures linear history.

Pull Request

  • Small PRs are more welcome than big ones and will be merged faster, especially because of the review time.
  • One PR should preferrably only tackle one feature.

Commits

  • One commit should fully tackle one topic, not more not less.

Work in progress

  • You are fine to do on your branch what ever you want. Especially rebasing or squashing before removing the WIP label is expected.
  • --fixup commits are preferred if you need to commit something that handles the same topic as another one of your commits in your feature or hotfix. These are wither done with the --fixup option for git cli or you can start your commit message with fixup! so they can be combined automatically with the previous or targeted commit on merge or rebase.

What to do

Have a peak at: Issues
These topics are open for discussion, jump in, and also for implementation. The description will reflect the latest status of the
discussion and should end up in the documentation, when finishing the
implementation.

Add ramparts on key structures

Spawns and especially towers need ramparts on them in order to be effective. Towers are most effective at close range.

Memory.players not declared

hi. tried your script and got an error about Memory.players when scout visited his first room. Just had to add players to memory and set it as object but it could be better if you initialise it somewhere :)

Defenders to weak

Recently getting 24/7 attacked in my remote mining rooms by those http://i.imgur.com/jE7bdsz.jpg
Defenders cant do anything against it, they also repair each other, we need some bigger calibers for that, probably in a defense squad also with heal each other support

Issues with sourcer logic

Not sure what's going on, but the sourcer roles do not appear to be working as expected. At one point, one of them was working as expected, then neither worked. When they are not working (just sitting one square away from the source) they will constanly say 'R:-1 pre'. (Source is hidden under the text bubble - the sourcer has never touched this source point in thousands of ticks).

image

Getting more done in GitHub with ZenHub

Hola! @Somotaw has created a ZenHub account for the TooAngel organization. ZenHub is the only project management tool integrated natively in GitHub – created specifically for fast-moving, software-driven teams.


How do I use ZenHub?

To get set up with ZenHub, all you have to do is download the browser extension and log in with your GitHub account. Once you do, you’ll get access to ZenHub’s complete feature-set immediately.

What can ZenHub do?

ZenHub adds a series of enhancements directly inside the GitHub UI:

  • Real-time, customizable task boards for GitHub issues;
  • Multi-Repository burndown charts, estimates, and velocity tracking based on GitHub Milestones;
  • Personal to-do lists and task prioritization;
  • Time-saving shortcuts – like a quick repo switcher, a “Move issue” button, and much more.

Add ZenHub to GitHub

Still curious? See more ZenHub features or read user reviews. This issue was written by your friendly ZenHub bot, posted by request from @Somotaw.

ZenHub Board

Terminal missing energy

Manual command to move Energy to a Terminal would be nice.
Automatic move Energy to a Terminal until X is reached (config) would be nice.

My Terminal is at 20692 Energy for a Week now and its not selling stuff because to low Energy.

Creeps stuck on path

creeps_stuck

These road block all creeps if they are some. The 4 creeps on the top always switch pos but the 2 on the bottom-right never move.
W71S66 on official serv for see them.

Mineral handling

Definition:

  • Base mineral: Minerals which can be harvest in rooms
  • Higher mineral: Minerals with can be gathered by reacting other minerals

Example config values:

  • high threshold: 100000

  • low threshold: 1000

  • Minerals are stored in the terminal

  • The base mineral which is available in a room, is stored up to high threshold after that sold in the market

  • Other base minerals can be ordered from other rooms or bought from the market

  • Each mineral should react higher minerals by themself and store up to low threshold

Mineral creep:

  • Takes care that enough energy is in the terminal (high threshold)
  • Takes care that minerals are in the labs for reaction
  • Takes care that minerals are in the labs for boosting

To be boosted creeps:

  • Order minerals for boosting, so that they are available when the creep is spawned

Build ramparts around spawn only in walls

Currently the ramparts are build always around the spawn, check if it is in Memory.walls

Maybe while setting walls, check the distance to the rampart (on misplacedSpawn?)

Autoattack

Two auto attacking logics:

Simple defense test:
If a new player shows up, multiple waves of multiple level are send to that player to make sure their defense level fits is advanced enough for the area (https://github.com/TooAngel/screeps/blob/master/FAQ.md#why-am-i-being-attacked-without-being-on-the-list)

  1. A simple ATTACK, MOVE (multiple times, depending on the energy available)
  2. A squad (DISMANTLER, multiple HEALERS) are send (#35)

Kill room:
If the players idiot counter is higher than threshold a room is selected and will be attacked.
A ranged creep will move around the room to prevent external harvesting.
Squads (simple attack level 2) are attacking, best from multiple sides, if possible. Creeps are spawned until the last spawn is killed. After that the vision is kept available by sending a simple (MOVE) creep, destroying new construction Sites. On defending creep appropriate counter attacks should be launched (Defender?)

Squad definition:
squads maybe should change thier name into: intention + targetRoomName, so we can spawn missing creeps later, if needed
create configs for squad intention size, so we can play with different setups
intentions should be grouped roles aka Squads like:
[remote-heal, build-defence or repair-defence, flee] like 'healers and builders' and
[tank, dismantle, self-heal, no-flee] like 'tanks' and
[tank, attack, ranged-attack, flee] like 'attackers'

Autoattack level 2

To be able to kill simple bots with GCL >= 3 and a tower, heal creeps need to be send.
The idea:

  • Send a dismantler
  • Send three heal creeps
  • dismantler waits in the room before targetRoom
  • Heal creeps enter targetRoom, heal themself, and switch on the room border until the tower is drained

Stuck rooms

  • W9N2, spawn 25,20
  • W7N4
  • W8N1
  • W3N8, spawn 37,15 base
  • W7N7, spawn 30, 20
  • W3N7, spawn 27, 13
  • W2N2, spawn 6, 13
  • W2N8, spawn 12, 20

Retaliation factor

Currently only hostile actions are counted into the idiot counter.

Introducing a retaliation factor for actions of the bot could reduce the constant growing of idiots.

E.g. factor of 0.1
If a hostile creeps is in my room idiot +1, if my creep is in hostile room idiot -0.1
Same for destroyed rooms and nukes

All break issue.

hey, come back this evening with only 2 creeps still alive. they are harvesters spaming "tr:incomplet" (proto_creep_ressources l 890) I'll try to understand what happen and say you if i sucefully fix it.
room w72n71

Issue with coming back after wipeout

I was running this script for a while on private server. Reached level where it was possible to expand to other room.
Sadly i'm not able to provide screenshots or logs. Did not thought about it at that time.

When i came back in some time, i saw that in main room there are only two harvesters, which were using just single source. They were traveling between it and filling extensions. And that lasted for days. So there are several issues after wipeout of creepers.

a. Harverstes were gathering only 13 energy from source and then traveling to extensions to fill.
b. Instead building haulers, AI was building scouts.

All of those issues led to the point where AI was not able to rebuild, upgrade controller, maintain roads and etc.

W71S66 getPaths pathStart-harvester missing in cache

hey, here is another "error" i have since i started, spaming the console. dunno if it's an error because all looks working and actually didn't understand what is the path you're talking about ^^

getPaths pathStart-5836baa8090e0ab576fdd205 missing in cache [01:01:32] W71S66 getPaths pathStart-W70S66 missing in cache [01:01:32] W71S66 getPaths pathStart-W71S65 missing in cache [01:01:32] W71S66 getPaths pathStart-W71S67 missing in cache [01:01:32] W71S66 getPaths pathStart-filler missing in cache [01:01:32] W71S66 getPaths pathStart-harvester missing in cache [01:01:53] W71S66 getPath pathStart-harvester missing in cache

Queue Error

Executing room failed: E28S79 TypeError: Cannot read property 'Symbol(Symbol.iterator)' of undefined TypeError: Cannot read property 'Symbol(Symbol.iterator)' of undefined
at Room.inQueue (prototype_room_utils:57:29)
at Room.checkRoleToSpawn (prototype_room_utils:121:12)
at Room.executeRoom (prototype_room_my:279:10)
at Room.myHandleRoom (prototype_room_my:56:15)
at Room.handle (prototype_room:5:17)
at Room.execute (prototype_room:12:27)
at Memory.myRooms..map..filt

Wall setup

Thickness 3:

  • Blocks all sniping attacks for building and creeps near the wall
  • First layer can be attacked by three creeps, the rest only by one

Thickness 1:

  • Not so many stuctures => Less CPU usage on find operations

I think Thickness 3 makes more sense, but some issues needs to be addressed before:

  • The random spawn could be within these layers, make sure it is surrounded by ramparts #11
  • Walls could not be reachable for repairing, make sure all walls are reachable
  • Find (and maybe other) operations are much more expensive due to the number of structures, improve caching

Towers not being filled

I've been running this script for a few days on my private server to study what it does. For the most part it's working fine for me, however the tower that has been built is not getting any resources put in it at all.

Edit: Adding to earlier, studying the memory that's been created, I can see that towerfiller is only called when the room is under attack, but the tower still has no energy after I was attacked, instead it used the energy to create 2 ranged attackers to defend the room

RCL is currently 4, so I'm expecting to see storagefiller once it's reached 5

Will see what I can do to get at least some energy in the tower to prepare for another attack

Fresh start error

Im getting this error after setting my spawn with a clean memory.

[5:17:15 AM]127048 W5N8                        Executing room failed: W5N8 TypeError: Cannot read property 'length' of undefined TypeError: Cannot read property 'length' of undefined
    at Room.myHandleRoom (prototype_room_my:39:65)
    at Room.handle (prototype_room:5:17)
    at Room.execute (prototype_room:13:27)
    at Memory.myRooms._.map._.filter (main:30:56)
    at G:\Steam\steamapps\common\Screeps\server\node_modules\lodash\index.js:1932:13
    at G:\Steam\steamapps\common\Screeps\server\node_modules\lodash\index.js:3073:15
    at baseForOwn (G:\Steam\steamapps\common\Screeps\server\node_modules\lodash\index.js:2046:14)
    at G:\Steam\steamapps\common\Screeps\server\node_modules\lodash\index.js:3043:18
    at baseFilter (G:\Steam\steamapps\common\Screeps\server\node_modules\lodash\index.js:1931:7)
    at Function.filter (G:\Steam\steamapps\common\Screeps\server\node_modules\lodash\index.js:6309:14)

feature/Improve nextroomer source selection

We need to have them select a second source if there are no empty spots on the first one :)
need to make them use containers if present. We might need to increase the work parts to empty sources quicker

CPU conservation

The bot is very greedy when it comes to CPU usage, which is a huge issue for newer players with only 30 CPU. It will simply run itself dry and then spam my emails with "no CPU in bucket" errors. I would recommend the usage of a "defer" module which contains greedy commands that don't necessarily need to be run every tick and are deferred until the user has a decent amount of CPU in the bucket.

In addition, as an ad-hoc solution I added a simple command to the very beginning of main.js that would cancel running on that tick if the bucket is empty. The tickLimit is multiplied by two because that is usually how much CPU it uses for me, but it only needs to be how much the script is expected to run on that tick.

  if (Game.cpu.bucket < Game.cpu.tickLimit * 2) {
  return;
  }

I also noticed you have support for a profiler, but do not include the screeps-profiler.js (https://github.com/gdborton/screeps-profiler/blob/master/screeps-profiler.js) when it has no license and thus defaults to "open." No one will give you trouble for including it in your repository. (You could even potentially use a git submodule)

Even with support for it, I don't see that it even does anything for the user, as the bot doesn't seem to do anything with the data it provides.

The config option serializePath, which would seem to improve CPU performance, is broken with the error:

Executing room failed: W15N69 TypeError: string.split is not a function TypeError: string.split is not a function
    at Function.Room.stringToPath (config_room_utils:63:22)
    at Room.checkPath (config_room_basebuilder:149:19)
    at wrappedFunction [as checkPath] (screeps-profiler:96:29)
    at Room.buildBase (config_room_controller:25:14)
    at wrappedFunction [as buildBase] (screeps-profiler:96:29)
    at Room.executeRoom (config_room_my:210:8)
    at wrappedFunction [as executeRoom] (screeps-profiler:96:29)
    at Room.myHandleRoom (config_room_my:49:15)
    at wrappedFunction [as myHandleRoom] (screeps-profiler:96:29)
    at Room.handle (config_room:16:17)

and so does not help.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.