Commit 61661305 authored by alaskalinuxuser's avatar alaskalinuxuser
Browse files

added mobility counter

parent a7d24092
......@@ -172,23 +172,23 @@ vector<string> sepVect = split(boardPositions, ' ');
m_theBoard[second] = newPiece;
}
if (m_theBoard[first] == 'k' || m_theBoard[first] == 'K'){
cout << "King Move" << endl;
//cout << "King Move" << endl;
if (first == 4 && second == 6) {
// White Castles King Side
m_theBoard[7] = '-';
m_theBoard[5] = 'R';cout << "castleWKS" << endl;
m_theBoard[5] = 'R';//cout << "castleWKS" << endl;
} else if (first == 4 && second == 2) {
// White Castles Queen Side
m_theBoard[0] = '-';
m_theBoard[3] = 'R';cout << "castleWQS" << endl;
m_theBoard[3] = 'R';//cout << "castleWQS" << endl;
} else if (first == 60 && second == 62) {
// Black Castles King Side
m_theBoard[63] = '-';
m_theBoard[61] = 'r';cout << "castleBKS" << endl;
m_theBoard[61] = 'r';//cout << "castleBKS" << endl;
} else if (first == 60 && second == 58) {
// Black Castles Queen Side
m_theBoard[56] = '-';
m_theBoard[59] = 'r';cout << "castleBQS" << endl;
m_theBoard[59] = 'r';//cout << "castleBQS" << endl;
}
} // Not a king move.....
......
#include <sstream>
#include "Eval.h"
#include "Moves.h"
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <iostream>
#include <string>
Moves moveEvaluations;
int Eval::getEval(string thatBoard) {
int picoEval = 0;
......@@ -27,6 +28,25 @@ int Eval::getEval(string thatBoard) {
case 'p': picoEval-=10;break;
}} // End material evaluation.
// Mobility evaluation
string listMoves ="";
int deltaChange = 0;
try {
listMoves = moveEvaluations.available(thatBoard, true, false, false);
if (listMoves.size() == 0){
deltaChange -= 10000; } else {
deltaChange = deltaChange + listMoves.size()/5;
}
listMoves = moveEvaluations.available(thatBoard, false, false, false);
if (listMoves.size() == 0){
deltaChange += 10000; } else {
deltaChange = deltaChange - listMoves.size()/5;
}
} catch (...) {
cout << " Exception " << endl;
} // End try/catch block
//cout << deltaChange << " Delta " << endl;
picoEval += deltaChange;
return picoEval;
}
File added
......@@ -844,10 +844,10 @@ string Moves::bishopMovesB(string boardPositions, int i) {
// Need castle moves //
if (theBoard[60] == 'k') {
cout << "The king is on square 60" << endl;
//cout << "The king is on square 60" << endl;
if (theBoard[59] == '-' && theBoard[58] == '-' &&
theBoard[57] == '-' && theBoard[56] == 'r' && m_qcastle == true) {
cout << "Path is clear to castle queenside." << endl;
//cout << "Path is clear to castle queenside." << endl;
if (isKingSafe(theBoard, turn)) {
//The king is not in check, so...
theBoard[59] = 'k';
......@@ -862,7 +862,7 @@ string Moves::bishopMovesB(string boardPositions, int i) {
} //queenside
if (theBoard[61] == '-' && theBoard[62] == '-' &&
theBoard[63] == 'r' && m_Kcastle == true) {
cout << "Path is clear to castle kingside." << endl;
//cout << "Path is clear to castle kingside." << endl;
if (isKingSafe(theBoard, turn)) {
//The king is not in check, so...
theBoard[61] = 'k';
......@@ -1469,10 +1469,10 @@ string Moves::bishopMoves(string boardPositions, int i) {
// Need castle moves //
if (theBoard[4] == 'K') {
cout << "The king is on square 4" << endl;
//cout << "The king is on square 4" << endl;
if (theBoard[3] == '-' && theBoard[2] == '-' &&
theBoard[1] == '-' && theBoard[0] == 'R' && m_Qcastle == true) {
cout << "Path is clear to castle queenside." << endl;
//cout << "Path is clear to castle queenside." << endl;
if (isKingSafe(theBoard, turn)) {
//The king is not in check, so...
theBoard[3] = 'K';
......@@ -1487,7 +1487,7 @@ string Moves::bishopMoves(string boardPositions, int i) {
} //queenside
if (theBoard[5] == '-' && theBoard[6] == '-' &&
theBoard[7] == 'R' && m_Kcastle == true) {
cout << "Path is clear to castle kingside." << endl;
//cout << "Path is clear to castle kingside." << endl;
if (isKingSafe(theBoard, turn)) {
//The king is not in check, so...
theBoard[5] = 'K';
......@@ -1623,7 +1623,7 @@ string Moves::available(string boardPositions, bool whoseTurn, bool isPass, char
}
}}
//Debugging only //
cout << list << endl;
//cout << list << endl;
return list;
/*
* The list is in this format 1234,
......@@ -1640,7 +1640,7 @@ string Moves::plyMove(string boardPositions, bool whoseTurn, bool isPass, char e
int currentEval = 0;
if (candidateList.size() > 0){
currentEval = evaluations.getEval(boardPositions);
cout << "Current eval: " << " time " << (int)time(0) << " eval "<< currentEval << endl;
//cout << "Current eval: " << " time " << (int)time(0) << " eval "<< currentEval << endl;
int moveEval = 0;
int bestEval = currentEval;
for (int a = 0; a < 4; a++) {
......@@ -1658,7 +1658,7 @@ string Moves::plyMove(string boardPositions, bool whoseTurn, bool isPass, char e
boardPositions[second] = boardPositions[first];
boardPositions[first] = '-';
moveEval = evaluations.getEval(boardPositions);
cout << "Move eval: " << chosenMove << " eval " << moveEval << " places " << boardPositions << endl;
//cout << "Move eval: " << chosenMove << " eval " << moveEval << " places " << boardPositions << endl;
if (whoseTurn){
// White's turn, higher is better.
if ( moveEval > bestEval ) {
......@@ -1691,7 +1691,7 @@ string Moves::plyMove(string boardPositions, bool whoseTurn, bool isPass, char e
boardPositions[fourth] = boardPositions[third];
boardPositions[third] = '-';
int newMoveEval = evaluations.getEval(boardPositions);
cout << "Move eval: " << chosenMove << " eval " << moveEval << " places " << boardPositions << endl;
//cout << "Move eval: " << chosenMove << " eval " << moveEval << " places " << boardPositions << endl;
if (whoseTurn){
// White's turn, higher is better.
if ( newMoveEval > bestEval ) {
......
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment