Commit fe417f69 authored by Victor's avatar Victor
Browse files

overloading show for world and sim

parent eb64136a
...@@ -101,13 +101,9 @@ Base.copy(m::Missing) = missing ...@@ -101,13 +101,9 @@ Base.copy(m::Missing) = missing
Base.copy(n::Nothing) = nothing Base.copy(n::Nothing) = nothing
function Base.show(io::IO, a::AbstractAgent) function Base.show(io::IO, a::Agent{A,R,T,U,V}) where {A,R,T,U,V}
print(io,"pos: ") println(io, "Agent with indices of type", T)
show(io, a.x_history) end
println(io)
print(io,"t: ")
show(io, a.t_history)
end
Base.summary(A::AbstractAgent) = string(TYPE_COLOR,nameof(typeof(a)),NO_COLOR," with uType ",TYPE_COLOR,eltype(a.x_history)) Base.summary(A::AbstractAgent) = string(TYPE_COLOR,nameof(typeof(a)),NO_COLOR," with uType ",TYPE_COLOR,eltype(a.x_history))
......
...@@ -33,6 +33,9 @@ Base.lastindex(s::Simulation) = get_size(s) ...@@ -33,6 +33,9 @@ Base.lastindex(s::Simulation) = get_size(s)
Base.getindex(s::Simulation,measure::String) = [agg[measure] for agg in s.df_agg] Base.getindex(s::Simulation,measure::String) = [agg[measure] for agg in s.df_agg]
function Base.show(io::IO, s::Simulation{A,S,T,F}) where {A,S,T,F}
println(io, "Simulation with agents of type", A)
end
# TODO: define two functions with signatures # TODO: define two functions with signatures
# function add_entry!(s::Simulation{A,S,T,F},w::World) where {A,S,T,F<:Function} # function add_entry!(s::Simulation{A,S,T,F},w::World) where {A,S,T,F<:Function}
# function add_entry!(s::Simulation{A,S,T,F},w::World) where {A,S,T,F<:Nothing} # function add_entry!(s::Simulation{A,S,T,F},w::World) where {A,S,T,F<:Nothing}
......
...@@ -34,6 +34,10 @@ Get x of world without geotrait. ...@@ -34,6 +34,10 @@ Get x of world without geotrait.
""" """
Base.getindex(w::World,i) = w.agents[i] Base.getindex(w::World,i) = w.agents[i]
function Base.show(io::IO, w::World{A,S,T}) where {A,S,T}
println(io, "World with agents of type", A)
end
addAgent!(w::World,a::AbstractAgent) = begin addAgent!(w::World,a::AbstractAgent) = begin
push!(w.agents,a) push!(w.agents,a)
end end
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment