Returns the next move calculated by Gnuchess.
 @return [String] Returns the short algebraic chess notation of the move.
7780
def gnuchess_move
      pipe = IO.popen('gnuchess -x', 'r+')
      begin
        pipe.puts('depth 1')
        pipe.puts('manual')
        self.coord_moves.each do |m|
          pipe.puts(m)
        end
        pipe.puts('go')
        while line = pipe.gets
          raise IllegalMoveError if line.include?('Invalid move')
          match = line.match(/My move is : ([a-h][1-8][a-h][1-8][rkbq]?)/)
          return match[1] if match
        end
      ensure
        pipe.puts('quit')
        pipe.close
      end
      return moves
    end
177816
def parse_csa1
      s0 = @current_pos
      s1 = parse_players
      s1 = nil if s1 == :failed
      s2 = parse_initial_board
      s2 = nil if s2 == :failed
      s3 = parse_moves
      if s3 != :failed
        @reported_pos = s0
        s0 = -> (ply, ini, ms) do
          ret = { "header" => {}, "initial" => ini, "moves" => ms }
          if ply
            ret["header"]["先手"] = ply[0] if ply[0]
            ret["header"]["後手"] = ply[1] if ply[1]
          end
          ret
        end.call(s1, s2, s3)
      else
        @current_pos = s0
        s0 = :failed
      end
      s0
    end
1241628
def parse_moves
      s0 = @current_pos
      s1 = parse_firstboard
      if s1 != :failed
        s2 = []
        s3 = parse_move
        while s3 != :failed
          s2 << s3
          s3 = parse_move
        end
        s3 = parse_result
        s3 = nil if s3 == :failed
        @reported_pos = s0
        s0 = -> (hd, tl, res) do
          tl.unshift(hd)
          tl << { "special" => res } if res && !tl[tl.length - 1]["special"]
          tl
        end.call(s1, s2, s3)
      else
        @current_pos = s0
        s0 = :failed
      end
      s0
    end
1229894
function() {
            var next = steps.indexOf( activeStep ) + 1;
            next = next < steps.length ? steps[ next ] : steps[ 0 ];

            return goto( next );
        }
1250238
def next_item
      return nil unless more_items?
      return response.cursor if response.respond_to?(:cursor)
      response.offset + response.limit
    rescue StandardError
      nil
    end
200522
public String next() {
        if (done) return null;

        // construct return value

        buffer.setLength(0); // delete old contents
        for (int i = 0; i < pieces.length; ++i) {
            buffer.append(pieces[i][current[i]]);
        }
        String result = buffer.toString();

        // find next value for next time

        for (int i = current.length - 1; ; --i) {
            if (i < 0) {
                done = true;
                break;
            }
            current[i]++;
            if (current[i] < pieces[i].length) break; // got sequence
            current[i] = 0;
        }
        return result;
    }
339746
def possible_moves(p1, manifest, castling = false)
      return [] if manifest[p1][:type].nil?

      allowed   = []
      type      = manifest[p1][:type]
      my_color  = manifest[p1][:color]

      constants(manifest, my_color, type)

      return [] if unoccupied?(p1)

      if type == :king
        allowed += [move_lateral(p1, 1)].flatten
        allowed += [move_diagonal(p1, 1)].flatten
        allowed += [castle(p1)].flatten if castling

      elsif type == :queen
        allowed += [move_lateral(p1)].flatten
        allowed += [move_diagonal(p1)].flatten

      elsif type == :rook
        allowed += [move_lateral(p1)].flatten

      elsif type == :bishop
        allowed += [move_diagonal(p1)].flatten

      elsif type == :pawn
        allowed += [move_pawn(p1)].flatten

      elsif type == :knight
        allowed += [move_knight(p1)].flatten
      end

      allowed
    end
1177610
def get_next(self):
        
        self._counter_curr += 1

        suffix = self._separator + "%s" % str(self._counter_curr)

        return self._base_name + suffix
1260527
def update(self, move):
        
        if move is None:
            raise TypeError("Move cannot be type None")

        if self.king_loc_dict is not None and isinstance(move.piece, King):
            self.king_loc_dict[move.color] = move.end_loc

        # Invalidates en-passant
        for square in self:
            pawn = square
            if isinstance(pawn, Pawn):
                pawn.just_moved_two_steps = False

        # Sets King and Rook has_moved property to True is piece has moved
        if type(move.piece) is King or type(move.piece) is Rook:
            move.piece.has_moved = True

        elif move.status == notation_const.MOVEMENT and \
                isinstance(move.piece, Pawn) and \
                fabs(move.end_loc.rank - move.start_loc.rank) == 2:
            move.piece.just_moved_two_steps = True

        if move.status == notation_const.KING_SIDE_CASTLE:
            self.move_piece(Location(move.end_loc.rank, 7), Location(move.end_loc.rank, 5))
            self.piece_at_square(Location(move.end_loc.rank, 5)).has_moved = True

        elif move.status == notation_const.QUEEN_SIDE_CASTLE:
            self.move_piece(Location(move.end_loc.rank, 0), Location(move.end_loc.rank, 3))
            self.piece_at_square(Location(move.end_loc.rank, 3)).has_moved = True

        elif move.status == notation_const.EN_PASSANT:
            self.remove_piece_at_square(Location(move.start_loc.rank, move.end_loc.file))

        elif move.status == notation_const.PROMOTE or \
                move.status == notation_const.CAPTURE_AND_PROMOTE:
            try:
                self.remove_piece_at_square(move.start_loc)
                self.place_piece_at_square(move.promoted_to_piece(move.color, move.end_loc), move.end_loc)
            except TypeError as e:
                raise ValueError("Promoted to piece cannot be None in Move {}\n{}".format(repr(move), e))
            return

        self.move_piece(move.piece.location, move.end_loc)
