Skip to content

Allow 3-5 ants per team#23

Open
saphiooo wants to merge 5 commits intoGrace-H:mainfrom
saphiooo:feature/varying-ant-teams
Open

Allow 3-5 ants per team#23
saphiooo wants to merge 5 commits intoGrace-H:mainfrom
saphiooo:feature/varying-ant-teams

Conversation

@saphiooo
Copy link
Contributor

Allowing for increased flexibility in the number of ants per team, with more developed error handling for cases where (1) north and south teams don't have the same number of ants, and (2) there are too few or too many ants in a team.

Updated the docs accordingly.

main.py Outdated
team2 = (GridBuilderStrat, SmarterRandomStrat, HorizontalStrat, ScoutStrat, RandomStrat)
DEBUG = False # Change this to True to get more detailed errors from ant strategies

# C. Create relevant error-handling measures
Copy link
Owner

@Grace-H Grace-H Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The section above the divider is for setup code that is modified before running the simulation--should the exceptions be further down below "Begin Game" with the other class definitions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes - sounds good! I'll place them below the other class definitions.

main.py Outdated
NORTH_SYMS = ["A", "B", "C", "D", "E"]
SOUTH_SYMS = ["F", "G", "H", "I", "J"]
else:
raise AntCountError ("Teams do not have between 3 to 5 ants.")
Copy link
Owner

@Grace-H Grace-H Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that the game better handles varying team sizes.

It seems like ANTS_COUNT, NORTH_SYMS, and SOUTH_SYMS are now varying parameters and not constants, so I think it could be good design to merge this code into the game configuration functions. What do you think about refactoring to move this logic into generate_game_config and adding these three variables to the config dictionary?

Alternatively, NORTH_SYMS and SOUTH_SYMS could be constant lists of length 5 but at opposite ends of the alphabet, so that certain letters (like E) are always on the same team. Then, a config key 'ants_count' would tell you how much of each list to use

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactoring the logic sounds good. I'm more hesitant about having SOUTH_SYMS start from the end of the alphabet, as the indicator for the south anthill is already X, but NORTH_SYMS and SOUTH_SYMS could be the constant lists of ['A', 'B', 'C', 'D', 'E'] and ['F', 'G', 'H', 'I', 'J'] respectively instead.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point about the anthill symbol

@saphiooo
Copy link
Contributor Author

It seems odd to prompt teams for the number of ants in their team every game, if teams for the entire Antcode project are set in stone. However, I left some relevant code that does use this approach at the end of the generate_game_config() function.

3+ ants colliding previously resulted in the program breaking due to referencing a nonexistent ant symbol. A future update will optimize the communication surrounding the collision ("Ants F, G, and H collided" as opposed to "Ants F and G collided / Ants F and H collided / Ants G and H collided").

@saphiooo
Copy link
Contributor Author

There appears to be a rare edge case scenario where 3 ants colliding can result in another AttributeError due to the way proposed_moves was changed. Planning to update soon with some refactoring that should fix the issue.

condense conflict messages,
add clarifying notes about ant behavior, vision priority, and message passing,
fix example code typo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments