To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

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
Base.copy(n::Nothing) = nothing
function Base.show(io::IO, a::AbstractAgent)
print(io,"pos: ")
show(io, a.x_history)
println(io)
print(io,"t: ")
show(io, a.t_history)
end
function Base.show(io::IO, a::Agent{A,R,T,U,V}) where {A,R,T,U,V}
println(io, "Agent with indices of type", T)
end
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)
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
# 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}
......
......@@ -34,6 +34,10 @@ Get x of world without geotrait.
"""
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
push!(w.agents,a)
end
......
Markdown is supported
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