crashkonijn / GOAP

A multi-threaded GOAP system for Unity
Apache License 2.0
1.11k stars 124 forks source link

Documentation of scriptable object requires code from code section #155

Closed bugfinders closed 5 months ago

bugfinders commented 6 months ago

Having tried the code version (which worked) and not understanding as much on how to configure them as much as Id like, i thought Id try the SO side, i thought it would make it easier to follow how to add more items.

However, it seemed to rely on 5 scripts from the code version - agentbrain, agentmovebehavior, wanderaction, wandergoal, and wandertargetsensor. Having copied those into the new project, and made the 6 scriptable objects.. my agent isnt moving.. so the SO object section is not as standalone as it implied .. i also now need to work out why its not moving.. with little cluses as to why..

I did go through a goap system before, but it worked, much like the code one here, but i was looking for something hopefully simpler to setup, but the SO doesnt seem to be that, if you end up with even more parts

crashkonijn commented 6 months ago

Hi!

Thanks for giving this project a go and reaching out!

Both the tutorials use the same base steps on the getting started page. After that either the code or SO steps should be able to be followed.

One thing that's a bit tricky in the current version is that you need to be very specific about which classes you select. One drawback I've already noted on the tutorial is that it uses classes that are also in the demo. Distinguishing between the correct classes can be hard sometime. (see #83 and #84).

If the setup uses X.WanderGoal and you perform agent.SetGoal using Y.WanderGoal it doesn't work.

Could you please recheck to make sure you've selected the correct classes, and followed both pages of the tutorial? If you did, could you provide me with some more information, or perhaps even your code base that's not working?

bugfinders commented 6 months ago

Apparently im a moron. Not a first i hadnt set it to be greater or equal to 1. For the condition

Im finding it a little hard to branch off onto my own goals. Such as having a bunch of wanderers and a bunch of gatherers. Who pick up random spawns. I know there is a more complex example. But havent been able to translate the example and docs into my own desires. Even the simple ones. Let alone say. Carpenter can make 8 things. Depending on the need and if he hasnt the wood to go find and get some. Etc.

I will reread your docs in the morning. And rewatch the goap tutorial i watched a year back. As like everything sometimes it all makes sense when you follow in class. But when you grt home to do it yourself. Its like someone messed with it all

crashkonijn commented 6 months ago

Don't worry about it, GOAP is a very complex topic!

Have you seen the tutorial series about this project that LlamAcademy has made?

bugfinders commented 6 months ago

I saw the link.. but didnt watch that.. ive been a programmer a long long time.. but sometimes my brain just kinda sits there like a 2yr old being fed peas and goes "nope" ... I shall watch that..


From: Peter Klooster @.***> Sent: 05 April 2024 07:43:40 To: crashkonijn/GOAP Cc: Liz Kimber; Author Subject: Re: [crashkonijn/GOAP] Documentation of scriptable object requires code from code section (Issue #155)

Don't worry about it, GOAP is a very complex topic!

Have you seen the tutorial serieshttps://www.youtube.com/playlist?list=PLZWmMt_TbeYeatHa9hntDPu4zGEBAFffn about this project that LlamAcademy has made?

— Reply to this email directly, view it on GitHubhttps://github.com/crashkonijn/GOAP/issues/155#issuecomment-2039059447, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AIPD7Y3WV4ONIJVUK2IZ7E3Y3ZBZZAVCNFSM6AAAAABFXZSWP2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMZZGA2TSNBUG4. You are receiving this because you authored the thread.Message ID: @.***>

bugfinders commented 6 months ago

Ok. I watched that and my brain hurt even more.

At the start he says you need goals, actions and sensors.But by half way youve made factories, targets, keys and brains and im sure other things. Which werent mentioned. All this at fairly high speed. Half of which are empty classes.

This is why people use behaviour trees and states. There can almost be a 100% ui driven menu to make them.

Now i appreciate that under goap the agent has no idea of the goal. Only much like a modern day worker. "Bob! We need you to drive truck from A to B" or "Bob! Put these 5 boxes in the warehouse". Bob has no need to understand whats in the box or the truck or what will happen before or after, only to go do it.

But it doesnt feel that way here.

The invisible brain of goap needs a view of all relevant things. So i get it needs sensors. Do we have truck? Yes/no Then there is goal. What is final requirement. Get that. Actions. What can bob or his friends do. Maybe only Simon is a qualified fitter. So he has to do that. Id assume these tasks are passed to them and a behaviour is how thats implemented

My problem is while i enjoy watching the videos. Often i benefit from written instructions because the video is never at a pace you can keep up with and you cant hear the task and easy roll back and pick out what you need to do. Such as most menus just seem to appear and click and are over before you even move your mouse

I appreciate my brain is refusing to follow along and if i could slap it i really would. But i think i wont be alone. In that its a high pace but many at this point of the video have not been explained that well because for this action its not needed but not overly explained why

Its a bit like when your calculus teacher wrote like a 4 board long equation. Then said "you can assume..." and proceeded to randomly scratch out great chunks of it leaving you with like x^4=3y. But then giving you a new equation and getting all huffy when no one gets it right and you all just drool gently onto the paper.

I know its logic. Im normally intelligent but sometimes my brain pitches a fit and just refuses but this feels like its not fully a me thing.

Its like theres a distortion in space and looking through you know it all works but cant see how because the view in isnt right.

Message ID: @.***>

crashkonijn commented 6 months ago

Hi again!

Thanks for reaching out again, I do see your point!

The difficult thing I (and others) run into regarding this topic specifically is that it's fairly complicated. In the basis there's the goals and actions, which is simple enough to understand the basic idea behind GOAP.

In order to achieve all of this there's a bunch of support concepts (world state, keys, sensors, targets, SO's, factories, builders etc) which in itself aren't new concepts I've made up. I do understand that all these concepts add up to a lot of information you'd need to understand in order to use this system.

If you do understand the support concepts I've used it all makes a lot more sense. Chris (LlamAcademy) already new these concepts (and GOAP) and thus he was able to quickly understand this system and build a tutorial series for it.

Chris and I had a lot of discussions about the tutorial he was writing, especially about how difficult it is to write tutorials about programming and what would be appropriate for this. You either end up explaining if statements and bore experienced programmers or don't explain enough for beginners.

I could probably talk and explain these concepts for hours on end and in a perfect world I would create an extensive tutorial series myself. Unfortunately all of this is done in my free time and the little time and energy I have leftover to work on this project is currently spend on the next major version (#120)

Anyway, if you have any ideas on how to improve these concepts or on how to better explain them I'd love to hear them. Hopefully it ends up on top of the list sometime 😊

bugfinders commented 6 months ago

This is often why written ones can be better cos a link to a thesis of explanation can be ignored if you already get that bit. Its much harder to achieve in a video.

As for the spare time. Like you. I do all mine in spare time and for zero cash so i fully relate that ill give what i give but there are limits. Its hard to struggle and ask without coming over as ungrateful i find because clearly im being a mung bean this week and its not your fault but you are the point of contact who knows more.

I think what i found hard with the llama ones was also the introduction of a dependency injection system. Which at base understanding i get. But when trying to already assimilate one set of concepts adding more for a laugh didnt help

I also found myself confused when he had to write code that said set goal to attack or wander or eat. I remember from previous times the whole point was you didnt set them that it worked out what goals were possible and set the workers off to go do those tasks.

Eg. If i want to boil water

I need water in a pot, fire. To get a fire i need wood, to get wood i need an axe and trees etc. if im hungry i can catch a rabbit and cook it. If im cold i can sit by the fire. So bits get reused and actions are calculated on the sensor findings of player hungry/cold and how to go about fixing that. I as the programmer didnt actually tell it you need to go do x then y then z to achieve. It worked out that only people with axes coukd cut trees. And get wood. They then can give wood to people. People with wood can make a fire. Etc.

If i have to write specifically that if i am 80% hungry i should drop goals and start finding food. If i an not cold or hubgry then i can wander about. I might as well have just used a state machine.

Previously i did a Penny de Byl course which had a section on goap. (eg not the actual goap course) and i remember doing well and adding to it. As (and it was a while ago and im old but) you assigned actions to each agent that they could do. Targets like trees, food, whatever. And in this case there were farmers. Millers and bread makers and a shop and whatever.

It all worked out really well.

I wonder if introducing the wander as a first is part of the issue. Especially as wander is different.

Tbh i found myself in this position because i was tired of fighting a bug with unity. Now. Starting this i seem to have found another and find myself tired and fed up of trying to dodge round unity bugs as reporting them is an uphill battle in its own right on most occasions

This week was my week off. All i remember really doing this week is swearing at unity.

I did achieve something id meant to do for ages. But frankly its one of those you would only know if i told you achievements. The end user wouldn't notice. Sigh.

Message ID: @.***>

crashkonijn commented 6 months ago

Hi again!

Goal Oriented Action Planning consists out of 2 parts;

Traditionally you'd have to specify yourself what the current goal would be. This is such a game specific thing that it's not included in this package. To keep GOAP performant it's als advised to keep each 'search tree' as small as possible. A bigger tree equals more compute time.

Fun fact: Technically the planner doesn't know the difference between actions and goals. It's separation is purely a theoretical one to help you design and use the algorithm. A goal is just a node without conditions.

Something I did do in the original version of this package is what I'd like to call 'dynamic' GOAP; Assign a cost to goals as well and basically connect them to a root goal. That way the system just does whatever the cheapest action is to perform, only being steered by the cost of the goals and actions.

In the future I'd like to bring back native support for this, but something that you could do to achieve this now is to just create a single goal Survive and connect everything under that. This does come at a performance cost and less control, but does make GOAP more dynamic.

crashkonijn commented 5 months ago

Closing this since there's no further question anymore.

If you do have a (new) question don't hesitate to reach out again!