index.js
/**
     * Update weight of all lines adjacent to picked square
     * @param {Number} squareId
     */
Update weight of all lines adjacent to picked square
@param {Number} squareId
Update weight of all lines adjacent to picked square @param { Number } squareId
function updateSquareLinesWeight(squareId) {
        for (let j = 0; j < squares[squareId].lines.length; j++) {
            let lineId =  squares[squareId].lines[j];
            if(lines[lineId].hidden) {
                if(squares[squareId].weight == squares[squareId].lines.length - 1) {
                    lines[lineId].weight += CIRCLE_COUNT * squares[squareId].value * 10;
                } else if(squares[squareId].weight == squares[squareId].lines.length - 2) {
                    lines[lineId].weight -= CIRCLE_COUNT * squares[squareId].value;
                } else if(squares[squareId].weight != squares[squareId].lines.length) {
                    let squareWeight = (squares[squareId].value > 1) ? (squares[squareId].weight + 1) : squares[squareId].weight;
                    lines[lineId].weight += squareWeight * squares[squareId].value;
                }
            }
        }
    }
function updateSquareLinesWeight ( squareId ) { for ( let j = 0 ; j < squares [ squareId ] . lines . length ; j ++ ) { let lineId = squares [ squareId ] . lines [ j ] ; if ( lines [ lineId ] . hidden ) { if ( squares [ squareId ] . weight == squares [ squareId ] . lines . length - 1 ) { lines [ lineId ] . weight += CIRCLE_COUNT * squares [ squareId ] . value * 10 ; } else if ( squares [ squareId ] . weight == squares [ squareId ] . lines . length - 2 ) { lines [ lineId ] . weight -= CIRCLE_COUNT * squares [ squareId ] . value ; } else if ( squares [ squareId ] . weight != squares [ squareId ] . lines . length ) { let squareWeight = ( squares [ squareId ] . value > 1 ) ? ( squares [ squareId ] . weight + 1 ) : squares [ squareId ] . weight ; lines [ lineId ] . weight += squareWeight * squares [ squareId ] . value ; } } } }
Update weight of all lines adjacent to picked square
 @param {Number} squareId
Update weight of all lines adjacent to picked square @param { Number } squareId
// Put highest weight if only one line is missing - picking means immediate earning of square // Put lowest weight if only two line are missing - picking means almost 100% surety that user will by next move claim this square // Put weight based on weight and value of square