0% found this document useful (0 votes)
16 views6 pages

Ai Algo Reference

The document outlines various algorithms and techniques for solving optimization and game-related problems, including hill climbing, A* search, and adversarial search for games like Tic-Tac-Toe and Snake and Ladder. It also describes logical reasoning for the monkey and banana problem, knowledge base querying in Prolog, and combinatorial problems like the N-Queens and Travelling Salesman Problem. Additionally, it includes a multi-agent maze game simulation and information retrieval using SPARQL from DBpedia.

Uploaded by

venkat Mohan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views6 pages

Ai Algo Reference

The document outlines various algorithms and techniques for solving optimization and game-related problems, including hill climbing, A* search, and adversarial search for games like Tic-Tac-Toe and Snake and Ladder. It also describes logical reasoning for the monkey and banana problem, knowledge base querying in Prolog, and combinatorial problems like the N-Queens and Travelling Salesman Problem. Additionally, it includes a multi-agent maze game simulation and information retrieval using SPARQL from DBpedia.

Uploaded by

venkat Mohan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

1.

Hill Climbing Problem


Aim:
To find an optimal or near-optimal solution for a graph-based
optimization problem using the hill climbing technique.
Algorithm:
1. Input the graph as an adjacency matrix.
2. Generate an initial random path.
3. Calculate the total cost of the current path.
4. For a fixed number of iterations, generate neighbor solutions by
swapping nodes.
5. Calculate the cost of each neighbor.
6. Replace the current path if a better (lower cost) path is found.
7. Return the best path and its cost.

2. A Search Algorithm*
Aim:
To find the shortest path from a source to a destination in a grid using
the A* search algorithm.
Algorithm:
1. Initialize source and destination nodes and create an open list
(min-heap).
2. Calculate the f = g + h value for each cell.
3. Select the node with the lowest f from the open list.
4. Explore valid, unblocked neighbors and update their parent, g,
h, f values.
5. If destination is reached, trace the path using parent pointers.
6. Repeat until the destination is found or open list is empty.
7. Print the path or indicate if no path is found.

3. Tic-Tac-Toe (Adversarial Search)


Aim:
To implement a Tic-Tac-Toe game using the Minimax algorithm where
AI plays optimally.
Algorithm:
1. Initialize an empty 3x3 board.
2. Let the user and AI play alternately.
3. Use the minimax function to determine the best move for AI.
4. Evaluate the board recursively for max (AI) and min (user)
moves.
5. Check for winning or draw conditions after each move.
6. Repeat until the game ends.
7. Display the winner or a draw.

4. Snake and Ladder (Adversarial Search)


Aim:
To simulate a turn-based Snake and Ladder game between a human
and AI.
Algorithm:
1. Initialize player positions at 0.
2. Roll the dice to generate moves.
3. Update player position and check for snakes or ladders.
4. Skip moves if position exceeds 100.
5. Alternate turns between human and AI.
6. Declare winner when a player reaches 100.
7. Repeat until game ends.

5. Rock, Paper, Scissors (Adversarial Search)


Aim:
To develop a Rock, Paper, Scissors game where the user plays against
AI.
Algorithm:
1. Define the choices: rock, paper, scissors.
2. Accept the user’s input.
3. Generate AI’s choice randomly.
4. Compare user and AI choices to decide the winner.
5. Display result.
6. Repeat until user quits.
7. Handle invalid inputs.

6. Monkey and Banana (First Order Logic)


Aim:
To simulate the monkey and banana problem using logical reasoning
and action rules.
Algorithm:
1. Define state transitions (move, climb, drag, walk, grasp).
2. Set goal state: monkey has banana.
3. Use recursive rules to derive action sequence.
4. Base case: if goal state is reached, return solution.
5. Recursive case: apply valid moves to transition states.
6. Trace the action path.
7. Display sequence of actions.

7. FOL Knowledge Base (Facts & Rules)


Aim:
To define a knowledge base and query it using first-order logic in
Prolog.
Algorithm:
1. Define facts (likes, hates, owns, father, female, etc.).
2. Define rules (e.g., may_steal(X, Y)).
3. Use Prolog queries to test the knowledge base.
4. Evaluate queries based on fact matching and rule inference.
5. Return true, false, or variable matches.
6. Support logical conjunctions and disjunctions in queries.
7. Allow dynamic knowledge exploration.

8. N-Queens Problem
Aim:
To place N queens on an N×N chessboard such that no two queens
attack each other.
Algorithm:
1. Initialize an N×N board with zeros.
2. Start from column 0 and recursively try placing a queen in each
row.
3. Check if placement is safe (row, left diagonal, right diagonal).
4. If safe, place queen and proceed to next column.
5. If all queens are placed, save the solution.
6. If no placement is possible, backtrack.
7. Print the last found solution.

9. Travelling Salesman Problem (TSP)


Aim:
To find the shortest possible route that visits each city exactly once
and returns to the origin city.
Algorithm:
1. Input cities and their pairwise distances.
2. Generate all permutations of city paths starting from one city.
3. Calculate total travel cost for each path.
4. Track the path with the minimum cost.
5. Return the optimal path and its cost.
6. Use brute-force method for small inputs.
7. Display the final route.

10. Multi-Agent Maze Game


Aim:
To simulate a player navigating a maze using arrow keys in a GUI
environment.
Algorithm:
1. Define a 2D array representing the maze layout.
2. Create a graphical interface using Tkinter.
3. Draw the maze with walls and paths.
4. Place player at start position and goal at end position.
5. Bind arrow keys to move the player.
6. Check for valid moves (no wall).
7. Display a success message when goal is reached.

11. Information Retrieval using SPARQL


Aim:
To retrieve abstract information of a person using SPARQL queries
from DBpedia.
Algorithm:
1. Connect to DBpedia endpoint using SPARQLWrapper.
2. Formulate a SPARQL query using the person’s name.
3. Retrieve abstract description in English.
4. Parse and extract URI and abstract.
5. Display only the first 50 words of the abstract.
6. Handle invalid inputs and formatting.
7. Output the information to the user.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy