Making Computers Think Like Auction Players

Last week, RPGnet released the second of my iPhone games, an adaptation of Reiner Knizia’s High Society. To celebrate its release, I’ve opted today to continue my series of articles talking about adapting tabletop games to computers with a look at artificial intelligence and how the computer players in High Society “think”.

The State of the Art

So, how do you make a computer think like a human player? Today, it’s still somewhat hard to tell a computer to emulate the intuitive, off-the-cuff things that a player might do when playing a game. Surprisingly it’s even hard to write a good algorithm that thoroughly examines gameplay and makes a best choice; what a human does without even thinking has to be painfully programmed decision-by-decision into an Artificial Intelligence (AI).

Even with all of that, you’re not necessarily going to have a good AI. Becauase there are some things that humans will do better than computers, the only way to really make computers reliable is to make sure they take advantage of the things they do better than humans.

I’m going to entirely ignore the computer AIs that simply cheat: with more money, more troops, access to hidden information, or whatever. It’s a poor man’s solution to AI, though sadly one that’s been used a lot over the years.

Beyond that, what’s probably the most common “state of the art” way to program AI is to make it compute. A Lot. A standard tool of the trade is a Monte Carlo Simulation, which turns up most frequently in card games. Typically, a computer looks at its selection of cards and then runs hundreds of thousands of simulations, each time assuming that different players have different (hidden) cards and that it plays its own cards in different ways. Afterward the AI looks at all its simulations, sees what did best the most often, and chooses that play.

The Monte Carlo Simulation is a simple methodology, a very powerful one, and in my opinion a very inhuman one, too. I’ve played games that I loved that used it, and I’ve also played games that sucked because their Monte Carlo Simulation took too long. (Very disappointing El Grande PC game, I’m talking to you.)

The State of My Knizia Games

Don’t get me wrong, a Monte Carlo simulation is absolutely necessary for games that reach a certain level of complexity. I don’t think that  or Tichu could be done well without them. But in working on my own Knizia games, High Society and Money, I’ve striven for a different attribute in my AIs: humanity.

I want you to be able to play “Dan” and say, “Yeah, that’s the idiot.” I want you to be able to play “Finn” and says, “He’s the guy that sometimes overdefends a winning position and ends up going low on money as a result.” I’m not sure how much of that really gets across — as there are real problems with getting through the interface of the computer screen to identify opponents as unique individuals — but the goal has led me to program my AIs in very different, and very human manners.

So this week I’m going to talk a bit about how I put together the High Society AIs. I’m going to keep things somewhat abstract, so as not to spoil your playing against them, but I hope I can offer enough detail to make them interesting. If you need a refresher about how High Society works, you should read my review of the game.

In High Society you’re constantly offered one choice: What do I bid for this item? But it’s more subtle than that. I think the bidding question can be broken up into at least the following components:

  • What’s the minimum amount you must bid for the card? (e.g., more than the last person)
  • What’s the maximum value you place on the item?
  • What’s the minimum amount of money you want left afterward, to make sure that you don’t end up in last place? Does this downgrade your maximum valuation?
  • What’s the amount you feel you should bid (between the minimum and the maximum) to discourage later bidders without potentially wasting money by bidding too high?
  • How can you tweak that bid amount to make optimal use of your cards, maintaining your flexibility for later rounds?

Put all that together and you have a pretty good outline of how the AI in High Society actually works. There are no Monte Carlo simulations and no iterating between different policies, just some firm boundaries on what should be paid when.

To the right you’ll find a picture of what the AIs actually look like in my code. Three variables (cardSelection, value, and aggressiveness) together define an AI’s play within the above parameters. Notably, things are set up so that I can mix and match the variables as I see fit. That’s not done (currently) in High Society, but some of the AIs in Money share strategies in exactly these ways.

It’s by defining these three variables that I (hopefully) make the AIs in High Society human and unique. One always bids the minimum amount while another tends to make jumps to avoid spending his low-value bills. A third makes a jump, but then settles on an exact bid that uses a minimal set of bills. Two of the AIs are extra worried about the bad cards that you can get stuck with. Beyond that, they all have different methods for evaluating card values and deciding how low they can go.

However, humanizing the AIs took more than just these simple algorithms. I also tried to think about how auction players think, to make the AIs react in understandable ways. Thus, the AIs get frustrated if they keep losing and tend to bid higher after a string of losses. They also tend to rest on their laurels a bit after they’ve won.

One thing that I’ve considered but never gotten around to is “bid fever,” where the theory is that some or all of the AIs should get more likely to stay in an auction when they’re engaged in an adrenaline-pumping auction with one other player.

As I said at the start, I don’t know if this all makes the AIs actually recognizable to the players, but I certainly hope that it pushes things in the right direction.

Letting Computers Be Computers

I noted earlier that one of the prime ways to make AIs good is to make sure they do things that computers are good at. This has led me introduce another trait into the High Society AIs that may not necessarily be human, but which lets them balance their own shortcomings. Some of the AIs are card counters. They don’t know any hidden info, but they do track the luxuries that people are buying and/or the money that players have spent.

This ended up exposing a bit of a rough spot in the tabletop game. It was actually possible to program the AIs to never lose. All they had to do was never let their total money drop below every other players and to manage every single auction with that in mind. Mind you, that isn’t a winning strategy either: If everyone refuses to spend money in High Society the game always ends with every player being eliminated. But it was something to consider when programming the AI. As it happens, one AI does count money and never spends enough money to be the last-place player; that can make that AI strong at times, but the other AIs use different — perhaps better — methods to measure how low their cash should go.

Even when you’re letting your AIs be AIs, you shouldn’t over-do it. Playing against a perfect card counter usually isn’t much fun. Thus the High SocietyAIs might make mistakes when counting. The lower the difficulty level for the AI, the more likely the AI doesn’t have an exactly perfect grasp of money (or score, for that matter).

Around the Corner

I hope you’ve enjoyed a look at some of the thoughts that went into making the iPhone High Society AI players play like humans. I’ll again note that you can get both Reiner Knizia’s High Society and Reiner Knizia’s Money from the iPhone App store.

As for what else I’ve been doing lately: I’ve started in on our next iPhone game, which is Reiner Knizia’s Kingdoms. Meanwhile, my one RPGnet review of the last two weeks was of Reiner Knizia’s Swat.

This article copyright © 2010, Skotos Tech Inc.


Author’s Note: I did make a slight substantive change to this article by updating my old list of AI characteristics (which was non-intuitive), to my new methdology (which allows intuitive names to be associated with AI strategies). But that was mainly because I couldn’t find my original picture that went with this article.

High Society has always been our lowest-selling Reiner Knizia iPhone game, which surprised me at first because we choose it so that we’d have an award-winner among our first three. I later came to the conclusion that some games make better iPhone conversions than others, which I wrote about in my next article about iPhone programming. Mind you, I still think High Society is a very nice adaptation of the tabletop game. —2/4/11, 6/22/12

Liked it? Take a second to support Shannon Appelcline on Patreon!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.