Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 1.42 KB | None | 0 0
  1. def spacingFigures(board: Board, figures: Array[Figure]): Array[Board] = {
  2.     var boards = Array[Board]()
  3.     for (x1 <- 0 to board.size - 1) {
  4.       for (y1 <- 0 to board.size - 1) {
  5.         if (board.cells(x1)(y1).status == Free() && figures(0).validateCell(board, Cell(x1, y1, Free()))) {
  6.           println(x1 + "," + y1)
  7.           var board_tmp1 = board
  8.           figures(0).changeFields(board_tmp1, Cell(x1, y1, Free()))
  9.           for (x2 <- 0 to board.size - 1) {
  10.             for (y2 <- 0 to board.size - 1) {
  11.               if (board.cells(x2)(y2).status == Free() && figures(1).validateCell(board, Cell(x2, y2, Free()))) {
  12.                 println(x2 + "," + y2)
  13.                 var board_tmp2 = board
  14.                 figures(1).changeFields(board_tmp2, Cell(x2, y2, Free()))
  15.                 for (x3 <- 0 to board.size - 1) {
  16.                   for (y3 <- 0 to board.size - 1) {
  17.                     if (board.cells(x3)(y3).status == Free() && figures(0).validateCell(board, Cell(x3, y3, Free()))) {
  18.                       println(x3 + "," + y3)
  19.                       var board_tmp3 = board_tmp2
  20.                       figures(2).changeFields(board_tmp3, Cell(x3, y3, Free()))
  21.                       board_tmp3.printBoard
  22.                       boards ++= Array(board_tmp3)
  23.  
  24.                     }
  25.                   }
  26.                 }
  27.               }
  28.             }
  29.           }
  30.         }
  31.       }
  32.     }
  33.     boards
  34.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement