ai_percent.cpp

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * Copyright (C) 2005 Eliot
00003  * Authors: Olivier Teuliere  <ipkiss@via.ecp.fr>
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation; either version 2 of the License, or
00008  * (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018  *****************************************************************************/
00019 
00020 #include "tile.h"
00021 #include "rack.h"
00022 #include "pldrack.h"
00023 #include "round.h"
00024 #include "results.h"
00025 #include "board.h"
00026 #include "ai_percent.h"
00027 
00028 
00029 AIPercent::AIPercent(int iId, float iPercent)
00030     : AIPlayer(iId), m_percent(iPercent)
00031 {
00032     // Ensure the decimal value of the percentage is between 0 and 1
00033     if (m_percent < 0)
00034         m_percent = 0;
00035     if (m_percent > 1)
00036         m_percent = 1;
00037 }
00038 
00039 
00040 void AIPercent::compute(const Dictionary &iDic, Board &iBoard, int turn)
00041 {
00042     m_results.clear();
00043 
00044     Rack rack;
00045     getCurrentRack().getRack(rack);
00046     m_results.search(iDic, iBoard, rack, turn);
00047 }
00048 
00049 
00050 bool AIPercent::changesLetters() const
00051 {
00052     return (m_results.size() == 0);
00053 }
00054 
00055 
00056 const Round & AIPercent::getChosenRound() const
00057 {
00058     int index = (int)(m_percent * (m_results.size() - 1));
00059     return m_results.get(index);
00060 }
00061 
00062 
00063 vector<Tile> AIPercent::getChangedLetters() const
00064 {
00065     return vector<Tile>();
00066 }
00067 
00068 /// Local Variables:
00069 /// mode: c++
00070 /// mode: hs-minor
00071 /// c-basic-offset: 4
00072 /// indent-tabs-mode: nil
00073 /// End:

Generated on Thu Dec 29 02:01:14 2005 for Eliot by  doxygen 1.4.5