/* This file is part of cardwords
   (c) 1998 1999 Tobias Peters
   see file COPYING for the copyright terms.
   
   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 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
*/

// cardwords_dicbot_bestordergenerator.hh

/* This file defines the class CardWords_DicBot_BestOrderGenerator.
   The purpose of this class is to find the best way to lay a
   special word with a given set of cards on a given part of the
   table.

   This is now done in a very small class because there is one optional
   return value that is only returned when asked for, therefore it must be
   stored somewhere (in the object instance). All needed data is accessible
   in the classes CardWords_DicBot_CardTableRequirements and
   CardWords_DicBot_CardSelectionContents. It would be possible to simply make
   CardWords_DicBot_BestOrderGenerator a member of one of these classes, but
   it is not apparent, wich one to take.

   When all accessing methods of these objects are inlined, it does not hurt
    CardWords_DicBot_BestOrderGenerator being a distinct class.
*/

#ifndef CARDWORDS_DICBOT_BESTORDERGENERATOR_HH
#define CARDWORDS_DICBOT_BESTORDERGENERATOR_HH

#include "cardwords_dicbot_cardselectioncontents.hh"
#include "cardwords_string.hh"
#include "cardwords_dicbot_cardtablerequirements.hh"

class CardWords_DicBot_BestOrderGenerator :
  // the optional data that can be asked for: It's a card selection that can
  // be casted to a move. Its the base class.
  public CardWords_CardSelection 
{
  // configurational data:

  // Set this to true when you don't want to use your wildcards for a word
  // even if you could achieve a higher score when you replace a normal card
  // through a wildcard.
  bool never_use_wildcards_when_unnecessary;

  // Set this to true when you want to use your wildcards in a situation where
  // it would not matter if you use the wildcard or the normal card. Unlikely,
  // isn't it?
  bool prefer_wildcards_when_same_score;

  // Set this to true if you think it's great to lay a high score card on a
  // cell where it counts 0 (nothing). This would make sense if you have a
  // table with most letter factors < 0.
  bool null_is_good;

public:
  CardWords_DicBot_BestOrderGenerator()
    : never_use_wildcards_when_unnecessary (false),
      prefer_wildcards_when_same_score     (false),
      null_is_good                         (false)
    {}
  CardWords_DicBot_BestOrderGenerator(bool ne, bool pr, bool nu)
    : never_use_wildcards_when_unnecessary (ne),
      prefer_wildcards_when_same_score     (pr),
      null_is_good                         (nu)
    {}
  
  // this is the do_it function:
  // Its return value is an int, the max score that can be achieved laying
  // this word and obeying the 3 rules above. This is not the real score that
  // this move reaches, but scores of words with same length and same table
  // position/direction are compareable.
  int
  operator () (const CardWords_String &, // The word to lay
               size_t remaining_wildcards, //the number of wildcards not ne-
               //                            cessarily used.
               const CardWords_DicBot_CardSelectionContents & tsc,
               const CardWords_DicBot_CardTableRequirements & req);
};
#define BEST_ORDER_GENERATOR_DEFINED
#endif
