Skip to content
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
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
3d72012
Skeleton
EtienneDesticourt Aug 8, 2016
e9913c3
Seek logic rework, removed channel callback
EtienneDesticourt Aug 9, 2016
59fa130
Fixed seek logic and added tests, fixed movement update, added ref to…
EtienneDesticourt Aug 10, 2016
3792cbd
Minor rename for clarity
EtienneDesticourt Aug 10, 2016
1fd1a23
Modified Seek to listen for :entity_change on Position
EtienneDesticourt Aug 10, 2016
239f2cc
:pos -> :coord
EtienneDesticourt Aug 10, 2016
165397c
Modified way AI behaviours are chosen for an npc
EtienneDesticourt Aug 10, 2016
f382506
Removed added whitespace
EtienneDesticourt Aug 10, 2016
e9c9693
Merge remote-tracking branch 'refs/remotes/origin/master' into AI_Pro…
EtienneDesticourt Aug 10, 2016
6fdee5b
:pos -> :coord
EtienneDesticourt Aug 10, 2016
f15a24f
Whitespace removal
EtienneDesticourt Aug 11, 2016
b2a2252
Added auto pos update skeleton
EtienneDesticourt Aug 11, 2016
12af7b6
Cleaned up seeking handler, fixed movement update handler
EtienneDesticourt Aug 15, 2016
260666f
Removed excess linebreak
EtienneDesticourt Aug 15, 2016
f718ddf
Naming changes
EtienneDesticourt Aug 16, 2016
38b65ca
Updated deps
EtienneDesticourt Oct 10, 2016
f819c1d
Put better default aggro/escape dist
EtienneDesticourt Oct 10, 2016
f7ab019
Set seeking as default npc behaviour, started auto updates at behavio…
EtienneDesticourt Oct 10, 2016
0c18581
Fixed tests
EtienneDesticourt Oct 10, 2016
d93eeb8
Changed event from map to atom, fixed seeks option
EtienneDesticourt Oct 11, 2016
e6dc0a6
Added geom deps, replaced Coord with Vector2D, added NavMesh to maps
EtienneDesticourt Oct 14, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Minor rename for clarity
  • Loading branch information
EtienneDesticourt committed Aug 10, 2016

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 3792cbd470b7ff9b8dc1178b3f8eeb2a2ed1272a
10 changes: 5 additions & 5 deletions lib/entice/logic/ai/seek.ex
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{})}
Copy link
Member

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?

Copy link
Member Author

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

Copy link
Member

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?


#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 => _,
Copy link
Member

Choose a reason for hiding this comment

The 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)