885552
public int[] getNext () {

		if (numLeft.equals (total)) {
			numLeft = numLeft.subtract (BigInteger.ONE);
			return a;
		}

		int temp;

		// Find largest index j with a[j] < a[j+1]

		int j = a.length - 2;
		while (a[j] > a[j+1]) {
			j--;
		}

		// Find index k such that a[k] is smallest integer
		// greater than a[j] to the right of a[j]

		int k = a.length - 1;
		while (a[j] > a[k]) {
			k--;
		}

		// Interchange a[j] and a[k]

		temp = a[k];
		a[k] = a[j];
		a[j] = temp;

		// Put tail end of permutation after jth position in increasing order

		int r = a.length - 1;
		int s = j + 1;

		while (r > s) {
			temp = a[s];
			a[s] = a[r];
			a[r] = temp;
			r--;
			s++;
		}

		numLeft = numLeft.subtract (BigInteger.ONE);
		return a;

	}
506547
def _next_move_direction(self):
        
        nmoves = len(self.moves)
        move = np.random.randint(1, nmoves+1)
        while self.prev_move == (move + 3) % nmoves:
            move = np.random.randint(1, nmoves+1)
        self.prev_move = move
        return np.array(self.moves[move])
924821
public long next() {
    long x = xorshift(this.x);
    this.x = y;
    y = z;
    z = this.x ^ x ^ y;
    return z;
  }
1008705
def _get_next(self):
        

        self.state = PRNG_A * self.state % PRNG_M
        return self.state
422251
def next_column
      # TODO take care of multipliers
      _calculate_column_offsets unless @coffsets
      c = @column_pointer.next
      cp = @coffsets[c]
      #$log.debug " next_column #{c} , #{cp} "
      @curpos = cp if cp
      down() if c < @column_pointer.last_index
      fire_column_event :ENTER_COLUMN
    end
599734
def next(self):
        
        # do not acquire lock if NuMap is not finished.
        if self.finished:
            raise StopIteration
        # get per-tee lock
        self.piper.tee_locks[self.i].acquire()
        # get result or exception
        exception = True
        try:
            result = self.piper.tees[self.i].next()
            exception = False
        except StopIteration, result:
            self.finished = True
        except Exception, result:
            pass
        # release per-tee lock either self or next
        if self.s == self.stride or self.finished:
            self.s = 1
            self.piper.tee_locks[(self.i + 1) % len(self.piper.tees)].release()

        else:
            self.s += 1
            self.piper.tee_locks[self.i].release()
        if exception:
            raise result
        else:
            return result
99335
def compute_origin
      return nil if move.castle

      possibilities = case move.piece
      when /[brq]/i then direction_origins
      when /[kn]/i  then move_origins
      when /p/i     then pawn_origins
      end

      if possibilities.length > 1
        possibilities = disambiguate(possibilities)
      end

      self.board.position_for(possibilities.first)
    end
784651
def all_legal_moves(self):
        ''
        # by default, every move is legal
        legal_moves = np.ones([N, N], dtype=np.int8)
        # ...unless there is already a stone there
        legal_moves[self.board != EMPTY] = 0
        # calculate which spots have 4 stones next to them
        # padding is because the edge always counts as a lost liberty.
        adjacent = np.ones([N + 2, N + 2], dtype=np.int8)
        adjacent[1:-1, 1:-1] = np.abs(self.board)
        num_adjacent_stones = (adjacent[:-2, 1:-1] + adjacent[1:-1, :-2] +
                               adjacent[2:, 1:-1] + adjacent[1:-1, 2:])
        # Surrounded spots are those that are empty and have 4 adjacent stones.
        surrounded_spots = np.multiply(
            (self.board == EMPTY),
            (num_adjacent_stones == 4))
        # Such spots are possibly illegal, unless they are capturing something.
        # Iterate over and manually check each spot.
        for coord in np.transpose(np.nonzero(surrounded_spots)):
            if self.is_move_suicidal(tuple(coord)):
                legal_moves[tuple(coord)] = 0

        # ...and retaking ko is always illegal
        if self.ko is not None:
            legal_moves[self.ko] = 0

        # and pass is always legal
        return np.concatenate([legal_moves.ravel(), [1]])