讲解:GAME RULES、C/C++、binary tree、C/C++Python|Haskell

GAME RULESYou 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 RULESThe 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 againstevery 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 DETAILSIn 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) AIsYou 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) 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-sign代写GAME RULES作业、代写C/C++程序设计作业、代做binary tree作业、代写C/C++作业 代做Pytificant 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 staticor enclose them within your own namespace 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.DEADLINESThere is a soft deadline on 19 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 before Christmas. The hard deadline is on 6 January.MINIMAL REQUIREMENTSYou 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 notpenalize you for a strategy that is based on a complex idea, correctly implemented, but turns out to be very poor in the tournament.WHAT YOU ARE STRONGLY ENCOURAGED TO DOThe tournament will be a society of miscellaneous strategies, so it is definitely a good idea to writea 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 writeand write a strategy that is optimal against them.WHAT YOU ARE STRONGLY DISENCOURAGED TO DOThere 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 sothat the opponent gets as few points as possible.Of course, this is considered cheating. You must not cooperate with other students anyhow.转自:http://ass.3daixie.com/2019010861261967.html

你可能感兴趣的:(讲解:GAME RULES、C/C++、binary tree、C/C++Python|Haskell)