Minor tweaks
This commit is contained in:
parent
23b507dc4c
commit
2e8e848a04
@ -241,6 +241,7 @@ defmodule Diamondtail.Brain do
|
||||
|
||||
@spec determine_move(Genome.t(), map(), map(), map()) :: %{move: :up | :down | :left | :right, shout: String.t()}
|
||||
def determine_move(genome, board, self, game) do
|
||||
# TODO: Consider keeping track of how many moves are available in latency calculation
|
||||
start_time = Time.utc_now()
|
||||
base_state = GameState.from(board, self)
|
||||
external_latency = ExternalLatencyManager.get_external_latency()
|
||||
@ -257,8 +258,9 @@ defmodule Diamondtail.Brain do
|
||||
end, ordered: false, timeout: :infinity)
|
||||
|
||||
if Enum.empty?(options) do
|
||||
end_time = Time.utc_now()
|
||||
InternalLatencyManager.register_latency(map_size(base_state.snakes), depth, Time.diff(end_time, start_time, :millisecond))
|
||||
# Don't register latency since we basically did no computation
|
||||
# end_time = Time.utc_now()
|
||||
# InternalLatencyManager.register_latency(map_size(base_state.snakes), depth, Time.diff(end_time, start_time, :millisecond))
|
||||
%{
|
||||
move: :left,
|
||||
shout: "I'm dead, good game!"
|
||||
@ -266,11 +268,12 @@ defmodule Diamondtail.Brain do
|
||||
else
|
||||
{:ok, {action, score}} = Enum.max_by(options, fn {:ok, {_, s}} -> s end)
|
||||
end_time = Time.utc_now()
|
||||
InternalLatencyManager.register_latency(map_size(base_state.snakes), depth, Time.diff(end_time, start_time, :millisecond))
|
||||
latency = Time.diff(end_time, start_time, :millisecond)
|
||||
InternalLatencyManager.register_latency(map_size(base_state.snakes), depth, latency)
|
||||
|
||||
%{
|
||||
move: action,
|
||||
shout: "#{inspect(options |> Enum.map(fn {:ok, v} -> v end) |> Enum.to_list)} (#{score})"
|
||||
shout: "#{action}: #{score} (#{depth}, #{latency}ms/#{target_latency}ms)"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
@ -19,9 +19,9 @@ defmodule Diamondtail.Router do
|
||||
|> send_resp(200, JSON.encode!(%{
|
||||
apiversion: "1",
|
||||
author: "kodicraft",
|
||||
color: "#4684ff",
|
||||
color: "#af2ecb",
|
||||
head: "trans-rights-scarf",
|
||||
tail: "hook",
|
||||
tail: "crystal-power",
|
||||
version: Mix.Project.config()[:version]
|
||||
}))
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user