This project assignment, Recursion And Beyond, introduces students to recursive problem-solving through classic computational challenges: the Towers of Hanoi and the Minimax algorithm for Tic-Tac-Toe. Each student will implement solutions in dedicated agent.js
files to explore recursive functions, dynamic strategies, and optimal decision-making.
- Overview
- Project Structure
- Getting Started
- Assignment Details
- Running the Project
- Testing
- Additional Resources
In this assignment, students will focus on implementing recursive algorithms in JavaScript. The tasks include solving both standard and extended versions of the Towers of Hanoi and implementing the Minimax algorithm for an AI-powered Tic-Tac-Toe game. Both assignments are structured in their own directories within src/components/Applications
, with each containing an agent.js
file where students will complete their recursive implementations.
Below is a simplified outline of the main project structure:
recursion-and-beyond/
├── public/
│ └── img/ # Project images for Hanoi and Tic-Tac-Toe
├── src/
│ ├── components/
│ │ ├── Applications/
│ │ │ ├── Hanoi/
│ │ │ │ ├── agent.js # Complete Hanoi problem solutions here
│ │ │ │ └── * # Components for Hanoi problem UI
│ │ │ └── Tic Tac Toe/
│ │ │ ├── agent.js # Complete Minimax implementation here
│ │ │ └── * # Components for Tic-Tac-Toe game UI
│ │ └── Sections/
├── package.json # Project dependencies and scripts
├── vite.config.js # Vite configuration
└── README.md # Project documentation
-
Fork the Repository:
Start by forking this repository to your own GitHub account.
-
Clone the Forked Repository:
git clone https://github.com/Aryanoor/Recursion-And-Beyond.git cd recursion-and-beyond
-
Install Dependencies:
npm install
-
Start the Development Server:
npm run dev
This starts a local server on
http://localhost:5173
, where you can interact with the application.
Each task is outlined below, with guidance on where to implement code.
The Towers of Hanoi problem challenges students to move disks between rods while following specific rules. The Classic Towers of Hanoi involves three rods and a variable number of disks, whereas the Extended Towers of Hanoi introduces additional constraints or rods.
- Location: Implement recursive solutions in
src/components/Applications/Hanoi/agent.js
. - Requirements:
- Create a recursive function that outputs each move from one rod to another.
- Extended problems may require variations in the recursive logic to accommodate extra constraints.
The Minimax algorithm is widely used in AI to ensure optimal decision-making in games. This project applies Minimax to a Tic-Tac-Toe game, allowing the AI agent to always make the best move, resulting in either a win or a tie.
- Location: Implement the minimax logic in
src/components/Applications/Tic Tac Toe/agent.js
. - Requirements:
- Develop a recursive algorithm that evaluates each possible move and chooses the optimal path.
- Ensure edge cases (like a full board or guaranteed win/loss situations) are handled.
To run the project in development mode:
npm run dev
This will launch the application and provide an interactive UI for both the Towers of Hanoi and Tic-Tac-Toe game, where you can test and verify the recursive functions.
- Use the UI for each task to verify your solution.
- Each step or move should be checked against the expected outcomes (e.g., Hanoi steps and Tic-Tac-Toe AI moves).
This project offers an in-depth exploration of recursion and algorithmic thinking. Good luck, and happy coding!