/**********************************************************************
 *
 *   FreeDoko a Doppelkopf-Game
 *    
 *   Copyright (C) 2001-2003  by Diether Knof and Borg Enders
 *
 *   This program is free software; you can redistribute it and/or 
 *   modify it under the terms of the GNU General Public License as 
 *   published by the Free Software Foundation; either version 2 of 
 *   the License, or (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details. 
 *   You can find this license in the file 'gpl.txt'.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program; if not, write to the Free Software
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
 *   MA  02111-1307  USA
 *
 *  Contact:
 *    Diether Knof dknof@gmx.de
 *    Borg Enders  borg@borgsoft.de
 *
 *********************************************************************/

#ifndef CLASS_GAMETREE_HEADER
#define CLASS_GAMETREE_HEADER

#include "../../card/hand.h"
class VirtualGamesInterface;
typedef VirtualGamesInterface GametreeInterface;
class Trick;

/**
 **
 ** tries all possibilities to play and take the card with the maximal
 ** worst card (max-min).
 ** In contrary to 'VirtualGames' a following player does not decide his
 ** card but all cards are tested.
 **
 ** @author     Diether Knof
 **
 **/
class Gametree {
  public:
    // constructor
    Gametree(GametreeInterface const& gametree_interface,
	     unsigned const future_limit,
	     bool const with_heuristics);
    ~Gametree();

    // the ai
    GametreeInterface const& gametree_interface() const;

    // the end depth
    unsigned const& end_depth() const;


    // choose the best card for the ai
    Card best_card() const;


  private:
    // calculates and sets the end depth
    unsigned const& end_depth_calculate(unsigned future_limit);

    // returns the maximal minimum modi
    int maxmin_modi(Game& virt_game, unsigned const tricks_to_calc) const;

    // returns the weighting of the trick for 'team'
    int modi(Trick const& trick, Team const& team, Card const& card) const;

  private:
    // the interface for virtual games
    GametreeInterface const* const gametree_interface_;

    // how many tricks to calc in the future
    unsigned end_depth_;
    // whether to use heuristics
    bool with_heuristics;

  private: // not implemeted
    Gametree();
    Gametree(Gametree const&);
    Gametree& operator=(Gametree const&);
}; // class Gametree 

#endif // #ifndef CLASS_GAMETREE_HEADER
