X-Git-Url: https://git.ucc.asn.au/?p=progcomp2013.git;a=blobdiff_plain;f=agents%2Fsilverfish%2Fsilverfish.cpp;fp=agents%2Fsilverfish%2Fsilverfish.cpp;h=5ef044fda627e6247c4c557e121ae55e1004f56c;hp=20eb9e930f30a3d608f016e233c7ddd822974c56;hb=7a6c3dd98ba430b9bcdf95b7a92100cb7c0a1bbe;hpb=6632f3437f19a985d3b6b311b30bc1bafbca0002 diff --git a/agents/silverfish/silverfish.cpp b/agents/silverfish/silverfish.cpp index 20eb9e9..5ef044f 100644 --- a/agents/silverfish/silverfish.cpp +++ b/agents/silverfish/silverfish.cpp @@ -2,7 +2,15 @@ using namespace std; -Silver::Silver(const string & colour) : Agent(colour), values() + + +bool sort_scores(pair & a, pair & b) +{ + return a.second > b.second; +} + + +Silver::Silver(const string & colour, int new_max_depth) : Agent(colour), values(), max_depth(new_max_depth), depth(0), { values[Piece::PAWN] = 1; values[Piece::BISHOP] = 3; @@ -13,18 +21,64 @@ Silver::Silver(const string & colour) : Agent(colour), values() values[Piece::UNKNOWN] = 1.5; } -Silver::Silver(const string & colour, const map & new_values) : Agent(colour), values(new_values) +Silver::Silver(const string & colour, const map & new_values, int new_max_depth) + : Agent(colour), values(new_values), max_depth(new_max_depth), depth(0) { //TODO: Assert map is valid } +Move Silver::BestMove(Piece::Colour c) +{ + +} + Square & Silver::Select() { - return Agent::Select(); + + for (int x = 0; x < BOARD_WIDTH; ++x) + { + for (int y = 0; y < BOARD_HEIGHT; ++y) + { + Square & s = board.SquareAt(x,y); + + if (s.piece != NULL && s.piece.colour == colour) + continue; + + map m = board.SquareAt(x,y).Coverage(colour); + + for (map::iterator i = m.begin(); i != m.end(); ++i) + { + moves[i->first].push_back(pair + } + } + } + + for (map > >::iterator i = moves.begin(); i < moves.end() + } Square & Silver::Move() { - return Agent::Move(); + vector moves; + board.Get_moves(selected); +} + +double ScoreMove(Piece * p, Square & target) +{ + ++depth; + double score = 0.0; + if (target.piece == NULL) + score = 0.0 + else + score = 0.5*(values[target.piece->types[0]] + values[target.piece->types[1]]); + + if (depth < max_depth) + { + double recurse_score; + + BestMove(Piece::Opposite(p->colour)); + } + --depth; + return score; } \ No newline at end of file