Exemple #1
0
         $modelGeneral->clearCache($queryChessCurrentMove, array($_SESSION['user']['id'], $_GET['id'], $move_id));
     }
     $curfen = $resultChessCurrentMove['move_fen'];
     $move = $resultChessCurrentMove['move'];
     $level = $resultChessCurrentMove['move_number'];
 } else {
     if (!empty($_GET['move']) && !empty($_GET['fen'])) {
         $curfen = $_GET['fen'];
     }
 }
 //pr($resultChess);
 //pr($resultChessMoves);
 //pr($resultChessCurrentMove);
 //Game meta start
 $standard = new Games_Chess_Standard();
 $standard->resetGame($curfen);
 $fen = $standard->renderFen();
 $toMove = $standard->toMove();
 //Game meta end
 //moves in db
 $movesInDb = array();
 if (!empty($resultChessMoves)) {
     foreach ($resultChessMoves as $v) {
         $movesInDb[] = $v['move'];
     }
 }
 //moves in db ends
 //legal moves started
 $legalMoves = getlegalmoves($standard, $fen);
 $copyLegalMoves = array();
 if (!empty($legalMoves['success'])) {
Exemple #2
0
<?php

require_once 'Connections/conn.php';
ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . realpath('PEAR'));
require_once 'Games/Chess/Standard.php';
include_once 'functions.php';
include_once 'Chess.class.php';
$time1 = microtime(true);
$moves = trim($_GET['moves']);
$standard = new Games_Chess_Standard();
$standard->resetGame();
if (!empty($moves)) {
    $tmp = explode('.', $moves);
    $tmp = array_slice($tmp, 1);
    foreach ($tmp as $k => $v) {
        $mv = explode(' ', $v);
        $white = !empty($mv[0]) ? clean($mv[0], $standard) : '';
        $standard->moveSAN($white);
        //pr($standard->getMoveList());
        $black = !empty($mv[1]) ? clean($mv[1], $standard) : '';
        if ($black == '') {
            break;
        }
        $standard->moveSAN($black);
        //pr($standard->getMoveList());
    }
}
$fen = $standard->renderFen();
$moves = $standard->getMoveList();
$toMove = $standard->toMove();
$moveby = 'W';
Exemple #3
0
<?php

require_once 'Connections/conn.php';
ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . realpath('PEAR'));
require_once 'Games/Chess/Standard.php';
include_once 'functions.php';
include_once 'Chess.class.php';
$chess = new Chess();
$rs = $chess->findpos('finalgames_B');
if ($rs[0] == 0) {
    echo 'no moves to play';
    exit;
}
$fen = !empty($rs[1]['fenpost']) ? $rs[1]['fenpost'] : NULL;
$standard = new Games_Chess_Standard();
$standard->resetGame($fen);
$toMove = $standard->toMove();
$fen = $standard->renderFen();
echo 'fen: ' . $fen . '<br>';
$moveby = 'W';
if ($toMove == 'W') {
    $moveby = 'B';
}
pr($rs);
if ($toMove == 'B') {
    $legalMoves = getlegalmoves($standard, $fen);
    pr($legalMoves);
    if (empty($legalMoves['success'])) {
        $result = $chess->findfen($fen, 'finalgames_B');
        if ($result[0] == 0) {
            $move = $chess->find($fen);
Exemple #4
0
        //pr($standard->getMoveList());
        $black = !empty($mv[1]) ? clean($mv[1], $standard) : '';
        if ($black == '') {
            break;
        }
        //echo 'White: '.$white.', black: '.$black.'<br>';
        $standard->moveSAN($black);
        //pr($standard->getMoveList());
    }
    $fen = $standard->renderFen();
    $moves = $standard->getMoveList();
    $toMove = $standard->toMove();
}
if (!empty($_POST['MM_Insert']) && $_POST['MM_Insert'] == 'fenplay') {
    $standard = new Games_Chess_Standard();
    $standard->resetGame($_POST['fen']);
    $fen = $standard->renderFen();
    $moves = $standard->getMoveList();
    $toMove = $standard->toMove();
    $moveby = 'W';
    if ($toMove == 'W') {
        $moveby = 'B';
    }
    //check db if fen occurs:
    $chess = new Chess();
    $result = $chess->findfen($fen, 'finalgames');
    $legalMoves = array();
    if ($result[0] == 0) {
        $move = $chess->find($fen);
        $from = substr($move, 0, 2);
        $to = substr($move, 2, 2);