Project

General

Profile

« Previous | Next » 

Revision 9ba7f3f6

Added by Leszek Koltunski over 1 year ago

Move scrambling to a new model where there are spearete scrambling 'algorithms' and 'edges' of the scrambling graph.
Now each edge can contain a whole algorithm, i.e. a sequence of moves leading from state to state, which permits construction of scrambling for more complicated bandaged objects such as the AI cube.

Unchecked as of yet, probably still a lot of bugs.

View differences:

src/main/java/org/distorted/objectlib/json/JsonWriter.java
486 486
    {
487 487
    JSONObject scrambling = new JSONObject();
488 488

  
489
    ScrambleState[] states = object.getScrambleStates();
490 489
    int scrambleType = object.getScrambleType();
491 490
    scrambling.put("scrambleType",scrambleType );
491
    int[][] algorithms = object.getScrambleAlgorithms();
492 492

  
493
    if( states!=null )
493
    if( algorithms!=null )
494 494
      {
495
      JSONArray scrambleStates = new JSONArray();
495
      JSONArray scrambleAlgorithms = new JSONArray();
496 496

  
497
      for(ScrambleState state : states)
497
      for(int[] algorithm : algorithms)
498 498
        {
499
        JSONArray axisArray = new JSONArray();
500
        int numAxis = state.getNumAxis();
499
        JSONArray algArray = new JSONArray();
500
        for (int entry : algorithm) algArray.put(entry);
501
        scrambleAlgorithms.put(algArray);
502
        }
501 503

  
502
        for(int ax=0; ax<numAxis; ax++)
503
          {
504
          JSONArray axArray = new JSONArray();
505
          int[] axData = state.getAx(ax);
504
      scrambling.put("algorithms", scrambleAlgorithms);
505
      }
506 506

  
507
          if( axData!=null )
508
            for(int data : axData) axArray.put(data);
507
    int[][] edges = object.getScrambleEdges();
509 508

  
510
          axisArray.put(axArray);
511
          }
509
    if( edges!=null )
510
      {
511
      JSONArray scrambleEdges = new JSONArray();
512 512

  
513
        scrambleStates.put(axisArray);
513
      for(int[] edge : edges)
514
        {
515
        JSONArray edgeArray = new JSONArray();
516
        for (int entry : edge) edgeArray.put(entry);
517
        scrambleEdges.put(edgeArray);
514 518
        }
515 519

  
516
      scrambling.put("scrambleStates", scrambleStates);
520
      scrambling.put("edges", scrambleEdges);
517 521
      }
518 522

  
519 523
    return scrambling;

Also available in: Unified diff