jankeromnes / terraforming-mars-bot

A proof-of-concept Terraforming Mars AI meant to play https://github.com/bafolts/terraforming-mars/ automatically
MIT License
14 stars 7 forks source link

Trying to annotate corps #8

Open SliceOfBread opened 3 years ago

SliceOfBread commented 3 years ago

When the corporation has an action (UNMI as an example) and this comes up in the play options, the annotateCrad function tries to run on the corp and spits out an error. This is minor as it doesn't prevent anything playing.

Game state (1p): gen=14, temp=8, oxy=0, oceans=5, phase=research Bot plays: [ [] ] Game state (1p): gen=14, temp=8, oxy=0, oceans=5, phase=action Bot plays: [ [ '0' ], [ 'Fish' ] ] Game state (1p): gen=14, temp=8, oxy=0, oceans=5, phase=action Bot plays: [ [ '0' ], [ '1' ], [ '1' ] ] Game state (1p): gen=14, temp=8, oxy=0, oceans=5, phase=action Bot plays: [ [ '32' ] ] card not found United Nations Mars Initiative Error: Could not find card: { "name": "United Nations Mars Initiative", "calculatedCost": 0, "cardType": "green", "isDisabled": false } at annotateCards (/workspace/terraforming-mars-bot/play-bot.js:145:21) at annotateWaitingFor (/workspace/terraforming-mars-bot/play-bot.js:121:5) at annotateWaitingFor (/workspace/terraforming-mars-bot/play-bot.js:125:5) at playGame (/workspace/terraforming-mars-bot/play-bot.js:98:5) at runMicrotasks () at processTicksAndRejections (internal/process/task_queues.js:97:5) at async /workspace/terraforming-mars-bot/play-bot.js:43:20 Game state (1p): gen=14, temp=8, oxy=0, oceans=6, phase=action Bot plays: [ [ '0' ], [ 'United Nations Mars Initiative' ] ] Game state (1p): gen=14, temp=8, oxy=0, oceans=6, phase=action Bot plays: [ [ '0' ], [ '1' ], [ '1' ] ] Game state (1p): gen=14, temp=8, oxy=0, oceans=6, phase=action

jankeromnes commented 3 years ago

Indeed, many thanks for reporting this @SliceOfBread!

It's good that the script just logs this error instead of halting the entire game, but given that corporation cards do seem to come up in waitingFor.cards, we should probably teach annotateCards to recognize corporation cards and handle them differently (i.e. there is no point in calling getProjectCardByName() for corporations).

SliceOfBread commented 3 years ago

Is there a situation (card) where anyone would need the annotation for "perform an action from a played card"?

jankeromnes commented 3 years ago

Good point. Probably most of the annotations are not helpful when playing card actions (i.e. tags, calculatedCost, etc), except probably to know what the card's action is (this information is currently only available in the form of rendering metadata, which isn't ideal because it's clearly meant for rendering a card graphically, and any change to the rendering data format may break any parser we write to understand card effects/actions).

I've started writing such a card effects/actions parser for quantum bot, but it's not very smart yet (e.g. doesn't yet understand conversions like 8 heat -> 1 TR, or parametrized effects like 1 TR / jovian tag, let alone more complicated things like microbes, animals, etc).

Probably a better way forward than parsing render data would be for the game to expose card effects in some bot-understandable way. (Sorry for the slide side-track!)

SliceOfBread commented 3 years ago

(continuing the side-track) I started work on a list of cards with more machine readable information. This was originally from a forum post and later updated by the people who Play-By-Forum on BGG. The first iteration will include base+corp+prelude and the corporations and prelude are complete (well, for now). I'm trying to get to a place where I can use this plus the code from the cards in https://github.com/bafolts/terraforming-mars/src/cards

It is at https://github.com/SliceOfBread/tm-cards if you are interested.