TricksterCards / TricksterBots

Suggest methods for bots used in Trickster Cards.
MIT License
9 stars 8 forks source link

Spades: bot should bid/behave appropriately in end game #54

Open johnbent opened 2 years ago

johnbent commented 2 years ago

Seems like the bot doesn't take end game situation into consideration. The bot just has one method of bidding and playing and it plays like that regardless of end game situation.

Perfect example: I'm partnering with bot and I'm last bid in game to 500. Score was 472 for them to 381 for us. Bot bid 2, opps bid 3, I bid nil. So, excluding bags, if everyone gets their bids, the final score is 502 for them to 501 for us. We only win if I get my nil and bot gets 2 more bags than them. We could also avoid losing if bot would sacrifice its 2 bid and give them 8 bags. But bot made no attempt at either of these. We were down to two tricks left and my nil was safe and bot had just one trick. Instead of sacrificing its bid to keep the game alive, bot unnecessarily took its second trick.

In short: it prioritized making its bid over not losing the game.

Similar example: bot bids last in final round. Opps bid 5 in total. I bid 3. We need to bid 7 in total to win. Bags are not a factor. Bot bids 3. Opps cruise to easy win.

Summary: bot needs to take total score into consideration when bidding and playing.

By the way, I love trickster. Y'all do awesome work. I suspect this is probably quite complex. But, y'all are awesome and I hope you can eventually implement stuff like this.

antross commented 2 years ago

Thanks for the feedback @johnbent!

This would be a nice addition to the Spades bot. I'm not sure how quickly we'll be able to get to it, but if you're interested in giving it a try in the meantime (or anyone else is) we'd definitely review a pull request.

Bidding logic can be found here: https://github.com/TricksterCards/TricksterBots/blob/fcfb8c00730a0ce6e02aec8f0e8781eaf852131a/TricksterBots/Bots/Spades/SpadesBot.cs#L169

Card play logic can be found here: https://github.com/TricksterCards/TricksterBots/blob/fcfb8c00730a0ce6e02aec8f0e8781eaf852131a/TricksterBots/Bots/Spades/SpadesBot.cs#L640

johnbent commented 1 year ago

Thanks @antross for the reply.

I am definitely interested in messing with the code some. But, as you can see, I might not be super punctual about it. The current biggest stumbling block for me (aside from free time) is that it is not immediately obvious how I start working on it. I saw some mentions of TestBots in the top-level README. Is that the path?

What I would prefer (what would make it easiest for me) would be a way to run it locally with either 4 bots playing each other or with 3 bots playing and myself. And then the ability to view log files. As well as the ability to input starting deals. Then, I could add some logging statements and run it and make sure I was adding code in the right place by looking at the logs. Then create some starting deals and start looking at the bidding logic.

Another super cool thing would be to allow separate logic or preferences for the bots. Then the ability to auto-run say 1000 matches of bots vs bots and see whether something like a more aggressive set mentality on 10 bid tables would beat the current bots.

antross commented 1 year ago

Hey @johnbent, sorry I missed your most recent reply here.

The TestBots project is the easiest way to run unit tests, but there's no UI and it's mostly for setting up very specific scenarios. It's great for testing a fix for a particular issue, but not for playing full games. The current Spades bot tests live here: https://github.com/TricksterCards/TricksterBots/blob/main/TestBots/TestSpadesBot.cs. FYI, we have some slightly simpler ways to add new tests to some of our other bots I could look into porting here if you want to go this route.

For running locally where you can watch everything happen within a live game in the Trickster Cards interface, the WebAPI project is the way to go. You start the project in Visual Studio on your machine and it'll give you a link to connect your local changes into a live interface (described briefly at https://github.com/TricksterCards/TricksterBots#testing). In this setup, you're testing one local bot with your changes playing with/against the current production bots. Setup a Practice game and you can use our "Edit Deal" feature to manually configure specific starting deals.

Hopefully I won't miss any more GitHub notifications, but if needed you can also reach out to me via email. I'm "tony" on our domain (trickstercards.com).