aiutility

package module
v0.0.0-...-3ecad0d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 18, 2023 License: GPL-3.0 Imports: 0 Imported by: 1

README

aiutility

Very basic implementation of an utility based AI

The components of the AI are:

  • Reasoner
  • Action
  • Consideration

The reasoner is the main component that decides what to do. It has a list of actions that it can choose from. Each action has a list of considerations that it uses to decide if it should perform that action. Each consideration generates an appraisal (in form of a score) that is used to calculate the utility of the action. The action with the highest utility is then chosen.

Great explanation of utility based AI: https://www.gdcvault.com/play/1012410/Improving-AI-Decision-Modeling-Through

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action struct {
	Name    string                  // The name of the action.
	Utility func(*Reasoner) float64 // The utility of the action.
	Execute func()                  // The function that executes the action.
}

Action represents an action that can be performed by an agent.

type Consideration

type Consideration func(params any) float64

Consideration represents a consideration that can be used to calculate the utility of an action. TODO: Introduce parameters for considerations. - This could be entity a and b for calculating the distance between two entities, etc.

type Reasoner

type Reasoner struct {
	Actions        []*Action                // The actions that can be performed by the agent.
	Considerations map[string]Consideration // The considerations that can be used to calculate the utility of an action.
}

Reasoner represents the root of the AI system. It contains all the actions and considerations.

func NewReasoner

func NewReasoner() *Reasoner

NewReasoner returns a new reasoner.

func (*Reasoner) BestAction

func (r *Reasoner) BestAction() *Action

BestAction returns the action with the highest utility.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL