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

Better Bot repr #847

Open
Debilski opened this issue Feb 5, 2025 · 3 comments
Open

Better Bot repr #847

Debilski opened this issue Feb 5, 2025 · 3 comments

Comments

@Debilski
Copy link
Member

Debilski commented Feb 5, 2025

For reference, this is the current repr(bot):

<pelita.team.Bot object at 0x102778b90>

This is str(bot):

Playing on red side. Current turn: 1. Bot: y. Round: 1, score: 0:0. timeouts: 0:0
################################
#.  . #.   .              . #.y#
#     #  #### ###  .    #  . .x#
#    .  ##..#     #########    #
#.    #  #  #.### . ..  .. .#  #
######## #. #     ####  #.### ##
# .#     #. #     .#    .   #  #
#    ## ##.    ##..#  # .#  # ##
## #  #. #  #..##    .## ##    #
#a #   .    #.     # .#     #. #
##b###.#  ####     # .# ########
#  #. ..  .. . ###.#  #  #    .#
#    #########     #..##  .    #
# . .  #    .  ### ####  #     #
# .# .              .   .# .  .#
################################
Bots: {'a': (1, 9), 'x': (30, 2), 'b': (2, 10), 'y': (30, 1)}
Noisy: {'a': True, 'x': False, 'b': True, 'y': False}
Food: [(30, 14), (21, 10), (24, 4), (20, 14), (26, 1), (24, 7), (27, 4), (29, 9), (18, 6), (21, 8), (20, 12), (21, 4), (25, 4), (27, 2), (18, 4), (24, 14), (17, 7), (18, 7), (29, 1), (20, 4), (27, 14), (21, 9), (21, 12), (18, 11), (24, 6), (25, 5), (29, 2), (19, 2), (26, 12), (30, 11), (11, 1), (10, 5), (10, 11), (13, 4), (12, 13), (2, 13), (7, 9), (10, 6), (6, 10), (10, 3), (4, 1), (13, 11), (11, 11), (2, 14), (13, 8), (14, 8), (7, 1), (4, 13), (6, 11), (5, 14), (1, 1), (11, 3), (10, 7), (1, 4), (13, 9), (2, 6), (5, 3), (4, 11), (7, 11), (7, 8)]

At the least I think it should be something like:

<Bot: y (red), (30, 1), turn: 1, round: 1>
@otizonaizit
Copy link
Member

At the least I think it should be something like:

<Bot: y (red), (30, 1), turn: 1, round: 1>

but that is what is there already in the first line, no?

Playing on red side. Current turn: 1. Bot: y. Round: 1, score: 0:0. timeouts: 0:0

The strings can be reshuffled, yes, but all the info is there already.

Should we short circuit __repr__ to __str__, so that we can use that representation in the exceptions too?

@Debilski
Copy link
Member Author

Debilski commented Feb 5, 2025

I think __repr__ should only include the first line of __str__, but even this might be too verbose. We should see that code like

print([b, b.other])

stays readable.

@Debilski
Copy link
Member Author

Debilski commented Feb 5, 2025

(Discussion can also be postponed; I’m in the middle of restructuring the network code and we can approach this part later.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants