bencbartlett / Overmind

AI for Screeps, a multiplayer programming strategy game
MIT License
545 stars 155 forks source link

Overmind completes its own terminal orders #202

Open GrimReaper2654 opened 2 years ago

GrimReaper2654 commented 2 years ago

Issue summary

Overmind is selling energy to itself.

Description of issue:

I created a buy order for energy since my colony had little energy and overmind decided to sell energy to itself.

Screen Shot 2021-09-22 at 2 45 40 pm

The problem is somewhere around here

                let energyThreshold = Energetics.settings.terminal.energy.outThreshold;
                if (terminalNearCapacity) { // if you're close to full, be more agressive with selling energy
                    energyThreshold = Energetics.settings.terminal.energy.equilibrium;
                }
                if (terminal.store[RESOURCE_ENERGY] > 200000) {
                    if (terminalNearCapacity) { // just get rid of stuff at high capacities
                        let response = Overmind.tradeNetwork.sellDirectly(terminal, RESOURCE_ENERGY, 10000, true);
                        if (response == OK)
                            return;
                    }
                    else if (energyOrders.length < 0) {
                        let response = Overmind.tradeNetwork.sell(terminal, RESOURCE_ENERGY, 50000);
                        if (response == OK)
                            return;
                    }
                }

Steps to reproduce:

Create buy order for energy when you have some energy in the terminal.

Suggested fix (optional):

add something that checks if the order is yours.

Other information: