fighter1107a 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of fighter1107a might be problematic. Click here for more details.
- fighter1107a-0.1.0/PKG-INFO +26 -0
- fighter1107a-0.1.0/README.md +19 -0
- fighter1107a-0.1.0/fighter1107a/__init__.py +1 -0
- fighter1107a-0.1.0/fighter1107a/cli.py +91 -0
- fighter1107a-0.1.0/fighter1107a/codes/A search.py +58 -0
- fighter1107a-0.1.0/fighter1107a/codes/Assignment1.1_38_12411944.py +38 -0
- fighter1107a-0.1.0/fighter1107a/codes/Assignment1_38_12411944.py +35 -0
- fighter1107a-0.1.0/fighter1107a/codes/Assignment5_38_12411944.py +62 -0
- fighter1107a-0.1.0/fighter1107a/codes/Assignment7_38_12411944.py +47 -0
- fighter1107a-0.1.0/fighter1107a/codes/Assignment8_38_12411944.py +46 -0
- fighter1107a-0.1.0/fighter1107a/codes/Assignment9_38_12411944.py +39 -0
- fighter1107a-0.1.0/fighter1107a/codes/BFS.py +45 -0
- fighter1107a-0.1.0/fighter1107a/codes/DFS.py +44 -0
- fighter1107a-0.1.0/fighter1107a/codes/Graph Colouring.py +50 -0
- fighter1107a-0.1.0/fighter1107a/codes/Greedy Best-First Search.py +51 -0
- fighter1107a-0.1.0/fighter1107a/codes/UCS.py +39 -0
- fighter1107a-0.1.0/fighter1107a.egg-info/PKG-INFO +26 -0
- fighter1107a-0.1.0/fighter1107a.egg-info/SOURCES.txt +21 -0
- fighter1107a-0.1.0/fighter1107a.egg-info/dependency_links.txt +1 -0
- fighter1107a-0.1.0/fighter1107a.egg-info/entry_points.txt +2 -0
- fighter1107a-0.1.0/fighter1107a.egg-info/top_level.txt +1 -0
- fighter1107a-0.1.0/pyproject.toml +20 -0
- fighter1107a-0.1.0/setup.cfg +4 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: fighter1107a
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Print AI in Software Engineering lab assignment codes in the terminal
|
|
5
|
+
Requires-Python: >=3.8
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
|
|
8
|
+
# fighter1107a (`aise`)
|
|
9
|
+
|
|
10
|
+
Simple cross-platform CLI to print all 12 AI in Software Engineering assignment Python codes directly in the terminal (without downloading or creating files).
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
aise # Open interactive menu
|
|
16
|
+
aise 1.0 # Print Vacuum Cleaner Reflex Agent
|
|
17
|
+
aise 1.1 # Print Lift Reflex Agent
|
|
18
|
+
aise 2 # Print BFS and DFS (or: aise bfs / aise dfs)
|
|
19
|
+
aise 3 # Print Uniform Cost Search (UCS)
|
|
20
|
+
aise 4 # Print GBFS and A* (or: aise gbfs / aise astar)
|
|
21
|
+
aise 5 # Print Hill Climbing (8-Queens)
|
|
22
|
+
aise 6 # Print Graph Coloring CSP (Backtracking)
|
|
23
|
+
aise 7 # Print AI SRS / User Stories / Docs Generator
|
|
24
|
+
aise 8 # Print AI Code Generator & Reviewer
|
|
25
|
+
aise 9 # Print AI Bug Detector & Unit Test Generator
|
|
26
|
+
```
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# fighter1107a (`aise`)
|
|
2
|
+
|
|
3
|
+
Simple cross-platform CLI to print all 12 AI in Software Engineering assignment Python codes directly in the terminal (without downloading or creating files).
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
aise # Open interactive menu
|
|
9
|
+
aise 1.0 # Print Vacuum Cleaner Reflex Agent
|
|
10
|
+
aise 1.1 # Print Lift Reflex Agent
|
|
11
|
+
aise 2 # Print BFS and DFS (or: aise bfs / aise dfs)
|
|
12
|
+
aise 3 # Print Uniform Cost Search (UCS)
|
|
13
|
+
aise 4 # Print GBFS and A* (or: aise gbfs / aise astar)
|
|
14
|
+
aise 5 # Print Hill Climbing (8-Queens)
|
|
15
|
+
aise 6 # Print Graph Coloring CSP (Backtracking)
|
|
16
|
+
aise 7 # Print AI SRS / User Stories / Docs Generator
|
|
17
|
+
aise 8 # Print AI Code Generator & Reviewer
|
|
18
|
+
aise 9 # Print AI Bug Detector & Unit Test Generator
|
|
19
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""fighter1107a package providing the `aise` terminal command."""
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
from importlib.resources import files
|
|
3
|
+
|
|
4
|
+
ASSIGNMENTS = [
|
|
5
|
+
("1.0", "Simple Reflex Agent (Vacuum Cleaner)", "Assignment1_38_12411944.py"),
|
|
6
|
+
("1.1", "Simple Reflex Agent (Lift Operation)", "Assignment1.1_38_12411944.py"),
|
|
7
|
+
("2.1", "Breadth-First Search (BFS)", "BFS.py"),
|
|
8
|
+
("2.2", "Depth-First Search (DFS)", "DFS.py"),
|
|
9
|
+
("3", "Uniform Cost Search (UCS)", "UCS.py"),
|
|
10
|
+
("4.1", "Greedy Best-First Search", "Greedy Best-First Search.py"),
|
|
11
|
+
("4.2", "A* Search Algorithm", "A search.py"),
|
|
12
|
+
("5", "Hill Climbing (8-Queens)", "Assignment5_38_12411944.py"),
|
|
13
|
+
("6", "CSP Backtracking (Graph Coloring)", "Graph Colouring.py"),
|
|
14
|
+
("7", "AI SRS / User Stories / Docs", "Assignment7_38_12411944.py"),
|
|
15
|
+
("8", "AI Code Generator & Reviewer", "Assignment8_38_12411944.py"),
|
|
16
|
+
("9", "AI Bug Detector & Unit Tests", "Assignment9_38_12411944.py"),
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
ALIASES = {
|
|
20
|
+
"1": ["1.0"],
|
|
21
|
+
"vacuum": ["1.0"],
|
|
22
|
+
"lift": ["1.1"],
|
|
23
|
+
"2": ["2.1", "2.2"],
|
|
24
|
+
"bfs": ["2.1"],
|
|
25
|
+
"dfs": ["2.2"],
|
|
26
|
+
"ucs": ["3"],
|
|
27
|
+
"4": ["4.1", "4.2"],
|
|
28
|
+
"gbfs": ["4.1"],
|
|
29
|
+
"astar": ["4.2"],
|
|
30
|
+
"a*": ["4.2"],
|
|
31
|
+
"hc": ["5"],
|
|
32
|
+
"queens": ["5"],
|
|
33
|
+
"csp": ["6"],
|
|
34
|
+
"srs": ["7"],
|
|
35
|
+
"review": ["8"],
|
|
36
|
+
"test": ["9"],
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
BY_KEY = {key: (title, fname) for key, title, fname in ASSIGNMENTS}
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def print_code(keys):
|
|
43
|
+
codes_dir = files("fighter1107a").joinpath("codes")
|
|
44
|
+
for idx, key in enumerate(keys):
|
|
45
|
+
title, fname = BY_KEY[key]
|
|
46
|
+
content = codes_dir.joinpath(fname).read_text(encoding="utf-8")
|
|
47
|
+
if len(keys) > 1:
|
|
48
|
+
if idx > 0:
|
|
49
|
+
print()
|
|
50
|
+
print(f"# === [{key}] {title} ({fname}) ===")
|
|
51
|
+
print(content, end="" if content.endswith("\n") else "\n")
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def resolve_choice(raw):
|
|
55
|
+
choice = raw.strip().lower()
|
|
56
|
+
if choice in BY_KEY:
|
|
57
|
+
return [choice]
|
|
58
|
+
if choice in ALIASES:
|
|
59
|
+
return ALIASES[choice]
|
|
60
|
+
return None
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def show_menu():
|
|
64
|
+
print("AI in Software Engineering - Assignments (Print Only)")
|
|
65
|
+
print("-" * 55)
|
|
66
|
+
for key, title, _ in ASSIGNMENTS:
|
|
67
|
+
print(f" {key:<4} : {title}")
|
|
68
|
+
print("-" * 55)
|
|
69
|
+
print("Tip: You can also run directly, e.g. `aise 3` or `aise bfs`")
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def main():
|
|
73
|
+
if len(sys.argv) > 1:
|
|
74
|
+
arg = " ".join(sys.argv[1:])
|
|
75
|
+
keys = resolve_choice(arg)
|
|
76
|
+
if not keys:
|
|
77
|
+
print(f"Unknown assignment '{arg}'. Run `aise` to see options.", file=sys.stderr)
|
|
78
|
+
sys.exit(1)
|
|
79
|
+
print_code(keys)
|
|
80
|
+
return
|
|
81
|
+
|
|
82
|
+
show_menu()
|
|
83
|
+
choice = input("\nEnter assignment number/name (or q to quit): ").strip()
|
|
84
|
+
if choice.lower() in ("q", "quit", "exit", ""):
|
|
85
|
+
return
|
|
86
|
+
keys = resolve_choice(choice)
|
|
87
|
+
if not keys:
|
|
88
|
+
print(f"Invalid choice '{choice}'.")
|
|
89
|
+
sys.exit(1)
|
|
90
|
+
print()
|
|
91
|
+
print_code(keys)
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import heapq
|
|
2
|
+
|
|
3
|
+
graph = {
|
|
4
|
+
'A': {'B': 4, 'C': 2, 'D': 6},
|
|
5
|
+
'B': {'A': 4, 'E': 5},
|
|
6
|
+
'C': {'A': 2, 'E': 3, 'F': 2},
|
|
7
|
+
'D': {'A': 6, 'F': 4},
|
|
8
|
+
'E': {'B': 5, 'C': 3, 'H': 5},
|
|
9
|
+
'F': {'C': 2, 'D': 4, 'G': 2},
|
|
10
|
+
'G': {'F': 2, 'H': 1},
|
|
11
|
+
'H': {'E': 5, 'G': 1}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
# Admissible and consistent heuristic h(n) <= actual shortest distance to G
|
|
15
|
+
h = {
|
|
16
|
+
'A': 5,
|
|
17
|
+
'B': 8,
|
|
18
|
+
'C': 4,
|
|
19
|
+
'D': 5,
|
|
20
|
+
'E': 5,
|
|
21
|
+
'F': 2,
|
|
22
|
+
'G': 0,
|
|
23
|
+
'H': 1
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def astar(graph, h, source, destination):
|
|
28
|
+
pq = [(h[source], 0, source, [source])]
|
|
29
|
+
visited = set()
|
|
30
|
+
g_values = {source: 0}
|
|
31
|
+
|
|
32
|
+
while pq:
|
|
33
|
+
f_value, g, node, path = heapq.heappop(pq)
|
|
34
|
+
|
|
35
|
+
if node in visited:
|
|
36
|
+
continue
|
|
37
|
+
|
|
38
|
+
visited.add(node)
|
|
39
|
+
print(f"Visited {node} (g = {g}, h = {h[node]}, f = {f_value})")
|
|
40
|
+
|
|
41
|
+
if node == destination:
|
|
42
|
+
print("Shortest path:", " -> ".join(path))
|
|
43
|
+
print("Total cost:", g)
|
|
44
|
+
return g, path
|
|
45
|
+
|
|
46
|
+
for neighbour, cost in graph[node].items():
|
|
47
|
+
if neighbour not in visited:
|
|
48
|
+
new_g = g + cost
|
|
49
|
+
if neighbour not in g_values or new_g < g_values[neighbour]:
|
|
50
|
+
g_values[neighbour] = new_g
|
|
51
|
+
new_f = new_g + h[neighbour]
|
|
52
|
+
heapq.heappush(pq, (new_f, new_g, neighbour, path + [neighbour]))
|
|
53
|
+
|
|
54
|
+
print("Solution not found")
|
|
55
|
+
return None, []
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
astar(graph, h, 'A', 'G')
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
def reflex_lift_agent(current_floor, target_floor):
|
|
2
|
+
if target_floor > current_floor:
|
|
3
|
+
return "MOVE_UP"
|
|
4
|
+
elif target_floor < current_floor:
|
|
5
|
+
return "MOVE_DOWN"
|
|
6
|
+
else:
|
|
7
|
+
return "OPEN_DOOR"
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
total_floors = int(input("Enter total number of floors: "))
|
|
11
|
+
current_floor = 1
|
|
12
|
+
print("Lift is currently on Floor", current_floor)
|
|
13
|
+
|
|
14
|
+
while True:
|
|
15
|
+
target = int(input(f"\nEnter destination floor (1-{total_floors}, or 0 to exit): "))
|
|
16
|
+
|
|
17
|
+
if target == 0:
|
|
18
|
+
print("Lift system turned off.")
|
|
19
|
+
break
|
|
20
|
+
|
|
21
|
+
if target < 1 or target > total_floors:
|
|
22
|
+
print("Invalid Floor!")
|
|
23
|
+
continue
|
|
24
|
+
|
|
25
|
+
while True:
|
|
26
|
+
action = reflex_lift_agent(current_floor, target)
|
|
27
|
+
print(f"Percept: (Current={current_floor}, Target={target}) -> Action: {action}")
|
|
28
|
+
|
|
29
|
+
if action == "MOVE_UP":
|
|
30
|
+
current_floor += 1
|
|
31
|
+
print("Reached Floor", current_floor)
|
|
32
|
+
elif action == "MOVE_DOWN":
|
|
33
|
+
current_floor -= 1
|
|
34
|
+
print("Reached Floor", current_floor)
|
|
35
|
+
elif action == "OPEN_DOOR":
|
|
36
|
+
print("Destination Reached")
|
|
37
|
+
print("Door Open -> Passenger Enter/Exit -> Door Close")
|
|
38
|
+
break
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
def reflex_vacuum_agent(location, status):
|
|
2
|
+
if status == "dirty":
|
|
3
|
+
return "Suck"
|
|
4
|
+
elif location == "A":
|
|
5
|
+
return "Right"
|
|
6
|
+
elif location == "B":
|
|
7
|
+
return "Left"
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
rooms = {}
|
|
11
|
+
rooms["A"] = input("Enter status of Room A (clean/dirty): ").strip().lower()
|
|
12
|
+
rooms["B"] = input("Enter status of Room B (clean/dirty): ").strip().lower()
|
|
13
|
+
location = input("Enter starting location (A/B): ").strip().upper()
|
|
14
|
+
|
|
15
|
+
if location not in ["A", "B"] or rooms["A"] not in ["clean", "dirty"] or rooms["B"] not in ["clean", "dirty"]:
|
|
16
|
+
print("Invalid input!")
|
|
17
|
+
else:
|
|
18
|
+
for _ in range(4):
|
|
19
|
+
status = rooms[location]
|
|
20
|
+
if rooms["A"] == "clean" and rooms["B"] == "clean":
|
|
21
|
+
print(f"Percept: ({location}, {status}) -> Action: NoOp")
|
|
22
|
+
break
|
|
23
|
+
|
|
24
|
+
action = reflex_vacuum_agent(location, status)
|
|
25
|
+
print(f"Percept: ({location}, {status}) -> Action: {action}")
|
|
26
|
+
|
|
27
|
+
if action == "Suck":
|
|
28
|
+
rooms[location] = "clean"
|
|
29
|
+
print(f"Room {location} is cleaned.")
|
|
30
|
+
elif action == "Right":
|
|
31
|
+
location = "B"
|
|
32
|
+
elif action == "Left":
|
|
33
|
+
location = "A"
|
|
34
|
+
|
|
35
|
+
print("Both rooms are clean. Turning off.")
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import random
|
|
2
|
+
|
|
3
|
+
N = 8
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def heuristic(state):
|
|
7
|
+
attacks = 0
|
|
8
|
+
for i in range(N):
|
|
9
|
+
for j in range(i + 1, N):
|
|
10
|
+
if state[i] == state[j] or abs(state[i] - state[j]) == abs(i - j):
|
|
11
|
+
attacks += 1
|
|
12
|
+
return attacks
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def show_board(state):
|
|
16
|
+
for r in range(N):
|
|
17
|
+
row = ["Q" if state[c] == r else "." for c in range(N)]
|
|
18
|
+
print(" ".join(row))
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def hill_climbing(state):
|
|
22
|
+
current = state[:]
|
|
23
|
+
current_h = heuristic(current)
|
|
24
|
+
|
|
25
|
+
while True:
|
|
26
|
+
best_state = current
|
|
27
|
+
best_h = current_h
|
|
28
|
+
|
|
29
|
+
for col in range(N):
|
|
30
|
+
for row in range(N):
|
|
31
|
+
if row == current[col]:
|
|
32
|
+
continue
|
|
33
|
+
neighbor = current[:]
|
|
34
|
+
neighbor[col] = row
|
|
35
|
+
h = heuristic(neighbor)
|
|
36
|
+
if h < best_h:
|
|
37
|
+
best_h = h
|
|
38
|
+
best_state = neighbor
|
|
39
|
+
|
|
40
|
+
if best_h >= current_h:
|
|
41
|
+
break
|
|
42
|
+
|
|
43
|
+
current = best_state
|
|
44
|
+
current_h = best_h
|
|
45
|
+
|
|
46
|
+
return current, current_h
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
initial_state = [random.randint(0, N - 1) for _ in range(N)]
|
|
50
|
+
print("Initial State:", initial_state)
|
|
51
|
+
print("Initial Heuristic (Attacking Pairs):", heuristic(initial_state))
|
|
52
|
+
show_board(initial_state)
|
|
53
|
+
|
|
54
|
+
final_state, final_h = hill_climbing(initial_state)
|
|
55
|
+
print("\nFinal State:", final_state)
|
|
56
|
+
print("Final Heuristic (Attacking Pairs):", final_h)
|
|
57
|
+
show_board(final_state)
|
|
58
|
+
|
|
59
|
+
if final_h == 0:
|
|
60
|
+
print("\nSolution Found: 8-Queens solved!")
|
|
61
|
+
else:
|
|
62
|
+
print("\nStopped at Local Minimum (no better neighbor).")
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import google.generativeai as genai
|
|
2
|
+
|
|
3
|
+
API_KEY = "YOUR_GEMINI_API_KEY" # Insert your Gemini API key here
|
|
4
|
+
genai.configure(api_key=API_KEY)
|
|
5
|
+
model = genai.GenerativeModel("gemini-2.5-flash")
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def ask_ai(prompt):
|
|
9
|
+
try:
|
|
10
|
+
response = model.generate_content(prompt)
|
|
11
|
+
return response.text
|
|
12
|
+
except Exception as e:
|
|
13
|
+
return f"API Error: {e}"
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
print("1. Generate SRS (IEEE 830)")
|
|
17
|
+
print("2. Generate User Stories")
|
|
18
|
+
print("3. Generate Software Documentation")
|
|
19
|
+
choice = input("Choose option (1/2/3): ")
|
|
20
|
+
|
|
21
|
+
project = input("Enter project name: ")
|
|
22
|
+
features = input("Enter project description / key features: ")
|
|
23
|
+
|
|
24
|
+
if choice == "1":
|
|
25
|
+
prompt = (
|
|
26
|
+
f"Generate a Software Requirements Specification (SRS) following IEEE 830 "
|
|
27
|
+
f"for '{project}' with features: {features}. "
|
|
28
|
+
f"Include: 1. Introduction, 2. Overall Description, "
|
|
29
|
+
f"3. Functional Requirements, 4. Non-Functional Requirements."
|
|
30
|
+
)
|
|
31
|
+
elif choice == "2":
|
|
32
|
+
prompt = (
|
|
33
|
+
f"Generate Agile User Stories with Acceptance Criteria for '{project}' "
|
|
34
|
+
f"with features: {features}. "
|
|
35
|
+
f"Format: As a <role>, I want <feature>, so that <benefit>."
|
|
36
|
+
)
|
|
37
|
+
elif choice == "3":
|
|
38
|
+
prompt = (
|
|
39
|
+
f"Generate Software Documentation for '{project}' with features: {features}. "
|
|
40
|
+
f"Include: Overview, Modules/Architecture, Setup, and Usage."
|
|
41
|
+
)
|
|
42
|
+
else:
|
|
43
|
+
print("Invalid choice!")
|
|
44
|
+
exit()
|
|
45
|
+
|
|
46
|
+
print("\n--- Generated Output ---\n")
|
|
47
|
+
print(ask_ai(prompt))
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import google.generativeai as genai
|
|
2
|
+
|
|
3
|
+
API_KEY = "YOUR_GEMINI_API_KEY" # Insert your Gemini API key here
|
|
4
|
+
genai.configure(api_key=API_KEY)
|
|
5
|
+
model = genai.GenerativeModel("gemini-2.5-flash")
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def ask_ai(prompt):
|
|
9
|
+
try:
|
|
10
|
+
response = model.generate_content(prompt)
|
|
11
|
+
return response.text
|
|
12
|
+
except Exception as e:
|
|
13
|
+
return f"API Error: {e}"
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
print("1. Generate Source Code")
|
|
17
|
+
print("2. Review Source Code")
|
|
18
|
+
choice = input("Choose option (1/2): ")
|
|
19
|
+
|
|
20
|
+
if choice == "1":
|
|
21
|
+
lang = input("Enter programming language (e.g. Python): ")
|
|
22
|
+
task = input("Describe what code to generate: ")
|
|
23
|
+
prompt = f"Write clean, well-commented {lang} code for: {task}. Also mention time complexity."
|
|
24
|
+
print("\n--- Generated Code ---\n")
|
|
25
|
+
print(ask_ai(prompt))
|
|
26
|
+
|
|
27
|
+
elif choice == "2":
|
|
28
|
+
print("Paste your code below (type END on a new line to finish):")
|
|
29
|
+
lines = []
|
|
30
|
+
while True:
|
|
31
|
+
line = input()
|
|
32
|
+
if line.strip() == "END":
|
|
33
|
+
break
|
|
34
|
+
lines.append(line)
|
|
35
|
+
code = "\n".join(lines)
|
|
36
|
+
|
|
37
|
+
prompt = (
|
|
38
|
+
f"Perform a code review on the following code:\n{code}\n\n"
|
|
39
|
+
f"Include: 1. Bugs/Errors, 2. Time & Space Complexity, "
|
|
40
|
+
f"3. Best Practices & Readability, 4. Improved Code."
|
|
41
|
+
)
|
|
42
|
+
print("\n--- Code Review Report ---\n")
|
|
43
|
+
print(ask_ai(prompt))
|
|
44
|
+
|
|
45
|
+
else:
|
|
46
|
+
print("Invalid choice!")
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import google.generativeai as genai
|
|
2
|
+
|
|
3
|
+
API_KEY = "YOUR_GEMINI_API_KEY" # Insert your Gemini API key here
|
|
4
|
+
genai.configure(api_key=API_KEY)
|
|
5
|
+
model = genai.GenerativeModel("gemini-2.5-flash")
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def ask_ai(prompt):
|
|
9
|
+
try:
|
|
10
|
+
response = model.generate_content(prompt)
|
|
11
|
+
return response.text
|
|
12
|
+
except Exception as e:
|
|
13
|
+
return f"API Error: {e}"
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
print("Paste your Python code below (type END on a new line to finish):")
|
|
17
|
+
lines = []
|
|
18
|
+
while True:
|
|
19
|
+
line = input()
|
|
20
|
+
if line.strip() == "END":
|
|
21
|
+
break
|
|
22
|
+
lines.append(line)
|
|
23
|
+
code = "\n".join(lines)
|
|
24
|
+
|
|
25
|
+
bug_prompt = (
|
|
26
|
+
f"Detect all bugs, logical errors, and edge-case issues in this Python code, "
|
|
27
|
+
f"and provide the corrected code:\n{code}"
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
test_prompt = (
|
|
31
|
+
f"Generate Python unit test cases using the unittest module for this Python code. "
|
|
32
|
+
f"Cover normal cases, edge cases, and exception handling:\n{code}"
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
print("\n--- Bug Detection Report ---\n")
|
|
36
|
+
print(ask_ai(bug_prompt))
|
|
37
|
+
|
|
38
|
+
print("\n--- Generated Unit Test Cases ---\n")
|
|
39
|
+
print(ask_ai(test_prompt))
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
def enqueue(queue, x):
|
|
2
|
+
queue.append(x)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def dequeue(queue):
|
|
6
|
+
if not queue:
|
|
7
|
+
print("Queue is Empty")
|
|
8
|
+
return None
|
|
9
|
+
return queue.pop(0)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def bfs(adj_matrix, start, labels):
|
|
13
|
+
n = len(adj_matrix)
|
|
14
|
+
visited = [False] * n
|
|
15
|
+
order = []
|
|
16
|
+
queue = []
|
|
17
|
+
enqueue(queue, start)
|
|
18
|
+
visited[start] = True
|
|
19
|
+
|
|
20
|
+
while queue:
|
|
21
|
+
node = dequeue(queue)
|
|
22
|
+
if node is None:
|
|
23
|
+
break
|
|
24
|
+
order.append(labels[node])
|
|
25
|
+
for neighbor in range(n):
|
|
26
|
+
if adj_matrix[node][neighbor] == 1 and not visited[neighbor]:
|
|
27
|
+
visited[neighbor] = True
|
|
28
|
+
enqueue(queue, neighbor)
|
|
29
|
+
|
|
30
|
+
return order
|
|
31
|
+
|
|
32
|
+
labels = ["A", "B", "C", "D", "E", "F", "G"]
|
|
33
|
+
|
|
34
|
+
adj = [
|
|
35
|
+
[0, 1, 1, 1, 0, 0, 0], # A
|
|
36
|
+
[1, 0, 0, 0, 1, 1, 0], # B
|
|
37
|
+
[1, 0, 0, 0, 0, 0, 1], # C
|
|
38
|
+
[1, 0, 0, 0, 0, 0, 0], # D
|
|
39
|
+
[0, 1, 0, 0, 0, 0, 0], # E
|
|
40
|
+
[0, 1, 0, 0, 0, 0, 0], # F
|
|
41
|
+
[0, 0, 1, 0, 0, 0, 0], # G
|
|
42
|
+
]
|
|
43
|
+
|
|
44
|
+
traversal = bfs(adj, 0, labels)
|
|
45
|
+
print("BFS order:", traversal)
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# DFS using an adjacency matrix and an explicit stack
|
|
2
|
+
|
|
3
|
+
adj = [
|
|
4
|
+
[0, 1, 1, 1, 0, 0, 0], # A
|
|
5
|
+
[1, 0, 0, 0, 1, 1, 0], # B
|
|
6
|
+
[1, 0, 0, 0, 0, 0, 1], # C
|
|
7
|
+
[1, 0, 0, 0, 0, 0, 0], # D
|
|
8
|
+
[0, 1, 0, 0, 0, 0, 0], # E
|
|
9
|
+
[0, 1, 0, 0, 0, 0, 0], # F
|
|
10
|
+
[0, 0, 1, 0, 0, 0, 0], # G
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
nodes = ['A', 'B', 'C', 'D', 'E', 'F', 'G']
|
|
14
|
+
visited = [False] * len(nodes)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def push(stack, item):
|
|
18
|
+
stack.append(item)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def pop(stack):
|
|
22
|
+
return stack.pop()
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def dfs(start):
|
|
26
|
+
stack = [start]
|
|
27
|
+
|
|
28
|
+
while stack:
|
|
29
|
+
node = pop(stack)
|
|
30
|
+
if visited[node]:
|
|
31
|
+
continue
|
|
32
|
+
|
|
33
|
+
visited[node] = True
|
|
34
|
+
print(nodes[node], end=' ')
|
|
35
|
+
|
|
36
|
+
for neighbor in range(len(adj[node])):
|
|
37
|
+
if adj[node][neighbor] == 1 and not visited[neighbor]:
|
|
38
|
+
push(stack, neighbor)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
print("DFS traversal:")
|
|
42
|
+
for node in range(len(nodes)):
|
|
43
|
+
if not visited[node]:
|
|
44
|
+
dfs(node)
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Graph Coloring using Adjacency Matrix
|
|
2
|
+
# With Backtracking
|
|
3
|
+
|
|
4
|
+
graph = [
|
|
5
|
+
[0, 1, 0, 1], # A
|
|
6
|
+
[1, 0, 1, 0], # B
|
|
7
|
+
[0, 1, 0, 1], # C
|
|
8
|
+
[1, 0, 1, 0] # D
|
|
9
|
+
]
|
|
10
|
+
|
|
11
|
+
vertices = ['A', 'B', 'C', 'D']
|
|
12
|
+
|
|
13
|
+
colors = ['Red', 'Blue', 'Green', 'Orange']
|
|
14
|
+
|
|
15
|
+
color = {}
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def backtracking(i):
|
|
19
|
+
|
|
20
|
+
if i == len(vertices):
|
|
21
|
+
return True
|
|
22
|
+
|
|
23
|
+
for c in colors:
|
|
24
|
+
|
|
25
|
+
safe = True
|
|
26
|
+
|
|
27
|
+
for j in range(len(vertices)):
|
|
28
|
+
|
|
29
|
+
if graph[i][j] == 1:
|
|
30
|
+
if vertices[j] in color and color[vertices[j]] == c:
|
|
31
|
+
safe = False
|
|
32
|
+
break
|
|
33
|
+
|
|
34
|
+
if safe:
|
|
35
|
+
color[vertices[i]] = c
|
|
36
|
+
|
|
37
|
+
if backtracking(i + 1):
|
|
38
|
+
return True
|
|
39
|
+
|
|
40
|
+
del color[vertices[i]]
|
|
41
|
+
|
|
42
|
+
return False
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
if backtracking(0):
|
|
46
|
+
print("Color Assignment:")
|
|
47
|
+
for vertex in vertices:
|
|
48
|
+
print(vertex, "=", color[vertex])
|
|
49
|
+
else:
|
|
50
|
+
print("no solution exist")
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import heapq
|
|
2
|
+
|
|
3
|
+
graph = {
|
|
4
|
+
'A': ['B', 'C', 'D'],
|
|
5
|
+
'B': ['A', 'E'],
|
|
6
|
+
'C': ['A', 'E', 'F'],
|
|
7
|
+
'D': ['A', 'F'],
|
|
8
|
+
'E': ['B', 'C', 'H'],
|
|
9
|
+
'F': ['C', 'D', 'G'],
|
|
10
|
+
'G': ['F', 'H'],
|
|
11
|
+
'H': ['E', 'G']
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
h = {
|
|
15
|
+
'A': 5,
|
|
16
|
+
'B': 8,
|
|
17
|
+
'C': 4,
|
|
18
|
+
'D': 5,
|
|
19
|
+
'E': 5,
|
|
20
|
+
'F': 2,
|
|
21
|
+
'G': 0,
|
|
22
|
+
'H': 1
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def greedy_best_first_search(graph, h, source, destination):
|
|
27
|
+
pq = [(h[source], source, [source])]
|
|
28
|
+
visited = set()
|
|
29
|
+
|
|
30
|
+
while pq:
|
|
31
|
+
heuristic, node, path = heapq.heappop(pq)
|
|
32
|
+
|
|
33
|
+
if node in visited:
|
|
34
|
+
continue
|
|
35
|
+
|
|
36
|
+
visited.add(node)
|
|
37
|
+
print(f"Visited {node} (h = {heuristic})")
|
|
38
|
+
|
|
39
|
+
if node == destination:
|
|
40
|
+
print("Path found:", " -> ".join(path))
|
|
41
|
+
return path
|
|
42
|
+
|
|
43
|
+
for neighbour in graph[node]:
|
|
44
|
+
if neighbour not in visited:
|
|
45
|
+
heapq.heappush(pq, (h[neighbour], neighbour, path + [neighbour]))
|
|
46
|
+
|
|
47
|
+
print("Solution not found")
|
|
48
|
+
return []
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
greedy_best_first_search(graph, h, 'A', 'G')
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import heapq
|
|
2
|
+
|
|
3
|
+
graph = {
|
|
4
|
+
'A': [(1, 'B'), (4, 'C')],
|
|
5
|
+
'B': [(1, 'A'), (2, 'C'), (5, 'D')],
|
|
6
|
+
'C': [(4, 'A'), (2, 'B'), (1, 'D')],
|
|
7
|
+
'D': [(5, 'B'), (1, 'C')]
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def ucs(graph, start, goal):
|
|
12
|
+
pq = [(0, start, [start])]
|
|
13
|
+
visited = set()
|
|
14
|
+
|
|
15
|
+
while pq:
|
|
16
|
+
cost, node, path = heapq.heappop(pq)
|
|
17
|
+
|
|
18
|
+
if node in visited:
|
|
19
|
+
continue
|
|
20
|
+
|
|
21
|
+
visited.add(node)
|
|
22
|
+
|
|
23
|
+
if node == goal:
|
|
24
|
+
return cost, path
|
|
25
|
+
|
|
26
|
+
for weight, neighbour in graph[node]:
|
|
27
|
+
if neighbour not in visited:
|
|
28
|
+
heapq.heappush(pq, (cost + weight, neighbour, path + [neighbour]))
|
|
29
|
+
|
|
30
|
+
return -1, []
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
minimum_cost, path = ucs(graph, 'A', 'D')
|
|
34
|
+
|
|
35
|
+
if minimum_cost == -1:
|
|
36
|
+
print("Solution not found")
|
|
37
|
+
else:
|
|
38
|
+
print("Least-cost path:", " -> ".join(path))
|
|
39
|
+
print("Total cost required:", minimum_cost)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: fighter1107a
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Print AI in Software Engineering lab assignment codes in the terminal
|
|
5
|
+
Requires-Python: >=3.8
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
|
|
8
|
+
# fighter1107a (`aise`)
|
|
9
|
+
|
|
10
|
+
Simple cross-platform CLI to print all 12 AI in Software Engineering assignment Python codes directly in the terminal (without downloading or creating files).
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
aise # Open interactive menu
|
|
16
|
+
aise 1.0 # Print Vacuum Cleaner Reflex Agent
|
|
17
|
+
aise 1.1 # Print Lift Reflex Agent
|
|
18
|
+
aise 2 # Print BFS and DFS (or: aise bfs / aise dfs)
|
|
19
|
+
aise 3 # Print Uniform Cost Search (UCS)
|
|
20
|
+
aise 4 # Print GBFS and A* (or: aise gbfs / aise astar)
|
|
21
|
+
aise 5 # Print Hill Climbing (8-Queens)
|
|
22
|
+
aise 6 # Print Graph Coloring CSP (Backtracking)
|
|
23
|
+
aise 7 # Print AI SRS / User Stories / Docs Generator
|
|
24
|
+
aise 8 # Print AI Code Generator & Reviewer
|
|
25
|
+
aise 9 # Print AI Bug Detector & Unit Test Generator
|
|
26
|
+
```
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
pyproject.toml
|
|
3
|
+
fighter1107a/__init__.py
|
|
4
|
+
fighter1107a/cli.py
|
|
5
|
+
fighter1107a.egg-info/PKG-INFO
|
|
6
|
+
fighter1107a.egg-info/SOURCES.txt
|
|
7
|
+
fighter1107a.egg-info/dependency_links.txt
|
|
8
|
+
fighter1107a.egg-info/entry_points.txt
|
|
9
|
+
fighter1107a.egg-info/top_level.txt
|
|
10
|
+
fighter1107a/codes/A search.py
|
|
11
|
+
fighter1107a/codes/Assignment1.1_38_12411944.py
|
|
12
|
+
fighter1107a/codes/Assignment1_38_12411944.py
|
|
13
|
+
fighter1107a/codes/Assignment5_38_12411944.py
|
|
14
|
+
fighter1107a/codes/Assignment7_38_12411944.py
|
|
15
|
+
fighter1107a/codes/Assignment8_38_12411944.py
|
|
16
|
+
fighter1107a/codes/Assignment9_38_12411944.py
|
|
17
|
+
fighter1107a/codes/BFS.py
|
|
18
|
+
fighter1107a/codes/DFS.py
|
|
19
|
+
fighter1107a/codes/Graph Colouring.py
|
|
20
|
+
fighter1107a/codes/Greedy Best-First Search.py
|
|
21
|
+
fighter1107a/codes/UCS.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
fighter1107a
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "fighter1107a"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Print AI in Software Engineering lab assignment codes in the terminal"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.8"
|
|
11
|
+
dependencies = []
|
|
12
|
+
|
|
13
|
+
[project.scripts]
|
|
14
|
+
aise = "fighter1107a.cli:main"
|
|
15
|
+
|
|
16
|
+
[tool.setuptools.packages.find]
|
|
17
|
+
include = ["fighter1107a*"]
|
|
18
|
+
|
|
19
|
+
[tool.setuptools.package-data]
|
|
20
|
+
fighter1107a = ["codes/*.py"]
|