*** This script moves selected vertices randomly using the normal distribution.

// Parameter list begins
mov r98 32 // Standard deviation (X, 32768 max.)
mov r99 32 // Standard deviation (Y, 32768 max.)
// Parameter list ends
~~~ Default parameters:
~~~ mov r98 32 // Standard deviation (X, 32768 max.)
~~~ mov r99 32 // Standard deviation (Y, 32768 max.)
mov r01 0
getwallnumber r02
while r01 < r02
  setpntb1x r01 0
  inc r01
continue

getwallnumber r01  dec r01
while r01 >= 0 // For each vertex
  getselvertex r01 r00
  if r00 != 0 // Selected
    findmovwalls r01
    mov r03 r02  dec r03
    while r03 >= 0 // For each wall
      getwallmovestate r03 r04
      if r04 == 3  mov r04 1  endif // Move status is 1 or 3
      if r04 == 1 // Movable by current vertex
        getpntb1x r03 r04
        if r04 == 0 // Do not process single wall multiple times
          setpntb1x r03 1
          mov r07 5 // Pointer
          mov r12 0 // Counter
          while r07 < 7 // Repeat for X and Y
            mov r12 r07 // Auxiliary pointer
            add r12 93 // 98-5
            ptr 11 r12 // Get standard deviation
            mov r08 0 // Random value buffer
            mov r09 10 // Counter
            while r09 > 0 // Repeat 10 times
              rnd r10 // Assign random value
              and r10 2147483647 // Only positive values
              div r10 65536 // Take 15 major bits to provide random behavior
              mov r13 r11  mul r13 2  inc r13
              mod r10 r13 // Values in range from 0 to r13-1 (r11*2)
              sub r10 r11 // Values in range from -r11 to +r11
              add r08 r10 // Add to buffer
              dec r09
            continue
            ptr r07 8 // Return normal distribution value
            inc r07
          continue
          getwall r03 x r04
          add r04 r05
          setwall r03 x r04
          getwall r03 y r04
          add r04 r06
          setwall r03 y r04
        endif
      endif
      dec r03
    continue
  endif
  dec r01
continue