Creating GOAP drones for EarthGames


Creating robust GOAP bots that get the level key if not in combat with a player, then heads to the nearest portal, then exit door.

Here are the basic foundations. 


# Define current state and goals
var current_state = {
    "at_door": false,
    "has_key": false,
    "in_action": false,
    "player_defeated": false,
}
# match goals w/ main function lib
var goals = {
    "at_door": true,
    "has_key": true,
    "in_action": false,
    "player_defeated": false,
}
# Define possible actions
var action_book = {
    "at_door": {
        "required":{"has_key":true, "in_action": false},
        "effects":{"at_door": true, }
        },
    "has_key": {
        "required":{"in_action": false},
        "effects":{"has_key": true, }
    },
    "in_action": {"required":{"in_action": false}},
    "player_defeated": false,
}
# Main loop
    # Check if goals are satisfied     var goals_satisfied = true     for goal in goals.keys():         if goals[goal] != current_state[goal]:             goals_satisfied = false             break     # If goals not satisfied
        plan() #Effects Update to current state func _effects_update(efx, state):
self.current_state[efx] = state    
#Check if all parameters for the state change are met
func _check_required(req): 
if self.current_state[x] == req.values()[x]: 
_effects_update(...) #if params are met you could Break the loop call a function or let statements/the state changes fire functions in process
              # Define GOAP planner func plan():     #if not in action___     for top_goals size:         if [top_goals[x]] == true:             for action_book[x] size:                 var require_ok = _check_required(action_book[goals.keys()[top_goals[z]]]["required"])         

    

            

Test out Build 1

Leave a comment

Log in with itch.io to leave a comment.