This AI simple moves the characters towards the opposite
        edges of the grid for 3 steps or until event halts the 
        simulation
968325
def run(self):
        
        x, y = 1,0  # set the direction
        num_steps = 0
        while self.s.get_state() != 'Halted':
            self.s.command({'name':'walk', 'type':'move', 'direction':[x, y]}, self.a1)
            self.s.command({'name':'walk', 'type':'run', 'direction':[x, y+1]}, self.a2)
            num_steps += 1
            if num_steps >= 3:
                break
        for a in self.s.agents:
            print(a.name, 'finished at position ', a.coords['x'], a.coords['y'])
581950
public void animate(final boolean RUN) {
        if (isEnabled()) {
            if (RUN) {
                if (timeline.getState() != Timeline.TimelineState.PLAYING_FORWARD && timeline.getState() != Timeline.TimelineState.SUSPENDED) {
                    timeline = new Timeline(this);
                    timeline.addPropertyToInterpolate("rotationAngle", this.rotationAngle, 2 * Math.PI);
                    timeline.setEase(new org.pushingpixels.trident.ease.Linear());
                    timeline.setDuration((long) (5000));
                    timeline.playLoop(Timeline.RepeatBehavior.LOOP);
                } else if (timeline.getState() == Timeline.TimelineState.SUSPENDED) {
                    timeline.resume();
                }
            } else {
                timeline.suspend();
            }
        }
    }
327593
function moveRender (type) {
    var method = type ? 'down' : 'up'
    
    ui
      .left(lastLen + 2)
      .up(count - cur)
      .write('  ')
    
    // Each time move to right-bottom.
    ui[method]()
      .left(2)
      .write(chalk.blue(pointer))
      .left(2)
      .down(count - (type ? ++cur : --cur))
      .right(lastLen + 2)
  }
760084
public final void moveInside(Rect bounds) {
	// check the right edge
	int distanceOffRightSide = (x + w) - (bounds.x + bounds.w);
	if (distanceOffRightSide > 0) {
	    x -= distanceOffRightSide;
	}
	// check the left edge (we prefer this to fit)
	int distanceOffLeftSide = bounds.x - x;
	if (distanceOffLeftSide > 0) {
	    x += distanceOffLeftSide;
	}

	// check the bottom edge
	int distanceOffBottom = (y + h) - (bounds.y + bounds.h);
	if (distanceOffBottom > 0) {
	    y -= distanceOffBottom;
	}
	// check the top edge (we prefer this to fit)
	int distanceOffTop = bounds.y - y;
	if (distanceOffTop > 0) {
	    y += distanceOffTop;
	}	
    }
204931
function steppingDispatch() {
        applyExternalEffect(options.stepping.effect);  // WARNING: may change `options.stepping.effect`
        var event = options.dequeue(events);
        if (!event) {
            return false;
        }
        var effect = options.stepping.effect;
        effect.event = event;
        try {
            var behavior = event.context.behavior;
            effect.behavior = behavior;
            event.context.behavior(event.message);  // execute actor behavior
            if (behavior !== event.context.behavior) {
                effect.became = event.context.behavior;
            }
        } catch (exception) {
            effect.exception = exception;
        }
        applyBehaviorEffect(effect);  // WARNING: will change `options.stepping.effect`
        return effect;
    }
286049
def automeshgrid(
        x, y, step=0.02, xstep=None, ystep=None, pad=0.5, xpad=None, ypad=None
):
    """"""
    if xpad is None:
        xpad = pad
    if xstep is None:
        xstep = step
    if ypad is None:
        ypad = pad
    if ystep is None:
        ystep = step
    xmin = x.min() - xpad
    xmax = x.max() + xpad
    ymin = y.min() - ypad
    ymax = y.max() + ypad
    return meshgrid(xmin, xmax, step, ymin, ymax, ystep)
450137
private void performDynamicStep() {
        // initially look for singular values of zero
        if( findingZeros ) {
            if( steps > 6 ) {
                findingZeros = false;
            } else {
                double scale = computeBulgeScale();
                performImplicitSingleStep(scale,0,false);
            }
        } else {
            // For very large and very small numbers the only way to prevent overflow/underflow
            // is to have a common scale between the wilkinson shift and the implicit single step
            // What happens if you don't is that when the wilkinson shift returns the value it
            // computed it multiplies it by the scale twice, which will cause an overflow
            double scale = computeBulgeScale();
            // use the wilkinson shift to perform a step
            double lambda = selectWilkinsonShift(scale);

            performImplicitSingleStep(scale,lambda,false);
        }
    }
