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

[Python] Make MARITIME_TRADE action's value a 10-integer list #157

Open
bcollazo opened this issue Mar 6, 2022 · 2 comments · May be fixed by #289
Open

[Python] Make MARITIME_TRADE action's value a 10-integer list #157

bcollazo opened this issue Mar 6, 2022 · 2 comments · May be fixed by #289
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@bcollazo
Copy link
Owner

bcollazo commented Mar 6, 2022

Right now trade actions look like:

Action(Color.BLUE, ActionType.MARITIME_TRADE, ("WOOD", "WOOD", None, None, "SHEEP")) # 2 woods for a sheep
Action(Color.BLUE, ActionType.MARITIME_TRADE, ("BRICK", "BRICK", "BRICK", "BRICK", "WHEAT")) # 4 bricks for a wheat

Seems better to encode these as a union of two "freqdecks". This will make it more vector-friendl, potentially faster, and more interoperable with the rest of the code.

Action(Color.BLUE, ActionType.MARITIME_TRADE, (2,0,0,0,0,0,0,1,0,0)) # 2 woods for a sheep
Action(Color.BLUE, ActionType.MARITIME_TRADE, (0,4,0,0,0,0,0,0,1,0)) # 4 bricks for a wheat
@bcollazo bcollazo added enhancement New feature or request good first issue Good for newcomers labels Mar 6, 2022
@pachewise
Copy link
Contributor

Shouldn't this be two arguments? as in Action(Player, Action.Trade, (GiveFreqdeck, ReceiveFreqdeck)). Any reason why you decided to concatenate them?

@bcollazo
Copy link
Owner Author

bcollazo commented Apr 4, 2022

Ahh, that makes sense. I think I am mixing the end-goal with the current state of things. I think at the current state of things your suggestion makes sense.

However, more and more it seems we want to keep de-adopting Python high-level objects (including enums) in favor of more primitive data types because of performance. Particularly, this action might actually become something like:

(1,8,2,0,0,0,0,0,0,1,0,0)

in the future, where 1 means Blue, 8 means Maritime Trade, and such. That should make .copy() methods of the state much faster. Ideally, the complete state is just a vector we can quickly copy and edit by convention (i.e. index 5 is number of houses for second player, ...); for speed.

@zarns zarns linked a pull request Nov 3, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants