cabaletta / baritone

google maps for block game
GNU Lesser General Public License v3.0
7.21k stars 1.44k forks source link

Multiple goals simultaneously #186

Open ThaUnknown opened 6 years ago

ThaUnknown commented 6 years ago

Possible an option to run multiple goals simultaneously like following a player but mining blocks so depending on which goal it would prioritize, for example if follow player was first it would only mine if it was in range of the player, but if mine was first it would first mine everything it has then go to the player and start mining again

leijurv commented 6 years ago

Can you clarify what you mean by prioritizing goals? How is it different from having a queue of goals which it reaches one after the other?

ThaUnknown commented 6 years ago

That both of the goals are running at once but for the second one occur the first one needs to bw fulfilled, but if the first one becomes incompleted it interrupts the second one, does the first one and goes back to doing the second one affter the first goal is fulfilled

Thunder33345 commented 6 years ago

say you can call go mine diamond, iron, lapis, redstone which bot will prioritise diamond and mine iron others if it's near the path

or you meant it as in, go mine diamond if task completed: mine iron if task NOT completed: halt

ThaUnknown commented 6 years ago

Yes preety much

leijurv commented 6 years ago

@ThatGrzegorzB which one? @Thunder33345 gave two possibilities (1: it considers both goals and could go to either one, but it prefers the higher priority one, 2: it goes to the higher priority goal, and only after it gets there does it consider and path to the lower priority goal). Which one was your "Yes preety much" in response to?

ThaUnknown commented 6 years ago

Number 2, but it only considers the lower priority goal if the higher priority goal is finished, my idea was using this to follow players and for example mine or find blocks navigate to them and mine another block until the block it was supposed to find is gone

leijurv commented 6 years ago

This seems a lot closer to #176, queueing goals, as in one after the other, rather than simultaneous goals (as the title of this issue would seem to suggest).

SeasonalFerret commented 5 years ago

I'd say we should keep #176 separate from #186. Queuing goals to complete in order, and doing things simultaneously seem a bit different.

#mine log 64 & #goto home = baritone should walk home, but occasionally mine logs if it gets the chance.
#mine log 64 ; #goto home = baritone should mine logs, then once it's finished walk home.

Though, priority may be depending on the order. #kill pig & #goto home = Baritone should kill all pigs in sight. If none are found, start walking home until it finds more pigs. #goto home & #kill pigs = Baritone should walk towards home, but if it happens to walk near a pig go ahead and kill it.

You could probably queue it beyond this too, alongside #176: #kill pig & #goto home ; #mine diamond_ore = Baritone should kill pigs that it finds, walking home when there are no targets. Once finally home, start mining diamonds.

Combine with #708 to make a minimum amount of stuff.

#goto home & #kill pig 10 ; #mine diamond_ore 32 ; #goto home = Baritone should walk home, but kill pigs when it can. If the user has 10 porkchops, ignore pigs and just head home. If the user eats and has less than 10 porkchop (which would happen once the previous pigs are out of render distance), just keep going home until the next time it finds pigs. Once home, mine 32 diamonds. Once mined & collected, head back home once more.

This results in a super long trip back home where baritone is restocking on food by itself, and once home will collect 32 diamonds before heading back home again.

Lengthy post but the possibilities are endless if you manage to add this sort of "baritone goal language". #goto portal ; #goal 0 0 ; #invert ; #path & #goto portal ; #goal ; #invert ; #path & #kill pig 32 ; #sethome ; #mine log 32 & mine diamond_ore 32 ; #goto home ; #build house

  1. Go to portal #goto portal
  2. Go towards a random direction for all eternity basically. #goal 0 0 ; #invert ; #path
  3. If it finds a portal along the path (eventually), go through it #path & #goto portal
  4. Go towards a random direction, keep killing pigs #goal ; #invert ; #path & #kill pig 32
  5. Once the user ever has 32 pork chops, consider it home #kill pig 32 ; #sethome
  6. Start mining for logs and diamonds until you have enough #mine log 32 & mine diamond_ore 32
  7. Go home, construct a house (#112)

And there we go. Baritone goes from being a google maps in minecraft to possibly one of the most advanced minebots that may ever be known, simply from using queued commands.

jonnyawsom3 commented 5 years ago

if this ever gets implemented, what about also adding the ability to pause and resume certain tasks? (for example, task 1 is "mine some wood" and task 2 is walk away from a point, you say pause 1 and then it'll start walking, say pause 2 and then pause 1 again (or unpause) and it starts getting wood wherever you currently are)

CesiumCs commented 3 years ago

oh my fucking god

AirAustin commented 2 years ago

So.. The method of stacking commands doesn't work "Too many arguments (expected at most 3)"

ZacSharp commented 2 years ago

@AirAustin what did you expect from trying to use a feature that does not exist? This is a feature request and not a manual.

AirAustin commented 2 years ago

If it was requested 3 fucking years ago, why isn't it implemented yet

SeasonalFerret commented 2 years ago

If it was requested 3 fucking years ago, why isn't it implemented yet

If you want to stack commands, check out AltoClef. Meloweh's fork has @roundtrip which is what you want.

scorbett123 commented 2 years ago

If it was requested 3 fucking years ago, why isn't it implemented yet

You can implement it if you like. All developers of this project volunteer their time, so it's not always possible to have this kind of issue fixed quickly due to lack of that time.

ZacSharp commented 2 years ago

Time is not the issue for simple "run the next command whenever you are idle" scripts.

I spent less time on the code than I spent on a video, which ended up being too large, so here's just the end of it. The part you see here is
sel clear
sel pos1
sel pos2
sel ex n up 2
sel ex n north 1
sel ex n south 1
sel ex n east 1
sel ex n west 1
sel ca
sel clear
sel pos1
sel pos2
sel sh n down 1
sel ex n east 2
sel ex n west 2
sel ex n north 2
sel ex n south 2
sel pos1
sel pos2
sel sh n up 3
sel ex n east 2
sel ex n west 2
sel ex n north 2
sel ex n south 2
sel pos1
sel pos2
sel sh n east 2
sel ex n up 2
sel ex n north 2
sel ex n south 2
sel pos1
sel pos2
sel sh n west 2
sel ex n up 2
sel ex n north 2
sel ex n south 2
sel pos1
sel pos2
sel sh n south 2
sel ex n up 2
sel ex n east 1
sel ex n west 1
sel pos1
sel pos2
sel sh n north 2
sel sh n west 1
sel ex n up 2
sel pos1
sel pos2
sel sh n north 2
sel sh n east 1
sel ex n up 2
sel pos1
sel pos2
sel sh n north 2
sel sh n up 2
sel ex n up 1
sel fill log
sel clear
and the cut away part was sylveons last example but without any concurrency (which also means I had to use `#goto` instead of `#invert` and `#path`) https://user-images.githubusercontent.com/68165024/148705632-c33e0b80-6df7-4a56-93dc-c2d6c962e616.mp4

Though before committing it I'd like to know whether scripts with control flow and variables could become a feature as well, because if not I'd simplify a few things like pushing all commands into one queue instead of keeping the macros on a stack each with it's own current command index. Furthermore I'd really like to get the priority based concurrency, but I'm not sure on how to make it cooperate with the current processes.