public static long[] setup(String moves_text) {

    LogFile.message(moves_text);

    ArrayList<Long> banned_positions = new ArrayList<Long>();

    // Place each move in a separate token
    moves_text = moves_text.replaceAll("%13", "@");
    StringTokenizer tokenizer = new StringTokenizer(moves_text, "@");

    // Check if there are some moves
    if ( tokenizer.countTokens() < 2 ) {
      return new long[0];
    }

    GameState gs = new GameState(tokenizer.nextToken(), tokenizer.nextToken());
//    System.out.println(gs);

    // Add the initial position hash code to the list
    ArrayList<Long> hash_codes = new ArrayList<Long>();
    hash_codes.add(new Long(gs.getPositionHash()));

    // Remaining tokens are normal moves
    while (tokenizer.hasMoreTokens()) {
      String move_token = tokenizer.nextToken();
      StringTokenizer temp = new StringTokenizer(move_token);
      temp.nextToken(); // discard move number

      String move = "";
      int steps = 0;
      while (temp.hasMoreTokens()) {
        String step_token = temp.nextToken();
        move += step_token + " ";
        steps++;
      }

      // The last line is blank, so skip it!
      if (steps == 0) {
        continue;
      }

      // Need to explicitly add pass to complete step
      if (steps < 4) {
        move += "pass";
      }

      // Play the move and record the hash codes
      ArimaaMove temp_move = new ArimaaMove(move);
      gs.play(temp_move, gs);
//      System.out.println(gs);

      hash_codes.add(new Long(gs.getPositionHash()));
    }

    // Scan thru the list of codes and check for duplicates
    // Any duplicates mean the position has occurred twice, so if
    // we reach the position again, we lose
    while (!hash_codes.isEmpty()) {
      Long test = (Long) hash_codes.get(hash_codes.size() - 1);
      hash_codes.remove(hash_codes.size() - 1);
      if (hash_codes.contains(test)) {
        // Duplicate found, add move to repetition list
        banned_positions.add(test);
        LogFile.message("Duplicate hash value: " + test);
      }
    }


    // Turn result into array
   long result[] = new long[banned_positions.size()];
   for ( int i=0; i<banned_positions.size(); i++ ) {
     result[i] = banned_positions.get(i).longValue();
   }
   return result;

 }