Research Article

Mining Experiential Patterns from Game-Logs of Board Game

Algorithm 7

PiecesDistanceCalculation.
Procedure  PiecesDistanceCalculation
Input:
 PS, the current pieces-state.
, piece .
, piece .
Output:
 Dab, the distance between and .
Method:
()let  CS be the checkers-state;
() let  vAllFC be a vector to store the falling checkers of every layer.
() //The maximum distance between and .
() Calculate the move distance MDab;
() if  MDab == 0 or  MDab == 1 or  MDab == 2 then
() //If MDab is less than 3, there is no less distance.
()  return  MDab;
() endif
() for = 0 to 9 do
() CS[PS⋅SAS[]⋅][PS⋅SAS[]⋅] = 1;
() CS[PS⋅SPS[]⋅][PS⋅SPS[]⋅] = −1;
() endfor
() FindVirtualFallingCheckers(0, CS, , , true, vAllFC, 0);
() isBreak = false; //Denotes the end of searching.
() Dab = MDab; //The distance in the worst case.
() for each allFC  in  vAllFC  do
() for each in  allFC do
()  if  allFC.index == (MDab −1) then
()   isBreak = true; break;
()  endif
()  if == and == then
()   Dab = allFC.index + 1; isBreak = true;
()   break;
()  endif
()  if  allFC.index == (MDab −2) then break; endif
()  FindVirtualFallingCheckers(0, CS, , , true, vAllFC, allFC.index + 1);
() endfor
() if  isBreak == true then break; endif
() endfor
() return  Dab;
() //Search the virtual falling checkers of specified checkers.
() Function FindVirtualFallingCheckers(, CS, , , isFirstStep, vAllFC, index)
() begin
() for = 3to−3 do
()  if == −  then continue; endif
()  if == 0 then continue; endif
()  Search the next jumping falling checker (, ) in direction of checker (, ).
()  if (, ) exists then
()   vAllFC[index].add(new Coordinate(, ));
()   FindVirtualFallingCheckers(3, CS, , , false, vAllFC, index);
()  else if the piece on (, ) is of own side then
()   FindVirtualFallingCheckers(3, CS, , , true, vAllFC, index + 1);
()  else
()   if  isFirstStep == true then
()     vAllFC[index].add(new Coordinate(, ));
()   endif
()  endif
() endfor
() end