Super Tic-Tac-Toe is an advanced version of the classic Tic-Tac-Toe game. This project includes both the game logic implemented in JavaScript and an Express.js server that saves game data to a PostgreSQL database. The game uses EJS templating for rendering the game history.
- Features
- Installation
- Usage
- Game Rules
- Database Schema
- Endpoints
- Technologies Used
- Contributing
- License
- Play Super Tic-Tac-Toe in your browser.
- Save game data (winner, X moves, Y moves) to a PostgreSQL database.
- View game history with EJS templating.
-
Clone the repository:
git clone https://github.com/mihir2004/superTicTacToe.git cd superTicTacToe
-
Install dependencies:
npm install
-
Set up your PostgreSQL database:
Create a PostgreSQL database and update the database configuration in the Express server.
-
Create the database table:
CREATE TABLE game_data ( id SERIAL PRIMARY KEY, winner VARCHAR(10) NOT NULL, x_moves INTEGER[] NOT NULL, y_moves INTEGER[] NOT NULL, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP );
-
Start the Express server:
npm start
-
Open your browser and navigate to:
http://localhost:3000
-
Play the game and view the game history at:
http://localhost:3000/gameHistory
- The game board consists of 9 mini Tic-Tac-Toe boards arranged in a 3x3 grid.
- Players take turns playing on the mini boards.
- The first player to win three mini boards in a row (horizontally, vertically, or diagonally) wins the game.
- The location of the next move is determined by the position of the previous move.
The game_data
table stores the game results:
CREATE TABLE game_data (
id SERIAL PRIMARY KEY,
winner VARCHAR(10) NOT NULL,
x_moves INTEGER[] NOT NULL,
y_moves INTEGER[] NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
GET/:
Displays the game board.
POST/move:
Submits a move.
GET/gameHistory:
Displays the game history.
- JavaScript
- Express.js
- EJS
- PostgreSQL
- HTML
- CSS
- Fork the repository.
- Create a new branch (git checkout -b feature-branch).
- Make your changes and commit them (git commit -m 'Add some feature').
- Push to the branch (git push origin feature-branch).
- Open a pull request.
This structure ensures that the endpoints, technologies used, and contributing guidelines are placed in their respective sections, making the README.md
clear and well-organized.