[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Eliot-dev] Changes to eliot/game/ai_percent.cpp [antoine-1]
From: |
eliot-dev |
Subject: |
[Eliot-dev] Changes to eliot/game/ai_percent.cpp [antoine-1] |
Date: |
Sun, 23 Oct 2005 13:16:25 -0400 |
Index: eliot/game/ai_percent.cpp
diff -u /dev/null eliot/game/ai_percent.cpp:1.2.2.1
--- /dev/null Sun Oct 23 17:16:25 2005
+++ eliot/game/ai_percent.cpp Sun Oct 23 17:16:23 2005
@@ -0,0 +1,70 @@
+/*****************************************************************************
+ * Copyright (C) 2005 Eliot
+ * Authors: Olivier Teuliere <address@hidden>
+ *
+ * $Id: ai_percent.cpp,v 1.2.2.1 2005/10/23 17:16:23 afrab Exp $
+ *
+ * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *****************************************************************************/
+
+#include "tile.h"
+#include "rack.h"
+#include "pldrack.h"
+#include "round.h"
+#include "results.h"
+#include "board.h"
+#include "ai_percent.h"
+
+
+AIPercent::AIPercent(float iPercent)
+ : m_percent(iPercent)
+{
+ // Ensure the decimal value of the percentage is between 0 and 1
+ if (m_percent < 0)
+ m_percent = 0;
+ if (m_percent > 1)
+ m_percent = 1;
+}
+
+
+void AIPercent::compute(const Dictionary iDic, Board &iBoard, int turn)
+{
+ m_results.clear();
+
+ Rack rack;
+ getCurrentRack().getRack(rack);
+ m_results.search(iDic, iBoard, rack, turn);
+ m_results.sort_by_points();
+}
+
+
+bool AIPercent::changesLetters() const
+{
+ return (m_results.size() == 0);
+}
+
+
+const Round & AIPercent::getChosenRound() const
+{
+ int index = (int)(m_percent * (m_results.size() - 1));
+ return m_results.get(index);
+}
+
+
+std::vector<Tile> AIPercent::getChangedLetters() const
+{
+ return std::vector<Tile>();
+}
+
- [Eliot-dev] Changes to eliot/game/ai_percent.cpp [antoine-1],
eliot-dev <=