No encuentro la solucion

estoy haciendo un tres en raya, pero quería complicar la cosa un poco más y quería poner modo automático, es decir, jugar con la máquina.

Llevo 1 semana intentándolo, por eso estoy aqui. Me gustaría saber como lo haríais vosotros.

Si me poneis un poco de explicacion en forma de comentarios en el JS lo agradeceria muchisimo.

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

 



let turno = 0;
const tablero = ()

    const mustaClick = (e, pos) =>{
    
    turno = turno + 1;
    const love = e.target;
    const color = turno % 2 ? 'Salmon':'Green';
    love.style.backgroundColor = color;
    
    tablero(pos) = color;
    if(haGanado())alert('Good game bro' + ' ' + color);

}

haGanado = () => {
    if(tablero(0) == tablero(1) && tablero(0) == tablero(2) && tablero(0)){
        return true;  
    }else if(tablero(3) == tablero(4) && tablero(3) == tablero(5) && tablero(3)){
        return true;
    }else if(tablero(6) == tablero(7) && tablero(6) == tablero(8) && tablero(6)){
        return true;
    }else if(tablero(0) == tablero(3) && tablero(0) == tablero(6) && tablero(0)){
        return true;
    }else if(tablero(1) == tablero(4) && tablero(1) == tablero(7) && tablero(1)){
        return true;
    }else if(tablero(2) == tablero(5) && tablero(2) == tablero(8) && tablero(2)){
        return true;
    }else if(tablero(0) == tablero(4) && tablero(0) == tablero(8) && tablero(0)){
        return true;
    }else if(tablero(2) == tablero(4) && tablero(2) == tablero(6) && tablero(2)){
        return true;
    }
    return false;
}

document.querySelectorAll('button').forEach((obj, i) => obj.addEventListener('click', (e) => mustaClick(e, i)))
 



button{
   width: 150px;
   height: 150px;
}

.contenedor {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    width: 450px;
    margin: auto;

}
</head>
<body>

    <div class="contenedor">
    <button></button>
    <button></button>
    <button></button>
    <button></button>
    <button></button>
    <button></button>
    <button></button>
    <button></button>
    <button></button>

</div>

    <script src="https://es.stackoverflow.com/Scripttresenraya.js"></script>
    
</body>
</html>