Function that performs one step of the Game of Life
174604
def update_gol(self):
        
        
        updated_grid = [[self.update_cell(row, col) \
                            for col in range(self.get_grid_width())] \
                            for row in range(self.get_grid_height())]
        
        self.replace_grid(updated_grid)
273208
function start(name) {
  var orb = spheros[name],
      contacts = 0,
      age = 0,
      alive = false;

  orb.detectCollisions();

  born();

  orb.on("collision", function() { contacts += 1; });

  setInterval(function() { if (alive) { move(); } }, 3000);
  setInterval(birthday, 10000);

  // roll Sphero in a random direction
  function move() {
    orb.roll(60, Math.floor(Math.random() * 360));
  }

  // stop Sphero
  function stop() {
    orb.stop();
  }

  // set Sphero's color
  function color(str) {
    orb.color(str);
  }

  function born() {
    contacts = 0;
    age = 0;
    life();
    move();
  }

  function life() {
    alive = true;
    color("green");
  }

  function death() {
    alive = false;
    color("red");
    stop();
  }

  function enoughContacts() {
    return contacts >= 2 && contacts < 7;
  }

  function birthday() {
    age += 1;

    if (alive) {
      console.log("Happy birthday,", name);
      console.log("You are", age, "and had", contacts, "contacts.");
    }

    if (enoughContacts()) {
      if (!alive) { born(); }
    } else {
      death();
    }
  }
}
116724
function step(equation, symbolName) {
  const solveFunctions = [
    // ensure the symbol is always on the left node
    EquationOperations.ensureSymbolInLeftNode,
    // get rid of denominators that have the symbol
    EquationOperations.removeSymbolFromDenominator,
    // remove the symbol from the right side
    EquationOperations.removeSymbolFromRightSide,
    // isolate the symbol on the left side
    EquationOperations.isolateSymbolOnLeftSide,
  ];

  for (let i = 0; i < solveFunctions.length; i++) {
    const equationStatus = solveFunctions[i](equation, symbolName);

    if (equationStatus.hasChanged()) {
      return equationStatus;
    }
  }
  return EquationStatus.noChange(equation);
}
724061
def tictactoe(w, i, player, opponent, grid=None):
    ""
    grid = grid or empty_grid
    while True:
        w.render_to_terminal(w.array_from_text(view(grid)))
        if is_won(grid):
            print(whose_move(grid), "wins.")
            break
        if not successors(grid):
            print("A draw.")
            break
        grid = player(w, i, grid)
        player, opponent = opponent, player
915741
def run(self):
        """"""
        self.ms_game.tcp_accept()

        while True:
            data = self.ms_game.tcp_receive()

            if data == "help\n":
                self.ms_game.tcp_help()
                self.ms_game.tcp_send("> ")
            elif data == "exit\n":
                self.ms_game.tcp_close()
            elif data == "print\n":
                self.ms_game.tcp_send(self.ms_game.get_board())
                self.ms_game.tcp_send("> ")
            elif data == "":
                self.ms_game.tcp_send("> ")
            else:
                self.transfer.emit(data)
                self.ms_game.tcp_send("> ")

            if self.ms_game.game_status == 1:
                self.ms_game.tcp_send("[MESSAGE] YOU WIN!\n")
                self.ms_game.tcp_close()
            elif self.ms_game.game_status == 0:
                self.ms_game.tcp_send("[MESSAGE] YOU LOSE!\n")
                self.ms_game.tcp_close()
935468
function pipeRunStep(){
	//Public APIs
	/**
	 * run: run this step
	 * Should be implemented by subclasses
	 */
	this.run = function( callback ){
		throw new Error("Called run method from abstract pipeRunStep class");
	}
	
	this.getLabel = function(){
		return this.label || "Unknown label";
	}
	
	this.getPipe = function(){
		return (this.pipeRunStats && this.pipeRunStats.getPipe()) || null;
	}
	
	this.getPipeRunner = function(){
		return this.pipeRunner || null;
	}
	
	this.setStepMessage = function(message){
		this.stats.message = message;
		this.pipeRunStats.broadcastRunEvent();
	}
	
	this.setPercentCompletion = function( percent ){
		this.stats.percent = percent;
	}
	
	this.beginStep = function( pipeRunner, pipeRunStats ){
		pipeRunStats.logger.info( "Step %s started", this.getLabel() );
		
		//Reference to the main stats object
		this.pipeRunStats = pipeRunStats;
		this.pipeRunner = pipeRunner;
		
		pipeRunStats.setMessage( this.label );
		
		//Record the start time
		this.stats.startTime = moment();
		this.stats.status = "RUNNING";
		this.setPercentCompletion(0);
		
		this.pipeRunStats.save();
	}

	this.endStep = function(callback, err){
		//Set the end time and elapsed time
		this.stats.endTime = moment();
		this.stats.elapsedTime = moment.duration( this.stats.endTime.diff( this.stats.startTime ) ).humanize();
		
		this.stats.status = err ? "ERROR" : "FINISHED";
		if ( err ){
			this.setStepMessage( err );
		}
		this.setPercentCompletion(100);
		this.pipeRunStats.save( callback, err );
		
		this.pipeRunStats.logger.info({
			message: require('util').format("Step %s completed", this.getLabel() ),
			stats: this.stats
		});
	}
	
	/**
	 * toJSON serialization function
	 */
	this.toJSON = function(){
		return {
			label: this.getLabel()
		}
	}
}
811780
function step(element, type, cb) {
    return function generate(error, html) {
      html += minimize.helpers[type](element);
      return returns(error, html, cb);
    }
  }
1027838
function once(fun) {
    var emitted = false, result;
    return function () {
        if (emitted)
            return result;
        emitted = true;
        return result = fun.apply(null, arguments);
    };
}
338727
function(fun) {
      return function(x, y) {
        if (truthy(fun(x, y)))
          return -1;
        else if (truthy(fun(y, x)))
          return 1;
        else
          return 0;
      };
    }
271964
async def step(self):
        
        result = await self._execute(step=sc_pb.RequestStep(count=self.game_step))
        return result
850861
def _oneInteraction(self):
        
        if self.doOptimization:
            raise Exception('When using a black-box learning algorithm, only full episodes can be done.')
        else:
            self.stepid += 1
            self.agent.integrateObservation(self.task.getObservation())
            self.task.performAction(self.agent.getAction())

            # Save the cumulative sum of set-points for each period.
            for i, g in enumerate(self.task.env.case.online_generators):
                self.Pg[i, self.stepid - 1] = self.Pg[i, self.stepid - 1] + g.p

            reward = self.task.getReward()
            self.agent.giveReward(reward)
            return reward
66525
function onetime() {
        if (called) return value;

        called = 1;
        value = fn.apply(this, arguments);
        fn = null;

        return value;
      }
19198
function (hands, table, dead) {
		// Preprocesses the input data.
		table = table ? _.map(table, getCode) : [];
		dead = dead ? _.map(dead, getCode) : [];
		hands = _.map(hands, function (hand) {
			return _.map(hand, getCode);
		});
		var res = deckSize + 1;
		for (var c = 0; c < table.length; c++)
			res = evaluator[res + table[c]];
		var deck = _.chain(_.range(1, deckSize + 1)).difference(table)
				.difference(_.flatten(hands)).difference(dead).value();
		var player = _.map(hands, function (hand) {
			return evaluator[evaluator[res + hand[0]] + hand[1]];
		});
		var combinations = function (n, k, res, callback) {
			if (k <= 0) {
				callback(res);
			} else {
				while (n < deck.length) {
					var parcial = evaluator[res + deck[n++]];
					combinations(n, k - 1, parcial, callback);
				}
			}
		};
		
		// Calculates the outcome of each play.
		var remaining = 5 - table.length;
		var plays = deck.length / remaining;
		for (var c = 1; c < remaining; c++)
			plays *= (deck.length - c) / c;
		var values = new Array(hands.length);
		for (var p = 0; p < hands.length; p++) {
			var s = 0;
			values[p] = new Int32Array(plays);
			combinations(0, remaining, player[p], function (res) {
				values[p][s++] = res;
			});
		}
		
		// Determines the results.
		var wins = new Int32Array(hands.length);
		var splits = new Int32Array(hands.length);
		for (var s = 0; s < plays; s++) {
			var winner = [0];
			for (var p = 1; p < hands.length; p++) {
				if (values[p][s] > values[winner[0]][s])
					winner = [p];
				else if (values[p][s] == values[winner[0]][s])
					winner.push(p);
			}
			if (winner.length == 1) {
				wins[winner[0]]++;
			} else {
				for (var p = 0; p < winner.length; p++)
					splits[winner[p]]++;
			}
		}
		
		// Formats odds output.
		var odds = [];
		for (var p = 0; p < hands.length; p++)
			odds[p] = {win: wins[p] / plays, split: splits[p] / plays};
		return odds;
	}
1185805
def _oneInteraction(self):
        
        self.stepid += 1

        logger.info("\nEntering simulation period %d." % self.stepid)

        # Initialise the market.
        self.market.reset()

        # Get an action from each agent and perform it.
        for task, agent in zip(self.tasks, self.agents):
            observation = task.getObservation()
            agent.integrateObservation(observation)

            action = agent.getAction()
            task.performAction(action)

        # Clear the market.
        self.market.run()

        # Reward each agent appropriately.
        for task, agent in zip(self.tasks, self.agents):
            reward = task.getReward()
            agent.giveReward(reward)
235309
def play(self):
        
        colors = [lambda: self.white_move(), lambda: self.black_move()]
        colors = itertools.cycle(colors)

        while True:
            color_fn = next(colors)
            if game_state.no_moves(self.position):
                if self.position.get_king(color.white).in_check(self.position):
                    return 1

                elif self.position.get_king(color.black).in_check(self.position):
                    return 0

                else:
                    return 0.5

            color_fn()
737461
function step(){

        var time;

        window.requestAnimationFrame( step );

        if (!active){
            return;
        }

        time = now();

        if (!time){
            return;
        }

        ps.emit( 'tick', time );
    }
1307765
function () {
    // main code
    var x = new StablePriorityQueue(function (a, b) {
        return a.name < b.name ? -1 : (a.name > b.name ? 1 : 0) ;
    });
    x.add({name:"Jack", age:31});
    x.add({name:"Anna", age:111});
    x.add({name:"Jack", age:46});
    x.add({name:"Jack", age:11});
    x.add({name:"Abba", age:31});
    x.add({name:"Abba", age:30});
    while (!x.isEmpty()) {
        console.log(x.poll());
    }
    x = new StablePriorityQueue(function(a, b) {
          return a.energy - b.energy;
    });
    [{ name: 'player', energy: 10},
     { name: 'monster1', energy: 10},
     { name: 'monster2', energy: 10},
     { name: 'monster3', energy: 10}
    ].forEach(function(o){
          x.add(o);
    })
    while (!x.isEmpty()) {
        console.log(x.poll());
    }

}