-
Notifications
You must be signed in to change notification settings - Fork 4
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
Seeking AI behaviour #18
Open
EtienneDesticourt
wants to merge
21
commits into
master
Choose a base branch
from
AI_Proposal
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
3d72012
Skeleton
EtienneDesticourt e9913c3
Seek logic rework, removed channel callback
EtienneDesticourt 59fa130
Fixed seek logic and added tests, fixed movement update, added ref to…
EtienneDesticourt 3792cbd
Minor rename for clarity
EtienneDesticourt 1fd1a23
Modified Seek to listen for :entity_change on Position
EtienneDesticourt 239f2cc
:pos -> :coord
EtienneDesticourt 165397c
Modified way AI behaviours are chosen for an npc
EtienneDesticourt f382506
Removed added whitespace
EtienneDesticourt e9c9693
Merge remote-tracking branch 'refs/remotes/origin/master' into AI_Pro…
EtienneDesticourt 6fdee5b
:pos -> :coord
EtienneDesticourt f15a24f
Whitespace removal
EtienneDesticourt b2a2252
Added auto pos update skeleton
EtienneDesticourt 12af7b6
Cleaned up seeking handler, fixed movement update handler
EtienneDesticourt 260666f
Removed excess linebreak
EtienneDesticourt f718ddf
Naming changes
EtienneDesticourt 38b65ca
Updated deps
EtienneDesticourt f819c1d
Put better default aggro/escape dist
EtienneDesticourt f7ab019
Set seeking as default npc behaviour, started auto updates at behavio…
EtienneDesticourt 0c18581
Fixed tests
EtienneDesticourt d93eeb8
Changed event from map to atom, fixed seeks option
EtienneDesticourt e6dc0a6
Added geom deps, replaced Coord with Vector2D, added NavMesh to maps
EtienneDesticourt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Minor rename for clarity
- Loading branch information
commit 3792cbd470b7ff9b8dc1178b3f8eeb2a2ed1272a
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,25 +26,25 @@ defmodule Entice.Logic.Seek do | |
do: {:ok, entity |> put_attribute(%Seek{})} | ||
|
||
#No introspection for npcs ;) | ||
def handle_event({:movement_agent_updated, %Position{pos: _}, other_entity_id}, %Entity{id: id} = entity) | ||
when other_entity_id == id, | ||
def handle_event({:movement_agent_updated, %Position{pos: _}, moving_entity_id}, %Entity{id: my_id} = entity) | ||
when moving_entity_id == my_id, | ||
do: {:ok, entity} | ||
|
||
def handle_event({:movement_agent_updated, %Position{pos: mover_pos}, other_entity_id}, | ||
def handle_event({:movement_agent_updated, %Position{pos: mover_pos}, moving_entity_id}, | ||
%Entity{attributes: %{Position => %Position{pos: my_pos}, | ||
Movement => _, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we check for Movement here? I mean, if we need it for the behaviour, why not using the deconstructed variable? |
||
Npc => %Npc{init_pos: init_pos}, | ||
Seek => %Seek{aggro_distance: aggro_distance, escape_distance: escape_distance, target: target}}} = entity) do | ||
case target do | ||
nil -> | ||
if calc_distance(my_pos, mover_pos) < aggro_distance do | ||
{:ok, entity |> update_attribute(Seek, fn(s) -> %Seek{s | target: other_entity_id} end) | ||
{:ok, entity |> update_attribute(Seek, fn(s) -> %Seek{s | target: moving_entity_id} end) | ||
|> update_attribute(Movement, fn(m) -> %Movement{m | goal: mover_pos} end)} | ||
else | ||
{:ok, entity} | ||
end | ||
|
||
^other_entity_id -> | ||
^moving_entity_id -> | ||
if calc_distance(init_pos, mover_pos) >= escape_distance do | ||
{:ok, entity | ||
|> update_attribute(Seek, fn(s) -> %Seek{s | target: nil} end) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above, no args = what behaviour?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right I'll add an init that only take an entity
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here I meant: Do we need this case? Is this actually any use without parameters?