当前位置: 首页>>代码示例>>PHP>>正文


PHP Board::add_horz_distance方法代码示例

本文整理汇总了PHP中Board::add_horz_distance方法的典型用法代码示例。如果您正苦于以下问题:PHP Board::add_horz_distance方法的具体用法?PHP Board::add_horz_distance怎么用?PHP Board::add_horz_distance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Board的用法示例。


在下文中一共展示了Board::add_horz_distance方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: reachable_squares

 function reachable_squares()
 {
     #Array of square where the piece can move to
     $squares = array();
     $csq = $this->get_current_square();
     $hdist = abs(Board::horz_distance("a1", $csq));
     $vdist = abs(Board::vert_distance("a1", $csq));
     $dist = $hdist > $vdist ? $vdist : $hdist;
     $sq = Board::add_horz_distance($csq, -$dist);
     $sq = Board::add_vert_distance($sq, -$dist);
     $squares = array_merge($squares, Board::squares_in_line($csq, $sq));
     $hdist = abs(Board::horz_distance("h1", $csq));
     $vdist = abs(Board::vert_distance("h1", $csq));
     $dist = $hdist > $vdist ? $vdist : $hdist;
     $sq = Board::add_horz_distance($csq, $dist);
     $sq = Board::add_vert_distance($sq, -$dist);
     $squares = array_merge($squares, Board::squares_in_line($csq, $sq));
     $hdist = abs(Board::horz_distance("a8", $csq));
     $vdist = abs(Board::vert_distance("a8", $csq));
     $dist = $hdist > $vdist ? $vdist : $hdist;
     $sq = Board::add_horz_distance($csq, -$dist);
     $sq = Board::add_vert_distance($sq, $dist);
     $squares = array_merge($squares, Board::squares_in_line($csq, $sq));
     $hdist = abs(Board::horz_distance("h8", $csq));
     $vdist = abs(Board::vert_distance("h8", $csq));
     $dist = $hdist > $vdist ? $vdist : $hdist;
     $sq = Board::add_horz_distance($csq, $dist);
     $sq = Board::add_vert_distance($sq, $dist);
     $squares = array_merge($squares, Board::squares_in_line($csq, $sq));
     #Removes current position square
     $squares = preg_grep("/^{$csq}\$/", $squares, PREG_GREP_INVERT);
     return $squares;
 }
开发者ID:iamdual,项目名称:phpcheckmate,代码行数:33,代码来源:Bishop.class.php

示例2: reachable_squares

 function reachable_squares()
 {
     #Array of square where the piece can move to
     $squares = array();
     $csq = $this->get_current_square();
     $tsq = Board::add_vert_distance($csq, 2);
     if ($tsq) {
         $sq = Board::square_right_of($tsq);
         if ($sq) {
             $squares[] = $sq;
         }
         $sq = Board::square_left_of($tsq);
         if ($sq) {
             $squares[] = $sq;
         }
     }
     $tsq = Board::add_vert_distance($csq, -2);
     if ($tsq) {
         $sq = Board::square_right_of($tsq);
         if ($sq) {
             $squares[] = $sq;
         }
         $sq = Board::square_left_of($tsq);
         if ($sq) {
             $squares[] = $sq;
         }
     }
     $tsq = Board::add_horz_distance($csq, 2);
     if ($tsq) {
         $sq = Board::square_up_from($tsq);
         if ($sq) {
             $squares[] = $sq;
         }
         $sq = Board::square_down_from($tsq);
         if ($sq) {
             $squares[] = $sq;
         }
     }
     $tsq = Board::add_horz_distance($csq, -2);
     if ($tsq) {
         $sq = Board::square_up_from($tsq);
         if ($sq) {
             $squares[] = $sq;
         }
         $sq = Board::square_down_from($tsq);
         if ($sq) {
             $squares[] = $sq;
         }
     }
     return $squares;
 }
开发者ID:iamdual,项目名称:phpcheckmate,代码行数:51,代码来源:Knight.class.php

