Advertisement
Guest User

CellsAdjacency.java

a guest
May 17th, 2021
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.72 KB | None | 0 0
  1. //  Sokoban brute solver.
  2. //  2021, May, B@R5uk
  3. //  Discussion: https://dxdy.ru/topic144781.html
  4.  
  5. import java.util.*;
  6.  
  7. public class CellsAdjacency {
  8.    
  9.     private int totalCellsNumber, activeCellsNumber;
  10.     /*
  11.         Array "values" consists of consecutive records for every possible transition
  12.         from cell to cell. Records for moves from same cell are placed one after another,
  13.         comprising blocks. Array "indices" holds starting indices of said blocks for
  14.         the same starting cell and for convenience contains one more index to denote
  15.         arrays "values" size.
  16.         Values record is a sequence of:
  17.         -   direction index (from CellVector class)
  18.         -   adjacent cell index
  19.         -   next adjacent cell index
  20.         -   rear adjacent cell index
  21.         Impassable and inactive next adjacent cells are assigned -1 index. Rear adjacent cells
  22.         are assigned -1 index if it is impassable or starting cell is inactive.
  23.     //*/
  24.     private short [] values;
  25.     private int   [] indices;
  26.    
  27.     public CellsAdjacency (int totalCellsNumber, int activeCellsNumber, short [] values, int [] indices) {
  28.         this .totalCellsNumber  = totalCellsNumber;
  29.         this .activeCellsNumber = activeCellsNumber;
  30.         this .values            = values;
  31.         this .indices           = indices;
  32.     }
  33.    
  34.     public int getTotalCellsNumber () {
  35.         return totalCellsNumber;
  36.     }
  37.    
  38.     public int getActiveCellsNumber () {
  39.         return activeCellsNumber;
  40.     }
  41.    
  42.     public short [] getValues () {
  43.         return Arrays .copyOf (values,  values  .length);
  44.     }
  45.    
  46.     public int [] getIndices () {
  47.         return Arrays .copyOf (indices, indices .length);
  48.     }
  49. }
  50.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement