/**
  * 2回目以降の呼び出しは、こっちのメソッドで実施する
  * @test
  */
 public function testRetObjectivePoint2()
 {
     $boardBeginCell = array(0, 0);
     $boardEndCell = array(6, 5);
     $aimUpperLeftInstance = new ObjectivePointDeciderConcrete(array(3, 3), $boardBeginCell, $boardEndCell);
     $expectedRet = $aimUpperLeftInstance->retObjectiveCell(array(3, 3), array());
     $actualRet = $aimUpperLeftInstance->retObjectiveCell(array(1, 2), array());
     $this->assertSame($expectedRet, $actualRet);
 }
示例#2
0
文件: main.php 项目: th1209/codingame
    $gameRounds[] = $gameRound;
    //1,2,3と増えていく
    fscanf(STDIN, "%d %d %d", $x, $y, $backInTimeLeft);
    $myPositions[$gameRound] = array('x' => $x, 'y' => $y, 'useBackInTime' => $backInTimeLeft);
    for ($i = 0; $i < $opponentCount; $i++) {
        fscanf(STDIN, "%d %d %d", $opponentX, $opponentY, $opponentBackInTimeLeft);
        $opponentsPositions[$gameRound][$opponentCount] = array('x' => $opponentX, 'y' => $opponentY, 'useBackInTime' => $opponentBackInTimeLeft);
    }
    for ($i = 0; $i < 20; $i++) {
        fscanf(STDIN, "%s", $line);
        $boards[$gameRound][$i] = str_split($line);
        //str_split:eachchar(string) -> array
    }
    /* インスタンス初回生成 */
    if (!isset($objectivePointDecider)) {
        $objectivePointDecider = new ObjectivePointDeciderConcrete(array($x, $y), array(X_BEGIN, Y_BEGIN), array(X_END, Y_END));
    }
    if (!isset($directionCellChanger)) {
        $directionCellChanger = new DirectionCellChangerConcrete();
    }
    /* ロジック */
    list($destX, $destY) = $objectivePointDecider->retObjectiveCell(array($x, $y), $boards[$gameRound]);
    list($destX, $destY) = $directionCellChanger->changeNextCell(array($x, $y), array($destX, $destY), $boards[$gameRound]);
    /* 結果の出力 */
    echo "{$resultX} {$resultY}\n";
    //     $x = 34;
    //     $y = 19;
    //    echo("$x $y\n"); // action: "x y" to move or "BACK rounds" to go back in time
}
// Write an action using echo(). DON'T FORGET THE TRAILING \n
// To debug (equivalent to var_dump): error_log(var_export($var, true));