Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FR] make the @agent macro define pretty printing as well #965

Open
Datseris opened this issue Feb 3, 2024 · 1 comment
Open

[FR] make the @agent macro define pretty printing as well #965

Datseris opened this issue Feb 3, 2024 · 1 comment
Labels
quality of life QoL enhancements that make user experience smoother

Comments

@Datseris
Copy link
Member

Datseris commented Feb 3, 2024

Currently we have:

@agent struct SchellingAgent(GridAgent{2})
    mood::Bool # whether the agent is happy in its position
    group::Int # The group of the agent, determines mood as it interacts with neighbors
end

a = SchellingAgent(1, (1,1), true, 1)

which prints

SchellingAgent(1, (1, 1), true, 1)

wouldn't it be nice to have pretty printing by default, so that each field is printed in 1 line, along with its name, its type, and then = value ? I am sure this shouldn't be too difficult to do...?

@Datseris Datseris added the quality of life QoL enhancements that make user experience smoother label Feb 3, 2024
@Datseris
Copy link
Member Author

Datseris commented Feb 3, 2024

Actually, we don't this at the macro level. We can define Base.show(..., a::AbstractAgent) and just loop over fields and print them. In this function we can also handle properly the @multiagent created types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
quality of life QoL enhancements that make user experience smoother
Projects
None yet
Development

No branches or pull requests

1 participant