示例3: reachable_squares

 function reachable_squares()
 {
     #Array of square where the piece can move to
     $squares = array();
     $csq = $this->get_current_square();
     $sq1 = Board::square_left_of($csq);
     if ($sq1) {
         $squares[] = $sq1;
         $sq2 = Board::square_up_from($sq1);
         if (defined($sq2)) {
             $squares[] = $sq2;
         }
         $sq2 = Board::square_down_from($sq1);
         if (defined($sq2)) {
             $squares[] = $sq2;
         }
     }
     $sq1 = Board::square_right_of($csq);
     if ($sq1) {
         $squares[] = $sq1;
         $sq2 = Board::square_up_from($sq1);
         if ($sq2) {
             $squares[] = $sq2;
         }
         $sq2 = Board::square_down_from($sq1);
         if ($sq2) {
             $squares[] = $sq2;
         }
     }
     $sq1 = Board::square_up_from($csq);
     if ($sq1) {
         $squares[] = $sq1;
     }
     $sq1 = Board::square_down_from($csq);
     if ($sq1) {
         $squares[] = $sq1;
     }
     $sq1 = Board::add_horz_distance($csq, 2);
     if ($sq1 && !$this->moved()) {
         $squares[] = $sq1;
     }
     $sq1 = Board::add_horz_distance($csq, -2);
     if ($sq1 && !$this->moved()) {
         $squares[] = $sq1;
     }
     return $squares;
 }
开发者ID:iamdual,项目名称:phpcheckmate,代码行数:47,代码来源:King.class.php

示例4: reachable_squares

 function reachable_squares()
 {
     #Array of square where the piece can move to
     $squares = array();
     $csq = $this->get_current_square();
     $x = Board::horz_distance("a4", $csq);
     $y = Board::vert_distance("d1", $csq);
     $row_start = 'a' . ($y + 1);
     $row_end = 'h' . ($y + 1);
     $col_start = chr(ord('a') + $x) . '1';
     $col_end = chr(ord('a') + $x) . '8';
     $row = Board::squares_in_line($row_start, $row_end);
     $col = Board::squares_in_line($col_start, $col_end);
     $squares = array_merge($squares, $row, $col);
     $hdist = abs(Board::horz_distance("a1", $csq));
     $vdist = abs(Board::vert_distance("a1", $csq));
     $dist = $hdist > $vdist ? $vdist : $hdist;
     $sq = Board::add_horz_distance($csq, -$dist);
     $sq = Board::add_vert_distance($sq, -$dist);
     $squares = array_merge($squares, Board::squares_in_line($csq, $sq));
     $hdist = abs(Board::horz_distance("h1", $csq));
     $vdist = abs(Board::vert_distance("h1", $csq));
     $dist = $hdist > $vdist ? $vdist : $hdist;
     $sq = Board::add_horz_distance($csq, $dist);
     $sq = Board::add_vert_distance($sq, -$dist);
     $squares = array_merge($squares, Board::squares_in_line($csq, $sq));
     $hdist = abs(Board::horz_distance("a8", $csq));
     $vdist = abs(Board::vert_distance("a8", $csq));
     $dist = $hdist > $vdist ? $vdist : $hdist;
     $sq = Board::add_horz_distance($csq, -$dist);
     $sq = Board::add_vert_distance($sq, $dist);
     $squares = array_merge($squares, Board::squares_in_line($csq, $sq));
     $hdist = abs(Board::horz_distance("h8", $csq));
     $vdist = abs(Board::vert_distance("h8", $csq));
     $dist = $hdist > $vdist ? $vdist : $hdist;
     $sq = Board::add_horz_distance($csq, $dist);
     $sq = Board::add_vert_distance($sq, $dist);
     $squares = array_merge($squares, Board::squares_in_line($csq, $sq));
     #Removes current position square
     $squares = preg_grep("/^{$csq}\$/", $squares, PREG_GREP_INVERT);
     return $squares;
 }
开发者ID:iamdual,项目名称:phpcheckmate,代码行数:42,代码来源:Queen.class.php


注:本文中的Board::add_horz_distance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。