204 lines
No EOL
5.2 KiB
JavaScript
204 lines
No EOL
5.2 KiB
JavaScript
|
|
(function() {
|
|
|
|
//var geometry = Model.Game.cbBoardGeometryCubic(4,5,3,["01","02","03","04","12","13","15","24","25","34","35","45"]);
|
|
var geometry = Model.Game.cbBoardGeometryCubic(4,4,4,["01","04","35","25"]);
|
|
|
|
Model.Game.cbDefine = function() {
|
|
|
|
return {
|
|
|
|
geometry: geometry,
|
|
|
|
pieceTypes: {
|
|
|
|
0: {
|
|
name: 'pawn-w',
|
|
aspect: 'pawn',
|
|
//graph: this.cbPawnGraph(geometry,1),
|
|
graph: this.cbAuthorGraph(geometry),
|
|
value: 1,
|
|
abbrev: '',
|
|
fenAbbrev: 'P',
|
|
epCatch: true,
|
|
},
|
|
|
|
1: {
|
|
name: 'ipawn-w',
|
|
aspect: 'pawn',
|
|
//graph: this.cbInitialPawnGraph(geometry,1),
|
|
graph: this.cbAuthorGraph(geometry),
|
|
value: 1,
|
|
abbrev: '',
|
|
fenAbbrev: 'P',
|
|
initial: [{s:1,p:0},{s:1,p:1},{s:1,p:2},{s:1,p:3},{s:1,p:12},{s:1,p:13},{s:1,p:14},{s:1,p:15}],
|
|
epTarget: true,
|
|
},
|
|
|
|
2: {
|
|
name: 'pawn-b',
|
|
aspect: 'pawn',
|
|
//graph: this.cbPawnGraph(geometry,-1),
|
|
graph: this.cbAuthorGraph(geometry),
|
|
value: 1,
|
|
abbrev: '',
|
|
fenAbbrev: 'P',
|
|
epCatch: true,
|
|
},
|
|
|
|
3: {
|
|
name: 'ipawn-b',
|
|
aspect: 'pawn',
|
|
//graph: this.cbInitialPawnGraph(geometry,-1),
|
|
graph: this.cbAuthorGraph(geometry),
|
|
value: 1,
|
|
abbrev: '',
|
|
fenAbbrev: 'P',
|
|
initial: [{s:-1,p:80},{s:-1,p:84},{s:-1,p:88},{s:-1,p:92},{s:-1,p:83},{s:-1,p:87},{s:-1,p:91},{s:-1,p:95}],
|
|
epTarget: true,
|
|
},
|
|
|
|
4: {
|
|
name: 'knight',
|
|
//graph: this.cbKnightGraph(geometry),
|
|
graph: this.cbAuthorGraph(geometry),
|
|
value: 2.9,
|
|
abbrev: 'N',
|
|
initial: [{s:1,p:8},{s:1,p:7},{s:-1,p:81},{s:-1,p:94}],
|
|
},
|
|
|
|
5: {
|
|
name: 'bishop',
|
|
//graph: this.cbBishopGraph(geometry),
|
|
graph: this.cbAuthorGraph(geometry),
|
|
value: 3.1,
|
|
abbrev: 'B',
|
|
initial: [{s:1,p:5},{s:1,p:9},{s:-1,p:85},{s:-1,p:86}],
|
|
},
|
|
|
|
6: {
|
|
name: 'rook',
|
|
//graph: this.cbCubicRookGraph(geometry),
|
|
graph: this.cbAuthorGraph(geometry),
|
|
value: 5,
|
|
abbrev: 'R',
|
|
initial: [{s:1,p:4},{s:1,p:11},{s:-1,p:82},{s:-1,p:93}],
|
|
//castle: true,
|
|
},
|
|
|
|
7: {
|
|
name: 'queen',
|
|
//graph: this.cbMergeGraphs(geometry,this.cbCubicRookGraph(geometry),this.cbBishopGraph(geometry)),
|
|
graph: this.cbAuthorGraph(geometry),
|
|
value: 9,
|
|
abbrev: 'Q',
|
|
initial: [{s:1,p:6},{s:-1,p:90}],
|
|
},
|
|
|
|
8: {
|
|
name: 'king',
|
|
isKing: true,
|
|
//graph: this.cbKingGraph(geometry),
|
|
graph: this.cbAuthorGraph(geometry),
|
|
abbrev: 'K',
|
|
initial: [{s:1,p:10},{s:-1,p:89}],
|
|
},
|
|
|
|
},
|
|
|
|
/*
|
|
promote: function(aGame,piece,move) {
|
|
if(piece.t==1)
|
|
return [0];
|
|
else if(piece.t==3)
|
|
return [2];
|
|
else if(piece.t==0 && geometry.R(move.t)==7)
|
|
return [4,5,6,7];
|
|
else if(piece.t==2 && geometry.R(move.t)==0)
|
|
return [4,5,6,7];
|
|
return [];
|
|
},
|
|
|
|
castle: {
|
|
"4/0": {k:[3,2],r:[1,2,3],n:"O-O-O"},
|
|
"4/7": {k:[5,6],r:[6,5],n:"O-O"},
|
|
"60/56": {k:[59,58],r:[57,58,59],n:"O-O-O"},
|
|
"60/63": {k:[61,62],r:[62,61],n:"O-O"},
|
|
},
|
|
*/
|
|
|
|
evaluate: function(aGame,evalValues,material) {
|
|
|
|
return;
|
|
|
|
// check lack of material to checkmate
|
|
var white=material[1].count;
|
|
var black=material[-1].count;
|
|
if(!white[0] && !white[1] && !white[4] && !white[5] && !white[6] && !white[7]) { // white king single
|
|
if(!black[2] && !black[3] && !black[6] && !black[7] && (black[4]+black[5]<2 || black[5]<2)) {
|
|
this.mFinished=true;
|
|
this.mWinner=JocGame.DRAW;
|
|
}
|
|
}
|
|
if(!black[2] && !black[3] && !black[4] && !black[5] && !black[6] && !black[7]) { // black king single
|
|
if(!white[0] && !white[1] && !white[6] && !white[7] && (white[4]+white[5]<2 || white[5]<2)) {
|
|
this.mFinished=true;
|
|
this.mWinner=JocGame.DRAW;
|
|
}
|
|
}
|
|
|
|
// check 50 moves without capture
|
|
if(this.noCaptCount>=100) {
|
|
this.mFinished=true;
|
|
this.mWinner=JocGame.DRAW;
|
|
}
|
|
|
|
// motivate pawns to reach the promotion line
|
|
var distPromo=aGame.cbUseTypedArrays?new Int8Array(3):[0,0,0];
|
|
var height=geometry.height;
|
|
var pawns=material[1].byType[0],pawnsLength;
|
|
if(pawns) {
|
|
pawnsLength=pawns.length;
|
|
for(var i=0;i<pawnsLength;i++)
|
|
switch(height-geometry.R(pawns[i].p)) {
|
|
case 2: distPromo[0]++; break;
|
|
case 3: distPromo[1]++; break;
|
|
case 4: distPromo[2]++; break;
|
|
}
|
|
}
|
|
pawns=material[-1].byType[2],pawnsLength;
|
|
if(pawns) {
|
|
pawnsLength=pawns.length;
|
|
for(var i=0;i<pawnsLength;i++)
|
|
switch(geometry.R(pawns[i].p)) {
|
|
case 1: distPromo[0]--; break;
|
|
case 2: distPromo[1]--; break;
|
|
case 3: distPromo[2]--; break;
|
|
}
|
|
}
|
|
if(distPromo[0]!=0)
|
|
evalValues['distPawnPromo1']=distPromo[0];
|
|
if(distPromo[1]!=0)
|
|
evalValues['distPawnPromo2']=distPromo[1];
|
|
if(distPromo[2]!=0)
|
|
evalValues['distPawnPromo3']=distPromo[2];
|
|
|
|
// motivate knights and bishops to deploy early
|
|
var minorPiecesMoved=0;
|
|
for(var t=4;t<=5;t++)
|
|
for(var s=1;s>=-1;s-=2) {
|
|
var pieces=material[s].byType[t];
|
|
if(pieces)
|
|
for(var i=0;i<pieces.length;i++)
|
|
if(pieces[i].m)
|
|
minorPiecesMoved+=s;
|
|
}
|
|
if(minorPiecesMoved!=0) {
|
|
evalValues['minorPiecesMoved']=minorPiecesMoved;
|
|
}
|
|
},
|
|
|
|
};
|
|
}
|
|
|
|
})(); |