GAME RULES You will play a two-player non-zero-sum extensive-form game on a complete binary tree of depth 8, where nodes in depths 0, 2, 4, 6 belong to one player and nodes in depths 1, 3, 5, 7 belong to the other player. (This means that the only thing that will vary is the payoffs in the 256 leaves of the tree.) TOURNAMENT RULES The participants of the tournament will be the programs of all the students (you) as well as several our programs (using various strategies). The tournament will consist of several million or billion rounds. In each round, the payoffs for both players in the 256 leaves will be generated (they are random non-negative 8-bit integers). Then, on this tree, every program will play against every other program in both orders (that is $n^2 - n$ games in total, where $n$ is the number of programs). The obtained payoffs are simply added up, and the program with the highest total payoff is the winner. 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: 4 examples of simple (and not very good) AIs You are expected to submit a cpp file similar to one of the four parts of sampleAIs.cpp. In particular, you implement the SOLUTION structure, which consists of 5 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. NR: This function is called at the beginning of each round. It gets the array of payoffs as a parameter. Payoff[t][i] is the payoff of player t (t=0 for the beginning player, i.e. the one who plays in even depths) in leaf i (marking 0 as left and 1 as right, the leaves are indexed from left to right; in other words, the binary representation of i corresponds to the path from the root to the leaf, the most-significant bit is the first edge (from the root of the tree)). AI: This function is called every time you are to decide, and also after the last move of the opponent (to let you know what he did). An even return value (e.g. 0) means you want to go to the left, an odd return value (e.g. 1) means you want to go to the right. In the last call (after the last move of the opponent), the return value is irrelevant (but do return a value!). The parameters are: op: the id of the current opponent depth: the depth of the current node path: the path from the root to the current node (only the $depth$ least-significant bits are relevant; again, the most-significant bit of them is the first edge (from the root of the tree)) We advise you not to use dynamic allocation (which would tremendously slow down your program) and use global variables/arrays instead. Please, declare all your global variables and functions (except the SOLUTION structure) as static so that their names do not collide with variables/functions of others. Your implementation should 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 NR function is under 1 millisecond (i.e. asymptotically linear time with respect to the size of the tree) the average running time of the AI function is under 1 microsecond (i.e. asymptotically constant time) 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 1 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, ...). We will try to give you the feedback by 5 December, so that you have about a week to fix/finish it. The hard deadline is on 11 December. At the last lecture, we will tell you the results of the tournament and a few words about the problem and what our strategies were like. MINIMAL REQUIREMENTS You must put a reasonable amount of effort into coming up with a sophisticated strategy and implement it. In particular, your strategy must be more sophisticated than the sample ones. On the other hand, we will not penalize you for a strategy that is based on a complex idea, correctly implemented, but turns out to be very poor in the tournament. BONUS ACHIEVEMENTS As has been said, you should try your best to win the tournament. If your program is really good, it may be taken into consideration during the final exam and Dominik and Tomáš may forgive you some part(s) of the homework set(s). 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. However, the sample AIs will not take part in the tournament, so if you write a strategy that tries to identify the behvaior and then play optimally against that, it will probably not yield any further points. 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 points as possible, while if they do not match, it plays so that the opponent gets as few points as possible. Of course, this is considered cheating. You must not cooperate with other (pairs of) students anyhow.