Skip to content

GOAP module #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 108 commits into
base: main
Choose a base branch
from
Open

GOAP module #1

wants to merge 108 commits into from

Conversation

konbraphat51
Copy link
Collaborator

@konbraphat51 konbraphat51 commented Apr 25, 2025

Summary

Implementation Details

image

  • The GOAP solving starts from GoapSolver.Solve()
  • The developer needs to prepare...
    • GoapAction
      • Condition
      • StateDiff
      • cost
    • State
      • the dictionary of GoapValue
    • goal Condition
      • This is what LLM server generates in TsunagiModule

What is GOAP?

For Japanese: https://www.slideshare.net/slideshow/y-miyake-igdaaiseminar2nd2007210/36655381#53

For English: https://web.archive.org/web/20230713022726/https://alumni.media.mit.edu/~jorkin/goap.html

Developer experience

Registering GoapActions

solver.AddAction(
new GoapAction(
ACTION_2,
new Condition<int>("int", ConditionOperator.Greater, 2),
new StateDiffInterface[] { new StateDiffAddition<float>("float", 1f) },
2.0
)
);

Create GoapState

GoapState state = new GoapState();
state.SetRawValue("int", 0);
state.SetRawValue("float", 0f);
state.SetRawValue("double", 0.0);
state.SetRawValue("boolean", false);

Solve

GoapResult result = solver.Solve(state, goal, 10);

How to PR?

Control

Commenting

Click at Files Changed
image
Drag the area you want to comment and push + button
image

Approving

Push Approve if you agree.

What to comment?

EVERYTHING

  • What this means?
  • Isn't this stupid?
  • Maybe you can do like this
  • WRITE COMMENT!!!
  • This code is difficult to read

Why to comment

  • Not to leave any stupid codes
    • For easier future expansion / fixing
  • For you to understand our code
  • To share responsibility of codes
    • Yeah, you will take the responsibility of these codes if you approve these

Examples

Konbraphat51 reviewing
Konbraphat51 being reviewed

Guides

Japanese

English

@konbraphat51 konbraphat51 self-assigned this Apr 25, 2025
@konbraphat51 konbraphat51 requested a review from Copilot April 25, 2025 07:06
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request introduces a new GOAP module with support for various condition types and operators for evaluating GOAP states. Key changes include:

  • Implementation of multiple condition structs such as NoCondition, ConditionOr, ConditionAnd, and a generic Condition.
  • Introduction of the ConditionInterface and ConditionOperator enum to standardize condition behavior.
  • Updates to documentation and cost estimation logic across condition types.

Reviewed Changes

Copilot reviewed 42 out of 55 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
Scripts/Goap/Conditions/NoCondition.cs A basic condition always satisfied, with zero cost estimation.
Scripts/Goap/Conditions/ConditionOr.cs Implements a composite OR condition that returns the minimum cost.
Scripts/Goap/Conditions/ConditionOperator.cs Introduces operators for state comparisons in conditions.
Scripts/Goap/Conditions/ConditionInterface.cs Defines a standard interface for GOAP conditions.
Scripts/Goap/Conditions/ConditionAnd.cs Implements a composite AND condition with cost estimation logic.
Scripts/Goap/Conditions/Condition.cs Provides the generic condition implementation for state comparisons.
README.md Adds badges to improve repository maintainability visibility.
Files not reviewed (13)
  • Docs.meta: Language not supported
  • Docs/GOAP_ClassDiagram.png.meta: Language not supported
  • Docs/GOAP_ClassDiagram.puml: Language not supported
  • Docs/GOAP_ClassDiagram.puml.meta: Language not supported
  • README.md.meta: Language not supported
  • Scripts.meta: Language not supported
  • Scripts/Goap.meta: Language not supported
  • Scripts/Goap/Conditions.meta: Language not supported
  • Scripts/Goap/Conditions/Condition.cs.meta: Language not supported
  • Scripts/Goap/Conditions/ConditionAnd.cs.meta: Language not supported
  • Scripts/Goap/Conditions/ConditionInterface.cs.meta: Language not supported
  • Scripts/Goap/Conditions/ConditionOperator.cs.meta: Language not supported
  • Scripts/Goap/Conditions/ConditionOr.cs.meta: Language not supported
Comments suppressed due to low confidence (4)

Scripts/Goap/Conditions/ConditionInterface.cs:27

  • [nitpick] Consider renaming the parameter 'costPerDiffes' to a clearer name such as 'costPerDifferences' for enhanced readability.
public double EstimateCost(GoapState state, Dictionary<string, double> costPerDiffes = null)

Scripts/Goap/Conditions/Condition.cs:26

  • [nitpick] Consider renaming 'stateIndex' to 'StateIndex' to follow C# naming conventions for public properties.
public string stateIndex { get; private set; }

Scripts/Goap/Conditions/Condition.cs:31

  • [nitpick] Consider renaming 'valueComparing' to 'targetValue' or 'comparisonValue' for increased clarity.
public T valueComparing { get; set; }

Scripts/Goap/Conditions/ConditionOr.cs:13

  • [nitpick] Consider renaming 'conditions' to 'Conditions' to align with C# public property naming conventions.
public ConditionInterface[] conditions { get; private set; }

@konbraphat51 konbraphat51 marked this pull request as ready for review April 25, 2025 07:09
@konbraphat51
Copy link
Collaborator Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant