Skip to content

distvan/ttt-php-ai

Repository files navigation

Tic-Tac-Toe with AI backend example

The repository contains an example application for demonstration/educational purpose.

I designed the application and replaced the other person with an AI model. I created a frontend using JavaScript and HTML. The frontend communicates with the backend, which is written in PHP, via an API. The backend generates a prompt, processes the AI's response, and sends it to the frontend to display the result.

Game Rules

The game is played by two people who take turns marking on X or an O on a 3x3 grid. The first person to mark three of their signs in a horizontal, vertical, or diagonal row is the winner.

Settings

See the .env variable, here you can set any LLM model or if the OPENAI_API_URL variable is empty the local minimax AI algorithm be used.

Testing

For backend run: composer test
For frontend run: npm run test-win or npm run test-unix

🌐 Join Me on CoderLegion

CoderLegion Check out my articles and community posts on CoderLegion!

About

Tic Tac Toe application with AI support in PHP

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published