TOURNAMENT RULES This year, we will have a tournament of AIs playing a simplified version of poker. Unlike standard poker, our game will be played with dice instead of cards. The tournament will consist of several millions of rounds. In each round, each pair of AIs will play one "deal" of the game. Each "deal" of the game consists of the following phases: the first player bets 1 chip (the small blind); the second player bets 2 chips (the big blind); a random integer B from the interval [3..18] is chosen and announced to both players; both players secretly roll their own die; the first player either folds (thereby losing the small blind) or raises to B; if the first player raises, the second player either folds (thereby losing the big blind) or calls; if the second player calls, showdown follows and the player with the higher number rolled wins (in case of a tie, the pot is split so that nobody wins or loses anything). Your task is to implement an AI which will play this game, trying to win as many chips as possible. IMPLEMENTATION DETAILS In the study materials, you can find the following files: tournament.cpp: the main code which simulates the tournament tournament.h: the header file which you should include in your cpp file sampleAIs.cpp: 5 examples of simple (and not very good) AIs You are expected to submit a cpp file similar to one of the 5 parts of sampleAIs.cpp. In particular, you implement the SOLUTION structure, which consists of 4 items: Name: the name of the strategy (e.g. your surname(s)) ShortName: the name shortened to 7 characters Init: You may implement an initialization function to do some precomputation and/or initialize your memory. This function will be called only once at the very beginning of the tournament. AI: This function is called every time you are to decide, and also after the showdown to inform you what the opponent has rolled. The parameters are: op: the id of the current opponent b: the current value of the game parameter B (how many chips a player bets) state: the current state of the "hand": an even number means that you are the first player (small blind), an odd number means that you are the second player (big blind); 0, 1 means you are to decide what to do; 2, 3 means your opponent has folded; 4, 5 means the game has come to a showdown d: when state = 0, 1, it says what you have rolled; when state = 4, 5, it says what your opponent has rolled The return value: zero means you want to fold, non-zero means you want to bet/call (relevant only when state = 0, 1; otherwise ignored) FURTHER IMPLEMENTATION NOTES You may call rand to make your strategy non-deterministic. Do not call srand (the seed setting function), that is our responsibility. The return value of the AI function is irrelevant when state >= 2, but DO return a value even in this case; otherwise the behavior is undefined and the program may crash. We advise you to use global variables/arrays (as demonstrated by the last sample AI) rather than dynamic allocation (which would only slow down the execution of your AI). In C/C++, all global memory is set to zero at the beginning of execution. This means you do not have to implement the initialization function at all if the only thing it would do is zeroing your global variables. Your implementation should (roughly) satisfy the following: it uses no more than 64 MB of memory the initialization function runs within 10 minutes the average running time of the AI function is under 1 microsecond (i.e. asymptotically constant time) These constraints are not hard, but if you exceed them significantly, we will tell you (after the soft deadline) that you must make your AI more efficient. If you have any further questions regarding the rules of the tournament or the specification, please look into the files. If you do not find the answer there, ask in the forum. DEADLINES There is a soft deadline on 20 December. By this day, you should submit an almost-final solution. We will look at it and tell you that it is OK or that there is some serious problem (it sometimes crashes, uses too much time/memory, ...). Then, you will have some time to make any improvements which you like to make or which we tell you that are necessary to make. The hard deadline will probably be in the first half of January. WHAT YOU ARE STRONGLY ENCOURAGED TO DO The tournament will be a society of miscellaneous strategies, so it is definitely a good idea to write a strategy that varies its behavior in response to the behavior of the opponent. You might even guess what strategies the others (or we) are going to write and write a strategy that is optimal against them. Note that it is not guaranteed that each of the sample AIs will take part in the tournament, so if you write a strategy that tries to identify their behvaior and then play optimally against them, it might not yield any further chips. Still, it may be a good idea to write such a strategy and run a practice tournament for yourself, just to make sure your ideas and implementation are correct. WHAT YOU ARE STRONGLY DISENCOURAGED TO DO There is a simple way to win the tournament if two programs cooperate: Program A plays some predetermined sequence in the first (say) 100 moves and then plays some very good strategy. For each opponent, program B looks at the first 100 moves of the opponent, and if they match the predetermined sequence, it plays so that the opponent gets as many chips as possible, while if they do not match, it plays so that the opponent gets as few chips as possible. Of course, this is considered cheating. You must not cooperate with other (pairs of) students anyhow.