summaryrefslogtreecommitdiff
path: root/resolvent.cpp
blob: 1aec568fc99729dc6d11833e4d048b7bc3286e2d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/*
 *  Quackle -- Crossword game artificial intelligence and analysis tool
 *  Copyright (C) 2005-2014 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 3 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, see <http://www.gnu.org/licenses/>.
 */

#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()
{
}