2020-07-01 15:19:53

Hello folks. So, I wanted to start practicing my coding skills with somethin simple. I came up with my own rendition of one thousand miles. I managed to get through everything, with 1 acception. I wanted the player to be able to select up to 5 computer players, but I have no idea about how to do that. Or assign variables for the bots.
Currently, I have a integer variable for the cards in the player's hand, and a boolean to check if the conditions to use said cards are met. I also have a boolean to check to see if the player has any nerfs or buffs, then an if statement to match accordingly. My questions are how do I go about creating AI to play against, and how do I assaign the same variables to the bots? I could just write up variables for up to 5 players, and just have a boolean to cancel out the other variables.
I don't want code, only logic. Thanks alot guys.

You ain't done nothin' if you ain't been cancelled
_____
I'm working on a playthrough series of the space 4X game Aurora4x. Find it here

2020-07-01 15:35:36

First, ask yourself: what are the cards that one should always play when they have them? Define the rules, if you will.
Second, ensure that your rules follow proper game logic, for example, make sure that a player cannot experience an accident twice.
Third, translate it into code. If you have your rules, and you have the proper prevention conditions, it should be as simple as going down the list of priorities in each hand and deciding what is best car to play, minmax if you will.

2020-07-01 15:50:44

Also making a class that represents a participant with functions to do all the things a participant can do, then inheriting from that for player (to connect the controls) and computer (to connect the AI) will go a long way here.  I.e. a function to list cards, and the player's UI uses it to display a menu, but the computer uses it to know what it can play.  The primary key insight that makes  this go from hard to easy is realizing that game entities are separate from whatever controls them, and coding that way instead.

I don't know the rules of this game but minmax is probably overkill and is also difficult to code, so unless this is Python or something where you can find a library, just writing "If I have this card then play it" a bunch of times might be best.

The other thing people tend to miss when talking about this stuff: you can get a library for minmax, or for astar, or whatever, and apply it (and yes, astar can apply to card games).  But if you do so you might make the computer unbeatable.  For many card and board games, the number of possible moves is small enough and the rules restricted enough that it's relatively easy for the computer to play a "perfect" game, always.

My Blog
Twitter: @ajhicks1992