辅导C GameTree留学生、讲解C程序、讲解国外

- 首页 >> C/C++编程


The new header comment for generate_level() is:

/*

      *      generate_level

      *      Generate the next level of the tree

      *      Pre-condition: the given tree and the given stack are

      *                             validly defined, i.e. not NULL pointers

      *      Post-condition: an additional level of possible moves has

      *                                 been added to the given game tree and each

      *                                 tree node of the new level also has been

      *                                 pushed onto the stack.  Each game state in

      *                                 the new level has a value calculated from

      *                                 the appropriate player's perspective (human

      *                                 if even numbered, computer if odd)

      *      Informally: generate the next level of the game tree

      *

      *      param t GameTree to create a level below

      *      param k Stack of reachable but unexpanded game trees

*/

The new header comment for build_game() is:

/*

      *      build_game

      *      Generate the game tree in a depth-first manner

      *      Pre-condition: the given game tree and stack are validly

      *                             defined (i.e. not NULL), and the given int

      *                             value represents the desired depth of

      *                             the tree

      *      Post-condition: if the given tree is empty then it is replaced

      *                                 with a new tree at level 0 comprising a new

      *                                 game (and this new tree is pushed onto the

      *                                 stack).  If the given tree isn't empty, the

      *                                 game isn't over, and the tree is not already

      *                                 deep enough, if there are existing children,

      *                                 then these are traversed and all are pushed

      *                                 onto the stack.  If (when) there are no

      *                                 children, an additional level of possible

      *                                 moves is added to the given game tree and each

      *                                 tree node of the new level also is pushed onto

      *                                 the stack.  Finally, the next tree is

      *                                 determined by removing the top of the stack

      *                                 and the process continues (recursively) until

      *                                 the stack is empty

      *      Informally: generate the game tree from the current point

      *                          in a depth-first manner until it is "d" levels

      *                          deep or the game is over

      *

      *      param t GameTree to build under

      *      param k Stack of reachable but unexpanded game trees

      *      param d desired depth (number of moves ahead) that game tree

      *                    should be built to

*/


站长地图