Все, что вы должны сделать, чтобы изменить button.text:
button.text = "something";
Но для вашего второго вопроса ваш Ai должен быть примерно таким:
try{
for(var k =-1;k<2;k++){ //k is the parameter responsible for previous and
//next also up and down cells and even also the upper right , bottom right,bottom left and bottom right cells.
for(var i =0;k<3;i++)
{
for(var j =0;k<3;j++)
{
if(x[i,j]==x[i+k,j+k] && ((i+k<3)&&(j+k<3)) //checks if there is two cells having the same "X" in a row.
{
button.text = "O"
}
}
}
}
}
catch(Exception e){
//nothing
}
Я положилблоки try catch, чтобы избежать ошибок индекса.