mgcsweek / csweekmon

Tiny toy project for MG CS Week
MIT License
1 stars 4 forks source link

Fragile moves/items usage #4

Open rand0musername opened 5 years ago

rand0musername commented 5 years ago

If we're wishing to optimize for the ease of use when defining new strategies, perhaps we should use enums or strings for moves/items in Strategy classes. Ideally instead of returning 0, 1 from choose_action competitors should return PERFORM_MOVE, ATTACK. This is much more readable for complex strategies and I believe will lead to less dumb mistakes.

rand0musername commented 5 years ago

I will add enums for commands in my PR, but let's discuss the rest first.

rand0musername commented 5 years ago

PR #7 for command (I meant action) enums.

rand0musername commented 5 years ago

Also I find strategy-centered indexing (e.g. 2 means "second of my items") to be a bit weird, if we're sticking with numbers let's at least use a global indexing (e.g. 2 always means "cookie) and a table somewhere in a PDF.

Dreian commented 5 years ago

I prefer strategy-centred indexing, it makes you focus only on the moves you selected. Also, you will otherwise have to verify that every time you return an action, it is a valid one (so game_engine has to adequately cope with it).

rand0musername commented 5 years ago

I don't think that would be hard to code from game engine perspective, but I see what you mean.

I am still not the biggest fan of raw numbers (especially when you have ~10 items), maybe strategy_gen.py could generate local constants that resolve to those numbers (so nothing changes from game engine perspective)? Like ITEM_TEN instead of 10? It's a bit dumb but less fragile? Idk