<commit_before>import _ from 'lodash';

const createFork = (gameBoard, marker = 'O') => {
    const sides = [
        {
            side: 'a2',
            possibles: ['a1', 'a3']
        },
        {
            side: 'b1',
            possibles: ['a1', 'c1']
        },
        {
            side: 'b3',
            possibles: ['a3', 'c3']
        },
        {
            side: 'c2',
            possibles: ['c1', 'c3']
        },
    ];

    let availibleCorners = [];
    const center = 'b2';
    const userMarker = marker === 'O' ? 'X' : 'O';

    if (gameBoard[center] !== '') {
        return false;
    }
    const sidesTakenByUser = sides.filter(({ side, possibles }) => {
        return gameBoard[side] === userMarker;
    })

    if (sidesTakenByUser.length === 1) {
        availibleCorners = sidesTakenByUser[0].possibles.filter((corner) => {
            return gameBoard[corner] === '';
        });
    }

    const len = availibleCorners.length - 1;
    const random = _.random(len);

    return availibleCorners[random] || false;
}

export default createFork;<commit_msg>Mom found way to win with doing side then corner the comp played two corners which allowed for a win.<commit_after>import _ from 'lodash';

const createFork = (gameBoard, marker = 'O') => {
    const sides = [
        {
            side: 'a2',
            possibles: ['a1', 'a3']
        },
        {
            side: 'b1',
            possibles: ['a1', 'c1']
        },
        {
            side: 'b3',
            possibles: ['a3', 'c3']
        },
        {
            side: 'c2',
            possibles: ['c1', 'c3']
        },
    ];

    let availibleCorners = [];
    const center = 'b2';
    const userMarker = marker === 'O' ? 'X' : 'O';
    const numDirtySquares = _.values(gameBoard).filter((square) => {
        return square !== '';
    }).length;

    if (gameBoard[center] !== '' || numDirtySquares > 1) {
        return false;
    }
    const sidesTakenByUser = sides.filter(({ side, possibles }) => {
        return gameBoard[side] === userMarker;
    })

    if (sidesTakenByUser.length === 1) {
        availibleCorners = sidesTakenByUser[0].possibles.filter((corner) => {
            return gameBoard[corner] === '';
        });
    }

    const len = availibleCorners.length - 1;
    const random = _.random(len);

    return availibleCorners[random] || false;
}

export default createFork;
{'fraction_non_alphanumeric': 0.15868388171595169, 'fraction_numerical': 0.013744273219491879, 'mean_word_length': 1.8561236623067776, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2819886', 'n_tokens_mistral': 793, 'n_tokens_neox': 753, 'n_words': 172}