Did something, apparently
[progcomp2013.git] / agents / silverfish / silverfish.cpp
1 #include "silverfish.h"
2
3 using namespace std;
4
5
6
7 bool sort_scores(pair<Square*, double> & a, pair<Square*, double> & b)
8 {
9         return  a.second > b.second;
10 }
11
12
13 Silver::Silver(const string & colour, int new_max_depth) : Agent(colour),  values(), max_depth(new_max_depth), depth(0),
14 {
15         values[Piece::PAWN] = 1;
16         values[Piece::BISHOP] = 3;
17         values[Piece::KNIGHT] = 3;
18         values[Piece::ROOK] = 5;
19         values[Piece::QUEEN] = 9;
20         values[Piece::KING] = 100;
21         values[Piece::UNKNOWN] = 1.5;
22 }
23
24 Silver::Silver(const string & colour, const map<Piece::Type, double> & new_values, int new_max_depth) 
25         : Agent(colour), values(new_values), max_depth(new_max_depth), depth(0)
26 {
27         //TODO: Assert map is valid
28 }
29
30 Move Silver::BestMove(Piece::Colour c)
31 {
32         
33 }
34
35 Square & Silver::Select()
36 {
37         
38         
39         for (int x = 0; x < BOARD_WIDTH; ++x)
40         {
41                 for (int y = 0; y < BOARD_HEIGHT; ++y)
42                 {
43                         Square & s = board.SquareAt(x,y);
44                         
45                         if (s.piece != NULL && s.piece.colour == colour)
46                                 continue;
47                         
48                         map<Piece*, double> m = board.SquareAt(x,y).Coverage(colour);   
49                         
50                         for (map<Piece*, double>::iterator i = m.begin(); i != m.end(); ++i)
51                         {
52                                 moves[i->first].push_back(pair<Square*, double>
53                         }
54                 }
55         }
56         
57         for (map<Piece*, vector<pair<Square*, double> > >::iterator i = moves.begin(); i < moves.end()
58         
59 }
60
61 Square & Silver::Move()
62 {
63         vector<Square*> moves;
64         board.Get_moves(selected);
65 }
66
67 double ScoreMove(Piece * p, Square & target)
68 {
69         ++depth;
70         double score = 0.0;
71         if (target.piece == NULL)
72                 score = 0.0
73         else
74                 score = 0.5*(values[target.piece->types[0]] + values[target.piece->types[1]]);
75         
76         if (depth < max_depth)
77         {
78                 double recurse_score;
79                 
80                 BestMove(Piece::Opposite(p->colour));
81         }
82         --depth;
83         return score;
84 }

UCC git Repository :: git.ucc.asn.au