638320
def onDragSelection(self, event):
        
        if self.grid.GetSelectionBlockTopLeft():
            #top_left = self.grid.GetSelectionBlockTopLeft()
            #bottom_right = self.grid.GetSelectionBlockBottomRight()
            # awkward hack to fix wxPhoenix memory problem, (Github issue #221)
            bottom_right = eval(repr(self.grid.GetSelectionBlockBottomRight()).replace("GridCellCoordsArray: ", "").replace("GridCellCoords", ""))
            top_left = eval(repr(self.grid.GetSelectionBlockTopLeft()).replace("GridCellCoordsArray: ", "").replace("GridCellCoords", ""))
            #
            top_left = top_left[0]
            bottom_right = bottom_right[0]
        else:
            return
        # GetSelectionBlock returns (row, col)
        min_col = top_left[1]
        max_col = bottom_right[1]
        min_row = top_left[0]
        max_row = bottom_right[0]
        self.df_slice = self.contribution.tables[self.grid_type].df.iloc[min_row:max_row+1, min_col:max_col+1]
362837
public void performStep() {
        // check for zeros
        for( int i = helper.x2-1; i >= helper.x1; i-- ) {
            if( helper.isZero(i) ) {
                helper.splits[helper.numSplits++] = i;
                helper.x1 = i+1;
                return;
            }
        }

        double lambda;

        if( followingScript ) {
            if( helper.steps > 10 ) {
                followingScript = false;
                return;
            } else {
                // Using the true eigenvalues will in general lead to the fastest convergence
                // typically takes 1 or 2 steps
                lambda = eigenvalues[helper.x2];
            }
        } else {
            // the current eigenvalue isn't working so try something else
            lambda = helper.computeShift();
        }

        // similar transforms
        helper.performImplicitSingleStep(lambda,false);
    }
1129561
@Override
	protected void putGridIntoCanonical(Grid g ) {
		// first put it into a plausible solution
		if( g.columns != numCols ) {
			rotateGridCCW(g);
		}

		if( g.get(0,0) == null ) {
			reverse(g);
		}

		// select the best corner for canonical
		if( g.columns%2 == 1 && g.rows%2 == 1) {
			// first make sure orientation constraint is maintained
			if( isClockWise(g)) {
				flipHorizontal(g);
			}

			int numRotationsCCW = closestCorner4(g);
			if( g.columns == g.rows ) {
				for (int i = 0; i < numRotationsCCW; i++) {
					rotateGridCCW(g);
				}
			} else if( numRotationsCCW == 2 ){
				// only two valid solutions.  rotate only if the other valid solution is better
				rotateGridCCW(g);
				rotateGridCCW(g);
			}
		} else if( g.columns%2 == 1 ) {
			// only two solutions.  Go with the one which maintains orientation constraint
			if( isClockWise(g)) {
				flipHorizontal(g);
			}
		} else if( g.rows%2 == 1 ) {
			// only two solutions.  Go with the one which maintains orientation constraint
			if( isClockWise(g)) {
				flipVertical(g);
			}
		}
	}
850862
function gameOfLife() {
  for (var i=0; i<grid.columns; i++) {
    buffer[i] = []; // reset row

    for (var k=0; k<grid.rows; k++) {
      var cnt = 0; // counter

      for ( var m=i-1; m<i+2; m++) { // get the states of surrounding cells
        var mm = (m<0) ? grid.columns-1 : ( (m>=grid.columns) ? m-grid.columns : m );

        for ( var n=k-1; n<k+2; n++) {
          var nn = (n<0) ? grid.rows-1 : ( (n>=grid.rows) ? n-grid.rows : n );
          if (mm===i && nn===k) continue;
          else if ( !grid.canFit(mm, nn, 1, 1) ) cnt++;
        }
      }
      buffer[i][k] = (grid.canFit(i, k, 1, 1) && cnt==3) || (!grid.canFit(i, k, 1, 1) && cnt>=2 && cnt<=3);
    }
  }
}
159161
public void nextStep() {
        if (currentStepIndex >= getWidgetCount() - 1) {
            CompleteEvent.fire(MaterialStepper.this, currentStepIndex + 1);
        } else {
            Widget w = getWidget(currentStepIndex);
            if (w instanceof MaterialStep) {
                MaterialStep step = (MaterialStep) w;
                step.setActive(false);

                step.setSuccessText(step.getDescription());

                // next step
                int nextStepIndex = getWidgetIndex(step) + 1;
                if (nextStepIndex >= 0) {
                    for (int i = nextStepIndex; i < getWidgetCount(); i++) {
                        w = getWidget(i);
                        if (!(w instanceof MaterialStep)) {
                            continue;
                        }
                        MaterialStep nextStep = (MaterialStep) w;
                        if (nextStep.isEnabled() && nextStep.isVisible()) {
                            nextStep.setActive(true);
                            setCurrentStepIndex(i);
                            NextEvent.fire(MaterialStepper.this);
                            break;
                        }
                    }
                }
            }
        }
    }
