Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- for ($i = 0; $i < 8; $i++) {
- for ($j = 0; $j < 8; $j++) {
- $field[$i][$j] = 'O';
- }
- }
- $x = rand(0,7);
- $y = rand(0,7);
- $field[$x][$y] = 'H';
- $pomX = $x + 1;
- $pomY = $y;
- while ($pomX < 8) {
- $field[$pomX][$pomY] = 'X';
- $pomX++;
- }
- $pomX = $x - 1;
- $pomY = $y;
- while ($pomX >= 0) {
- $field[$pomX][$pomY] = 'X';
- $pomX--;
- }
- $pomX = $x;
- $pomY = $y - 1;
- while ($pomY >= 0) {
- $field[$pomX][$pomY] = 'X';
- $pomY--;
- }
- $pomX = $x;
- $pomY = $y + 1;
- while ($pomY < 8) {
- $field[$pomX][$pomY] = 'X';
- $pomY++;
- }
- $pomX = $x + 1;
- $pomY = $y + 1;
- while ($pomX < 8 && $pomY < 8) {
- $field[$pomX][$pomY] = 'X';
- $pomY++;
- $pomX++;
- }
- $pomX = $x + 1;
- $pomY = $y - 1;
- while ($pomX < 8 && $pomY >= 0) {
- $field[$pomX][$pomY] = 'X';
- $pomY--;
- $pomX++;
- }
- $pomX = $x - 1;
- $pomY = $y - 1;
- while ($pomX >= 0 && $pomY >= 0) {
- $field[$pomX][$pomY] = 'X';
- $pomY--;
- $pomX--;
- }
- $pomX = $x - 1;
- $pomY = $y + 1;
- while ($pomX >= 0 && $pomY < 8) {
- $field[$pomX][$pomY] = 'X';
- $pomY++;
- $pomX--;
- }
- for ($i = 0; $i<8; $i++) {
- for ($j = 0; $j<8; $j++) {
- echo $field[$i][$j];
- }
- echo '<br />';
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment