octachrome / treason

A clone of the card game Coup written in Node.js
Other
138 stars 79 forks source link

AIs won't bluff role that was challenged and will challenge role that was challenged successfully #10

Closed einsteinsfool closed 7 years ago

einsteinsfool commented 7 years ago

Another PR that passed all tests. I will add more tests in the future after I write more PRs. For now AIs don't play as I'd expect them to so I prefer to first improve them. I have over 10 more ideas for fixes/improvements. And I finally know what's the difference between state.playerIdx and state.state.playerIdx. So it will be easier to change stuff now. :D

einsteinsfool commented 7 years ago

As for adding the stringify, here's output from game.js without it:

players: 
 [ { name: 'knoob',
     cash: 2,
     influenceCount: 2,
     influence: [Object],
     isObserver: false,
     ai: false,
     isReady: true,
     connected: true },

And here is with:

"players": [
    {
        "name": "knoob",
        "cash": 2,
        "influenceCount": 2,
        "influence": [
            {
                "role": "assassin",
                "revealed": false
            },
            {
                "role": "duke",
                "revealed": false
            }
        ],
einsteinsfool commented 7 years ago

Good remarks. Added a comment why lastRoleClaim shouldn't be nulled on INFLUENCE_REVEAL state. It's because we still need this value to update calledBluffs. You're right, I removed the unnecessary function since in onHistoryEvent we also update calledBluffs of AIs. And finally, I think you meant:

If you are in BLOCK_RESPONSE state, you need to check whether the blocking player

Fixed that too.

octachrome commented 7 years ago

Good stuff!