Skip to main content

TicTacToe

@site/src/components/TicTacToe/index.js
  const handleClick = (index) => {
const currentBoard = boardRef.current;
if (currentBoard[index] || winner) return;

const currentPlayer = playerRef.current;
console.log('Current player:', currentPlayer, 'Placing at index:', index);

const newBoard = [...currentBoard];
newBoard[index] = currentPlayer;
setBoard(newBoard);
boardRef.current = newBoard;

const positionName = getPositionName(index);
speak(`${currentPlayer} has been placed in ${positionName}`);

const gameWinner = checkWinner(newBoard);
if (gameWinner) {
console.log('Winner found:', gameWinner);
setWinner(gameWinner);
setTimeout(() => {
speak(`Player ${gameWinner} wins!`);
}, 1000);
} else if (newBoard.every(cell => cell !== '')) {
console.log('Draw - board is full');
setWinner('draw');
setTimeout(() => {
speak("It's a draw!");
}, 1000);
} else {
const nextPlayer = currentPlayer === 'X' ? 'O' : 'X';
console.log('Switching from', currentPlayer, 'to', nextPlayer);
setPlayer(nextPlayer);
playerRef.current = nextPlayer;
setTimeout(() => {
speak(`It's ${nextPlayer}'s turn`);
}, 1500);
}
};

🎮 Tic Tac Toe with Voice Control

AAC Board API Test Interface

API: ❌ Disconnected

Current Player: X

📡 API Log

No API activity yet. Try using voice commands!

🗣️ Voice Commands

Positions: "top left", "center", "bottom right", etc.

Numbers: "one" through "nine" (1-9)

Control: "new game", "reset", "stop listening", "help"

@site/src/components/TicTacToe/index.js
      const response = await fetch('http://localhost:8080/upload', {
method: 'POST',
body: formData
});

...
/Initial_API/index.js
            res.status(200).send({
message: 'Audio processed successfully',
transcription: result.trim(),
filename: req.file.originalname,
size: req.file.size + ' bytes'
});