Takes a board and return white and black pieces.
Used to calculate score from a board.

returns { white: [{x,y}], black: [{x,y}] }
195934
function getPiecesFromBoard(board) {
    var initialPieces = {
        white: [],
        black: []
    };
    return board.reduce(function (piecesRow, row) {
        return row.reduce(function (pieces, position) {
            if (Position.hasBlackPiece(position)) pieces.black = pieces.black.concat(position);else if (Position.hasWhitePiece(position)) pieces.white = pieces.white.concat(position);
            return pieces;
        }, piecesRow);
    }, initialPieces);
}
432457
function(h, s, b){
	            h *= 6;
	            s = [
	                b += s *= b < .5 ? b : 1 - b,
	                b - h % 1 * s * 2,
	                b -= s *= 2,
	                b,
	                b + h % 1 * s,
	                b + s
	            ];

	            return [
	                s[ ~~h    % 6 ] * 255, // red
	                s[ (h|16) % 6 ] * 255, // green
	                s[ (h|8)  % 6 ] * 255  // blue
	            ];
	        }
501592
private function diagonals()
    {

        $diagonals = array_fill(0, 2, []);

        $diagonalIndexes = range(0, count($this->board) - 1);

        $diagonalIndexesReverse = array_reverse($diagonalIndexes);

        foreach ($diagonalIndexes as $index => $value) {

            array_push($diagonals[0], $this->board->getValue([$value, $value]));

            array_push($diagonals[1], $this->board->getValue([$value, $diagonalIndexesReverse[$index]]));
        }

        return $diagonals;
    }
1017226
def to_array(self):
        
        array = super(GameHighScore, self).to_array()
        array['position'] = int(self.position)  # type int
        array['user'] = self.user.to_array()  # type User
        array['score'] = int(self.score)  # type int
        return array
1330600
function getPins(callback) {
        var allPins = [];
        getBoards(false, function (boards) {
            async.each(boards, function(board, asyncCallback) {
                var splitHref = board.href.split('/');
                if (splitHref[1] === username) { // it's possible to have boards listed from other users
                    var boardHref = board.href.split('/')[2];
                    getPinsFromBoard(boardHref, false, function (pins) {
                        allPins = allPins.concat(pins);
                        asyncCallback();
                    });
                } else {
                    asyncCallback();
                }
            },
            function (err) {
                if (err) {
                    console.error('Error iterating through each board to get pins');
                    throw err;
                }
                callback(buildResponse(allPins));
                return;
            });
        });
    }
206588
def get(self, x, y):
        
        for piece in self.pieces:
            if (piece.x, piece.y) == (x, y):
                return piece
384854
def bbox(self):
        """"""
        if not hasattr(self, '_bbox'):
            data = None
            for key in ('ARTBOARD_DATA1', 'ARTBOARD_DATA2', 'ARTBOARD_DATA3'):
                if key in self.tagged_blocks:
                    data = self.tagged_blocks.get_data(key)
            assert data is not None
            rect = data.get(b'artboardRect')
            self._bbox = (
                int(rect.get(b'Left')),
                int(rect.get(b'Top ')),
                int(rect.get(b'Rght')),
                int(rect.get(b'Btom')),
            )
        return self._bbox
380404
def piece_at(self, square: Square) -> Optional[Piece]:
        """"""
        piece_type = self.piece_type_at(square)
        if piece_type:
            mask = BB_SQUARES[square]
            color = bool(self.occupied_co[WHITE] & mask)
            return Piece(piece_type, color)
        else:
            return None
194326
function getTurnPieces(game) {
    const isBlack = isBlackTurn(game);
    return game.board.reduce((piecesRow, row) => {
        return piecesRow.concat(row.reduce((pieces, position) => (isBlack !== position.isBlack)
            ? pieces
            : pieces.concat({ x: position.x, y: position.y, isBlack }), []));
    }, []);
}
697953
function getColormap() {
    var map = [];
    var index = [];

    for (var i = 0; i < netsize; i++)
      index[network[i][3]] = i;

    var k = 0;
    for (var l = 0; l < netsize; l++) {
      var j = index[l];
      map[k++] = (network[j][0]);
      map[k++] = (network[j][1]);
      map[k++] = (network[j][2]);
    }
    return map;
  }
753302
def piece_type_at(self, square: Square) -> Optional[PieceType]:
        """"""
        mask = BB_SQUARES[square]

        if not self.occupied & mask:
            return None  # Early return
        elif self.pawns & mask:
            return PAWN
        elif self.knights & mask:
            return KNIGHT
        elif self.bishops & mask:
            return BISHOP
        elif self.rooks & mask:
            return ROOK
        elif self.queens & mask:
            return QUEEN
        else:
            return KING
230286
function getRGBBytes(color, out) {
    out = out || [0, 0, 0];
    out[0] = Math.round(color[0]*255);
    out[1] = Math.round(color[1]*255);
    out[2] = Math.round(color[2]*255);
    return out;
}
33273
function getNotEmptyNearPositions(board, position) {
    return getNearPositions(board, position).filter(function (p) {
        return Position.hasPiece(p);
    });
}
395626
function getRows (items) {
  const data = {}
  const rows = [[]]

  data.stacks = true

  for (var i = 0; i < items.length; i++) {
    const el = items[i]
    const dim = el.getBoundingClientRect()

    if (!dim.height) {
      continue
    }

    for (var j = rows.length - 1; j >= 0; j--) {
      const row = rows[j]

      if (!row[0]) {
        row.push(el)
        break
      }

      var leftDim = row[0].getBoundingClientRect()

      if (dim.top >= Math.floor(leftDim.bottom)) {
        rows.push([el])
        break
      }

      if (Math.floor(dim.bottom) > leftDim.top) {
        data.stacks = false

        if (dim.left < leftDim.left && !isRtl) {
          row.unshift(el)
          break
        }

        row.push(el)
        break
      }

      if (j === 0) {
        rows.unshift([el])
        break
      }
    }
  }

  data.rows = rows

  return data
}
1171209
function boardLookupTable() {
  var byBoard = {};
  for (var i = 0; i < boards.length; i++) {
    var currentBoard = boards[i];
    byBoard[currentBoard.name] = currentBoard;

    var aliases = currentBoard.aliases;
    if (Array.isArray(aliases)) {
      for (var j = 0; j < aliases.length; j++) {
        var currentAlias = aliases[j];
        byBoard[currentAlias] = currentBoard;
      }
    }
  }
  return byBoard;
}
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;
	}
934206
function getHex(color) {
    var c = [ color[0], color[1], color[2] ].map(function(val) {
        return Math.floor(val * 255);
    });

    return "#" + ((c[2] | c[1] << 8 | c[0] << 16) | 1 << 24)
        .toString(16)
        .slice(1)
        .toUpperCase();
}