Skip to content

Seeking AI behaviour#18

Open
EtienneDesticourt wants to merge 21 commits intomasterfrom
AI_Proposal
Open

Seeking AI behaviour#18
EtienneDesticourt wants to merge 21 commits intomasterfrom
AI_Proposal

Conversation

@EtienneDesticourt
Copy link
Copy Markdown
Member

Pretty much done, just need to figure out how to pass eid from movement to seek.

|> Map.put(Position, new_pos)
|> Map.put(Movement, new_movement)
end)
{:ok, %MapInstance{map: map, players: _}} = Entity.fetch_attribute(entity, MapInstance)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does the player have a map-instance attribute? I thought it was for maps only...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I added it to be able to notify the player's map's agents but I'll remove it now that we're gonna use :entity_change instead.

do: {:ok, entity |> put_attribute(%Seek{aggro_distance: aggro_distance, escape_distance: escape_distance})}

def init(entity, _args),
def init(entity, _args),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

whitespace change - kittens gonna die! :'(

def terminate(_reason, entity),
do: {:ok, entity |> remove_attribute(Movement)}

defp start_update_trigger_timer(message, time) do
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is there a need for this check? Otherwise just simply always use Process.send_after for simplicity

Copy link
Copy Markdown
Member Author

@EtienneDesticourt EtienneDesticourt Aug 15, 2016

Choose a reason for hiding this comment

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

I don't know. I copied it from here 20aa29d#diff-366987ce92dde211ad3e5f552c55e0d4R148 and assumed there was some kind of problem with send_after(message, 0). Although looking at it again it seems it might have just been to return nil so the calling function could interpret it as a timer ref so I'll replace it as you said.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In the other case we needed either the nil or the timer to cancel the timer appropriately - here we don't do anything with it, so we can just use the send_after I think :)

the client, but for simplicities sake we used velocity as a name.
"""
defstruct goal: %Coord{}, plane: 1, move_type: 9, velocity: 1.0
defstruct goal: %Coord{}, plane: 1, move_type: 9, velocity: 1.0, update_self: false, update_delay: 1
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I was thinking maybe we can shorten this a bit - for starters, I guess the update interval is static and can be compile with @update_interval 1 (also note the naming... delay sounds like waiting for something, which we don't do)
Second, I think 1ms for the interval is too short, considering that all NPCs are doing it and there will spam the whole map with position updates. I think for clients we have something like a position update every 50ms or so.
Next, maybe we can find a better name for update_self? Something that tells us that this behaviour is automatically recalculating its state?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

How about auto_move_update ?

@ephe-meral
Copy link
Copy Markdown
Member

@EtienneDesticourt any updates on this?

@EtienneDesticourt
Copy link
Copy Markdown
Member Author

Nope, no time to work on it lately. You can merge if you're good with the current state, the seeking logic is there even though the pathing AI isn't. We could add that in a separate branch.

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.

2 participants