Advertisement
Guest User

CellsAdjacency.java

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