summaryrefslogtreecommitdiff
path: root/resolvent.cpp
diff options
context:
space:
mode:
authorJason Katz-Brown <jason@airbnb.com>2013-08-25 02:17:13 -0700
committerJason Katz-Brown <jason@airbnb.com>2013-08-25 02:17:13 -0700
commit9306cb60c32082c5403931de0823a9fd5daa196c (patch)
treeca1b6eb695fdf3f0c2294e92416b272164bae642 /resolvent.cpp
parent8fb2c681cecc01b46b0f4ba02d5cc177c4747b1c (diff)
Initial git commit.
Diffstat (limited to 'resolvent.cpp')
-rw-r--r--resolvent.cpp127
1 files changed, 127 insertions, 0 deletions
diff --git a/resolvent.cpp b/resolvent.cpp
new file mode 100644
index 0000000..63d8122
--- /dev/null
+++ b/resolvent.cpp
@@ -0,0 +1,127 @@
+/*
+ * Quackle -- Crossword game artificial intelligence and analysis tool
+ * Copyright (C) 2005-2006 Jason Katz-Brown and John O'Laughlin.
+ *
+ * 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 Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#include <iostream>
+#include <time.h>
+
+#include "bogowinplayer.h"
+#include "endgameplayer.h"
+#include "preendgame.h"
+#include "resolvent.h"
+
+using namespace Quackle;
+
+Resolvent::Resolvent()
+{
+ m_name = MARK_UV("Resolvent");
+ m_id = 201;
+}
+
+Resolvent::~Resolvent()
+{
+}
+
+Move Resolvent::move()
+{
+ return moves(1).back();
+}
+
+MoveList Resolvent::moves(int nmoves)
+{
+ // UVcout << "Resolvent generating move from position:" << endl;
+ // UVcout << m_simulator.currentPosition() << endl;
+
+ ComputerPlayer *delegatee;
+
+ if (m_simulator.currentPosition().bag().empty())
+ {
+ // Case 1: Straight endgame.
+ delegatee = new EndgamePlayer;
+ }
+ else if (currentPosition().bag().size() <= Preendgame::maximumTilesInBagToEngage())
+ {
+ // Case 2: Preendgame.
+ delegatee = new Preendgame;
+ }
+ else
+ {
+ // Case 3: Beginning and middle of the game.
+ delegatee = new SmartBogowin;
+ }
+
+ delegatee->setParameters(parameters());
+ delegatee->setDispatch(currentPosition().nestedness() > 0? 0 : m_dispatch);
+ delegatee->setPosition(m_simulator.currentPosition());
+ delegatee->setConsideredMoves(m_simulator.consideredMoves());
+ MoveList moves = delegatee->moves(nmoves);
+ delete delegatee;
+
+ return moves;
+}
+
+bool Resolvent::isSlow() const
+{
+ return true;
+}
+
+InferringPlayer::InferringPlayer()
+{
+ m_name = MARK_UV("Inferring Player");
+ m_id = 2012;
+ m_parameters.secondsPerTurn = 20;
+ m_parameters.inferring = true;
+}
+
+InferringPlayer::~InferringPlayer()
+{
+}
+
+TorontoPlayer::TorontoPlayer()
+{
+ m_name = MARK_UV("Championship Player");
+ m_id = 2006;
+ m_parameters.secondsPerTurn = 66;
+}
+
+TorontoPlayer::~TorontoPlayer()
+{
+}
+
+FiveMinutePlayer::FiveMinutePlayer()
+{
+ m_name = MARK_UV("Five Minute Championship Player");
+ m_id = 5208;
+ m_parameters.secondsPerTurn = 60 * 5;
+}
+
+FiveMinutePlayer::~FiveMinutePlayer()
+{
+}
+
+TwentySecondPlayer::TwentySecondPlayer()
+{
+ m_name = MARK_UV("Twenty Second Championship Player");
+ m_id = 5209;
+ m_parameters.secondsPerTurn = 20;
+}
+
+TwentySecondPlayer::~TwentySecondPlayer()
+{
+}