algorithm - Generic Alpha Beta Search with C++ -


I am trying to design a function template that looks for the best trick for any game - of course The user templates of this function are implementing certain game-specific tasks. What am I trying to do to normalize the alpha beta search algorithm with the function template?

The announcement of the templates of this function looks like this:

  template & lt; Class GameState, Class Move, Class Endgame, Class Evaluate, Classes Guestbook, Class Mekow) Alfa Betamax (GameTest G, Int alpha, Int beta, Int Dathbath);  

In addition to other things:

  • Determine that a game has ended: bool endgame (g)
  • Evaluate the status of a game: int evaluate (g)
  • Get the possible moves: std :: vector & lt; Move & gt; Tricks = Gatemov (G)
  • Make a move: gemstate gnew = macaw (g, move [i])

You can define an intangible interface Say Game_traits is a special game_state implementation for each game: < / P>

  template & lt; Typename game & gt; Class game_traits {...}; Class Chess {...}; The template's & lt; & Gt; Class game_trat & lt; Chess & gt; {Stable Bull End Game (Chess Games); ...}; Template & lt; Typename games, symptoms of typename = game_traits & lt; Games & gt; & Gt; Int alpha betamax (game game, int alpha, int beta, inti dathbath) {end = symptoms: endgame (game); ...}  

See char_traits in the C ++ standard library how it is used.

Alternatively, you can make them just ways of playing games, you don do not need a legacy from some abstract classes because you provide it as template logic. You will not find just one, perhaps even transparent when compiling the error, when your template tries to use the function, the game.has_ended () says, when such method does not exist This type of mechanism is also used in the standard template library.

BTW, a new plan was made for this; Concepts:

  Auto concept gametype & lt; Typename game & gt; {Bool is_range (game & amp;); ...}; Template & lt; Typename game & gt; Gametype & lt; Games & gt; Int alpha betamax (game game, int alpha, int beta, intensity depth) {bulls and games = has_ended (); ...}  

Unfortunately the concepts have been postponed for the future version of the standard and will not yet appear in c ++ 0x (


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -