Skip to content

Commit

Permalink
format environment
Browse files Browse the repository at this point in the history
  • Loading branch information
jarbus committed Feb 27, 2024
1 parent 5b6113e commit 7d3bc15
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/environments/environment.jl
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
export step!, done, play
# Creation should be done as an environment constructor
function step!(env::AbstractEnvironment, args...; kwargs...)
@error "step! not implemented for $(typeof(env))"
end
function done(::AbstractEnvironment)::Bool
true
end
done(::AbstractEnvironment)::Bool = true
play(match::Match) = play(match.environment_creator, match.individuals)
function play(environment_creator::AbstractCreator, individuals::Vector{<:AbstractIndividual})
play(environment_creator(), develop.(individuals))
step!(env::AbstractEnvironment, args...; kwargs...) =
@error "step! not implemented for $(typeof(env))"

end
play(environment_creator::AbstractCreator, individuals::Vector{<:AbstractIndividual}) =
play(environment_creator(), develop.(individuals))

function play(env::AbstractEnvironment, phenotypes::Vector{<:AbstractPhenotype})
is_done = false
scores = zeros(length(phenotypes))
scores = zeros(Float32, length(phenotypes))
while !is_done
scores += step!(env, phenotypes)
is_done = done(env)
Expand Down

0 comments on commit 7d3bc15

Please sign in to comment.