bcollazo / catanatron

Settlers of Catan Bot Simulator and Strong AI Player
https://catanatron.com
GNU General Public License v3.0
266 stars 62 forks source link

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

Open bcollazo opened 2 years ago

bcollazo commented 2 years ago

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
pachewise commented 2 years ago

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

bcollazo commented 2 years ago

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.