Comments (3)
I did it in a simplified way for myself.
I have failed trying to implement getting resources from original origin to local moon, if there are not enough on the moon. The problem is function HandleMinerTransport assumes transport's destination is the same as celestial that is about to be upgraded. Changing that looks like a good way to break some code that I don't fully understand so I gave up with that part.
But other that this is looks quite simple:
Getting new setting (yeah, learning how does your settings work):
AutoMinerSettings autoMinerSettings = new() {
OptimizeForStart = (bool) settings.Brain.AutoMine.OptimizeForStart,
PrioritizeRobotsAndNanites = (bool) settings.Brain.AutoMine.PrioritizeRobotsAndNanites,
MaxDaysOfInvestmentReturn = (float) settings.Brain.AutoMine.MaxDaysOfInvestmentReturn,
DepositHours = (int) settings.Brain.AutoMine.DepositHours,
BuildDepositIfFull = (bool) settings.Brain.AutoMine.BuildDepositIfFull,
DeutToLeaveOnMoons = (int) settings.Brain.AutoMine.DeutToLeaveOnMoons,
RouteThroughMoons = (bool) settings.Brain.AutoMine.RouteThroughMoons
};
AutoMine's modified code in AutoMineCelestial:
if ((bool) settings.Brain.AutoMine.Transports.Active) {
fleets = UpdateFleets();
if (!Helpers.IsThereTransportTowardsCelestial(celestial, fleets)) {
Celestial throughMoon = new() { ID = 0 };
if (autoMinerSettings.RouteThroughMoons && (celestial is Planet)) {
throughMoon = celestials
.Unique()
.Where(c => c.Coordinate.Galaxy == celestial.Coordinate.Galaxy)
.Where(c => c.Coordinate.System == celestial.Coordinate.System)
.Where(c => c.Coordinate.Position == celestial.Coordinate.Position)
.Where(c => c.Coordinate.Type == Celestials.Moon)
.SingleOrDefault() ?? new() { ID = 0 };
}
if (throughMoon.ID != 0) {
fleetId = HandleMinerTransport(throughMoon, celestial, xCostBuildable, buildable, maxBuildings, maxFacilities, maxLunarFacilities, autoMinerSettings);
// TODO: handle transport to the moon, if it has too little resources too
} else {
Celestial origin = celestials
.Unique()
.Where(c => c.Coordinate.Galaxy == (int) settings.Brain.AutoMine.Transports.Origin.Galaxy)
.Where(c => c.Coordinate.System == (int) settings.Brain.AutoMine.Transports.Origin.System)
.Where(c => c.Coordinate.Position == (int) settings.Brain.AutoMine.Transports.Origin.Position)
.Where(c => c.Coordinate.Type == Enum.Parse<Celestials>((string) settings.Brain.AutoMine.Transports.Origin.Type))
.SingleOrDefault() ?? new() { ID = 0 };
fleetId = HandleMinerTransport(origin, celestial, xCostBuildable, buildable, maxBuildings, maxFacilities, maxLunarFacilities, autoMinerSettings);
}
if (fleetId == (int) SendFleetCode.AfterSleepTime) {
stop = true;
return;
}
Lifeform Autoresearch's modified code in LifeformAutoResearchCelestial:
if ((bool) settings.Brain.LifeformAutoResearch.Transports.Active) {
fleets = UpdateFleets();
if (!Helpers.IsThereTransportTowardsCelestial(celestial, fleets)) {
Celestial throughMoon = new() { ID = 0 };
if (settings.Brain.AutoMine.RouteThroughMoons && (celestial is Planet)) {
throughMoon = celestials
.Unique()
.Where(c => c.Coordinate.Galaxy == celestial.Coordinate.Galaxy)
.Where(c => c.Coordinate.System == celestial.Coordinate.System)
.Where(c => c.Coordinate.Position == celestial.Coordinate.Position)
.Where(c => c.Coordinate.Type == Celestials.Moon)
.SingleOrDefault() ?? new() { ID = 0 };
}
if (throughMoon.ID != 0) {
fleetId = HandleMinerTransport(throughMoon, celestial, xCostBuildable);
// TODO: handle transport to the moon, if it has too little resources too
} else {
Celestial origin = celestials
.Unique()
.Where(c => c.Coordinate.Galaxy == (int) settings.Brain.AutoMine.Transports.Origin.Galaxy)
.Where(c => c.Coordinate.System == (int) settings.Brain.AutoMine.Transports.Origin.System)
.Where(c => c.Coordinate.Position == (int) settings.Brain.AutoMine.Transports.Origin.Position)
.Where(c => c.Coordinate.Type == Enum.Parse<Celestials>((string) settings.Brain.AutoMine.Transports.Origin.Type))
.SingleOrDefault() ?? new() { ID = 0 };
fleetId = HandleMinerTransport(origin, celestial, xCostBuildable);
}
if (fleetId == (int) SendFleetCode.AfterSleepTime) {
Similar Lifeformautomine's code in LifeformAutoMineCelestial:
if ((bool) settings.Brain.LifeformAutoMine.Transports.Active) {
fleets = UpdateFleets();
if (!Helpers.IsThereTransportTowardsCelestial(celestial, fleets)) {
Celestial throughMoon = new() { ID = 0 };
if (settings.Brain.AutoMine.RouteThroughMoons && (celestial is Planet)) {
throughMoon = celestials
.Unique()
.Where(c => c.Coordinate.Galaxy == celestial.Coordinate.Galaxy)
.Where(c => c.Coordinate.System == celestial.Coordinate.System)
.Where(c => c.Coordinate.Position == celestial.Coordinate.Position)
.Where(c => c.Coordinate.Type == Celestials.Moon)
.SingleOrDefault() ?? new() { ID = 0 };
}
if (throughMoon.ID != 0) {
fleetId = HandleMinerTransport(throughMoon, celestial, xCostBuildable);
// TODO: handle transport to the moon, if it has too little resources too
} else {
Celestial origin = celestials
.Unique()
.Where(c => c.Coordinate.Galaxy == (int) settings.Brain.AutoMine.Transports.Origin.Galaxy)
.Where(c => c.Coordinate.System == (int) settings.Brain.AutoMine.Transports.Origin.System)
.Where(c => c.Coordinate.Position == (int) settings.Brain.AutoMine.Transports.Origin.Position)
.Where(c => c.Coordinate.Type == Enum.Parse<Celestials>((string) settings.Brain.AutoMine.Transports.Origin.Type))
.SingleOrDefault() ?? new() { ID = 0 };
fleetId = HandleMinerTransport(origin, celestial, xCostBuildable);
}
if (fleetId == (int) SendFleetCode.AfterSleepTime) {
And autorepatriate modified code in AutoRepatriate:
if (celestial.Coordinate.IsSame(destinationCoordinate)) {
Helpers.WriteLog(LogType.Info, LogSender.Brain, $"Skipping {celestial.ToString()}: celestial is the target.");
continue;
}
Coordinate localDestination = destinationCoordinate;
if (((bool) settings.Brain.AutoRepatriate.ThroughTheMoons) && (celestial is Planet)) {
Celestial throughMoon = celestials
.Unique()
.Where(c => c.Coordinate.Galaxy == celestial.Coordinate.Galaxy)
.Where(c => c.Coordinate.System == celestial.Coordinate.System)
.Where(c => c.Coordinate.Position == celestial.Coordinate.Position)
.Where(c => c.Coordinate.Type == Celestials.Moon)
.SingleOrDefault() ?? new() { ID = 0 };
if (throughMoon.ID != 0) {
localDestination = throughMoon.Coordinate;
}
}
var tempCelestial = UpdatePlanet(celestial, UpdateTypes.Fast);
.......................
payload = Helpers.CalcMaxTransportableResources(ships, payload, researches.HyperspaceTechnology, userInfo.Class, probeCargo: serverData.ProbeCargo);
if (payload.TotalResources > 0) {
var fleetId = SendFleet(tempCelestial, ships, localDestination, Missions.Transport, Speeds.HundredPercent, payload);
if (fleetId == (int) SendFleetCode.AfterSleepTime) {
stop = true;
return;
}
It's possible to change autoresearch in a similar way, but I skipped it as original origin is always the same as local moon for me. Yeah. Not an universal assumption. Not everybody has to play like me (have laboratory at each planet, no need to transfer resources far away).
from tbot.
i like very much your interest in the project, but posting here a few hundreds lines of code is little to no use sadly
if you wish to contribute with code, a pull request is the right way to do it
from tbot.
I'm sorry but we are not using github for anything at work (code repositiory that doesn't have even any paid plan to put code on OUR servers instead of sharing it with third party is useless for anything but open source) so I'm not going to learn it just for tbot.
Will just put ideas here without any code if you don't need my code. No problem.
from tbot.
Related Issues (20)
- Automatic Anti-ballistic Missile
- Support Lifeforms
- Attacker tools
- Wrong crystal transport when automine on other planet HOT 1
- [Docker] TBot crashes when running with -d option HOT 1
- problem with lifeform automine HOT 2
- yet another problem with lifeform automine
- Wrong usage for Delay with IntervalType.AFewSeconds?
- "ogamed.exe" not found. Cannot proceed... HOT 1
- Problem with manual captcha solving HOT 3
- captcha HOT 1
- Acces game in browser
- Autofarm calculate wrong the cargos HOT 1
- where to put my captcha if needed HOT 2
- Buildingnames where to find?
- AutoResearch Error
- Failed fleet save (deploy)
- Send only one message to attacker.
- Captcha on Windows server 2012 HOT 3
- Can't protect alliance farm HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tbot.