1354111
def gridrange(start, end, step):
    """"""
    for x in frange(start.real, end.real, step.real):
        for y in frange(start.imag, end.imag, step.imag):
            yield x + y * 1j
435049
public void onTentativeMove(GeometryEditTentativeMoveEvent event) {
		try {
			Coordinate[] vertices = editService.getIndexService().getSiblingVertices(editService.getGeometry(),
					editService.getInsertIndex());
			String geometryType = editService.getIndexService().getGeometryType(editService.getGeometry(),
					editService.getInsertIndex());

			if (vertices != null
					&& (Geometry.LINE_STRING.equals(geometryType) || Geometry.LINEAR_RING.equals(geometryType))) {
				Coordinate temp1 = event.getOrigin();
				Coordinate temp2 = event.getCurrentPosition();
				Coordinate c1 = mapPresenter.getViewPort().getTransformationService()
						.transform(temp1, RenderSpace.WORLD, RenderSpace.SCREEN);
				Coordinate c2 = mapPresenter.getViewPort().getTransformationService()
						.transform(temp2, RenderSpace.WORLD, RenderSpace.SCREEN);

				tentativeMoveLine.setStep(0, new MoveTo(false, c1.getX(), c1.getY()));
				tentativeMoveLine.setStep(1, new LineTo(false, c2.getX(), c2.getY()));
			} else if (vertices != null && Geometry.LINEAR_RING.equals(geometryType)) {
				// Draw the second line (as an option...)
			}
		} catch (GeometryIndexNotFoundException e) {
			throw new IllegalStateException(e);
		}
	}
510004
function (event) {
    var direction;
    var movementX;
    var movementY;
    var pitchObject = this.pitchObject;
    var previousMouseEvent = this.previousMouseEvent;
    var yawObject = this.yawObject;

    // Not dragging or not enabled.
    if (!this.data.enabled || (!this.mouseDown && !this.pointerLocked)) { return; }

    // Calculate delta.
    if (this.pointerLocked) {
      movementX = event.movementX || event.mozMovementX || 0;
      movementY = event.movementY || event.mozMovementY || 0;
    } else {
      movementX = event.screenX - previousMouseEvent.screenX;
      movementY = event.screenY - previousMouseEvent.screenY;
    }
    this.previousMouseEvent = event;

    // Calculate rotation.
    direction = this.data.reverseMouseDrag ? 1 : -1;
    yawObject.rotation.y += movementX * 0.002 * direction;
    pitchObject.rotation.x += movementY * 0.002 * direction;
    pitchObject.rotation.x = Math.max(-PI_2, Math.min(PI_2, pitchObject.rotation.x));
  }
347914
function(event, showAction) {
        var data = window.kelmu.data[id];
        var count = Math.max(+showAction.parameter || 1, 1);

        var action = function() {
          forward(event);
        };

        if (!data.animationReadyAvailable) {
          for (var i = 0; i < count; i++) {
            setTimeout(action, i * (data.settings.animationLength + 300));
          }
        } else {
          data.stepEvent = event;
          data.stepsToRun = count - 1;

          if (data.stepsToRun > 0) {
            // Notify the animator that we are running multiple steps that should be combined into a single step
            window.kelmu.sendMessage(id, 'showSequence');
          }

          forward(event);
        }
      }
79200
function handleBrushEnd() {
            if (!d3Selection.event.sourceEvent) {
                return; // Only transition after input.
            }

            let dateExtentRounded = [null, null];
            const selection = d3Selection.event.selection;

            if (selection) {
                let dateExtent = selection.map(xScale.invert);

                dateExtentRounded = dateExtent.map(timeIntervals[roundingTimeInterval].round);

                // If empty when rounded, use floor & ceil instead.
                if (dateExtentRounded[0] >= dateExtentRounded[1]) {
                    dateExtentRounded[0] = timeIntervals[roundingTimeInterval].floor(dateExtent[0]);
                    dateExtentRounded[1] = timeIntervals[roundingTimeInterval].offset(dateExtentRounded[0]);
                }

                d3Selection.select(this)
                    .transition()
                    .call(d3Selection.event.target.move, dateExtentRounded.map(xScale));
            }

            dispatcher.call('customBrushEnd', this, dateExtentRounded);
        }