ai-practical-kit 1.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.
- ai_practical_kit-1.1.0/INSTALL_OFFLINE.bat +27 -0
- ai_practical_kit-1.1.0/INSTALL_OFFLINE.ps1 +12 -0
- ai_practical_kit-1.1.0/INSTALL_OFFLINE.sh +9 -0
- ai_practical_kit-1.1.0/LICENSE +21 -0
- ai_practical_kit-1.1.0/MANIFEST.in +8 -0
- ai_practical_kit-1.1.0/PKG-INFO +189 -0
- ai_practical_kit-1.1.0/PUBLISH_TO_PYPI.md +86 -0
- ai_practical_kit-1.1.0/README.md +167 -0
- ai_practical_kit-1.1.0/ai_practical_kit/__init__.py +22 -0
- ai_practical_kit-1.1.0/ai_practical_kit/cli.py +157 -0
- ai_practical_kit-1.1.0/ai_practical_kit/experiments/__init__.py +0 -0
- ai_practical_kit-1.1.0/ai_practical_kit/experiments/alpha_beta_pruning.py +91 -0
- ai_practical_kit-1.1.0/ai_practical_kit/experiments/astar_8_puzzle.py +116 -0
- ai_practical_kit-1.1.0/ai_practical_kit/experiments/eight_queens.py +62 -0
- ai_practical_kit-1.1.0/ai_practical_kit/experiments/local_beam_tsp.py +116 -0
- ai_practical_kit-1.1.0/ai_practical_kit/experiments/maze_dfs.py +92 -0
- ai_practical_kit-1.1.0/ai_practical_kit/experiments/robot_path_bfs.py +98 -0
- ai_practical_kit-1.1.0/ai_practical_kit/experiments/rule_chatbot.py +47 -0
- ai_practical_kit-1.1.0/ai_practical_kit/experiments/sudoku_solver.py +136 -0
- ai_practical_kit-1.1.0/ai_practical_kit/experiments/tictactoe_minimax.py +148 -0
- ai_practical_kit-1.1.0/ai_practical_kit/experiments/tower_of_hanoi_bfs.py +100 -0
- ai_practical_kit-1.1.0/ai_practical_kit/experiments/vacuum_cleaner.py +70 -0
- ai_practical_kit-1.1.0/ai_practical_kit/gui.py +173 -0
- ai_practical_kit-1.1.0/ai_practical_kit.egg-info/PKG-INFO +189 -0
- ai_practical_kit-1.1.0/ai_practical_kit.egg-info/SOURCES.txt +30 -0
- ai_practical_kit-1.1.0/ai_practical_kit.egg-info/dependency_links.txt +1 -0
- ai_practical_kit-1.1.0/ai_practical_kit.egg-info/entry_points.txt +5 -0
- ai_practical_kit-1.1.0/ai_practical_kit.egg-info/top_level.txt +1 -0
- ai_practical_kit-1.1.0/examples/use_library.py +17 -0
- ai_practical_kit-1.1.0/pyproject.toml +38 -0
- ai_practical_kit-1.1.0/setup.cfg +4 -0
- ai_practical_kit-1.1.0/tests/smoke_test.py +43 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
@echo off
|
|
2
|
+
setlocal
|
|
3
|
+
set "WHEEL=%~dp0dist\ai_practical_kit-1.1.0-py3-none-any.whl"
|
|
4
|
+
if not exist "%WHEEL%" (
|
|
5
|
+
echo ERROR: Wheel not found:
|
|
6
|
+
echo %WHEEL%
|
|
7
|
+
echo Please extract the complete AIPracticalKit offline ZIP first.
|
|
8
|
+
pause
|
|
9
|
+
exit /b 1
|
|
10
|
+
)
|
|
11
|
+
where py >nul 2>nul
|
|
12
|
+
if %errorlevel%==0 (
|
|
13
|
+
py -m pip install --no-index --no-deps --upgrade "%WHEEL%"
|
|
14
|
+
) else (
|
|
15
|
+
python -m pip install --no-index --no-deps --upgrade "%WHEEL%"
|
|
16
|
+
)
|
|
17
|
+
if %errorlevel% neq 0 (
|
|
18
|
+
echo.
|
|
19
|
+
echo Installation failed. Check that Python and pip are installed.
|
|
20
|
+
pause
|
|
21
|
+
exit /b 1
|
|
22
|
+
)
|
|
23
|
+
echo.
|
|
24
|
+
echo AIPracticalKit installed successfully into this Python environment.
|
|
25
|
+
echo For VS Code, select the same Python interpreter in the status bar.
|
|
26
|
+
echo Launch GUI with: ai-practical-kit-gui
|
|
27
|
+
pause
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
$ErrorActionPreference = 'Stop'
|
|
2
|
+
$wheel = Join-Path $PSScriptRoot 'dist\ai_practical_kit-1.1.0-py3-none-any.whl'
|
|
3
|
+
if (-not (Test-Path $wheel)) {
|
|
4
|
+
throw "Wheel not found: $wheel. Extract the complete offline ZIP first."
|
|
5
|
+
}
|
|
6
|
+
$py = Get-Command py -ErrorAction SilentlyContinue
|
|
7
|
+
if ($py) {
|
|
8
|
+
& py -m pip install --no-index --no-deps --upgrade $wheel
|
|
9
|
+
} else {
|
|
10
|
+
& python -m pip install --no-index --no-deps --upgrade $wheel
|
|
11
|
+
}
|
|
12
|
+
Write-Host 'AIPracticalKit installed. Select this Python interpreter in VS Code.'
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#!/usr/bin/env sh
|
|
2
|
+
set -eu
|
|
3
|
+
WHEEL="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)/dist/ai_practical_kit-1.1.0-py3-none-any.whl"
|
|
4
|
+
if command -v python3 >/dev/null 2>&1; then
|
|
5
|
+
python3 -m pip install --no-index --no-deps --upgrade "$WHEEL"
|
|
6
|
+
else
|
|
7
|
+
python -m pip install --no-index --no-deps --upgrade "$WHEEL"
|
|
8
|
+
fi
|
|
9
|
+
printf '\nAIPracticalKit installed. Select this Python interpreter in VS Code.\n'
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 AIPracticalKit contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ai-practical-kit
|
|
3
|
+
Version: 1.1.0
|
|
4
|
+
Summary: Beginner-friendly Python implementations of 11 AI laboratory practical algorithms, with an offline source browser
|
|
5
|
+
Author: AIPracticalKit contributors
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Keywords: AI,practicals,education,search algorithms,backtracking,minimax
|
|
8
|
+
Classifier: Development Status :: 4 - Beta
|
|
9
|
+
Classifier: Intended Audience :: Education
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Requires-Python: >=3.9
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
License-File: LICENSE
|
|
21
|
+
Dynamic: license-file
|
|
22
|
+
|
|
23
|
+
# AIPracticalKit — Offline AI Laboratory Practical Library
|
|
24
|
+
|
|
25
|
+
AIPracticalKit packages the 11 AI practicals as reusable Python functions and includes each complete `.py` implementation. It also provides a text menu and a desktop source browser so a student can run an experiment, inspect its code, copy it, or save a separate copy.
|
|
26
|
+
|
|
27
|
+
**No third-party runtime dependencies. No internet is needed after you have downloaded the wheel or ZIP.** Python must already be installed on the computer. The graphical source browser uses Tkinter, which is included with most desktop Python installations.
|
|
28
|
+
|
|
29
|
+
## Included experiments
|
|
30
|
+
|
|
31
|
+
1. Simple Reflex Agent — Vacuum Cleaner World
|
|
32
|
+
2. A* Search — 8-Puzzle using Manhattan distance
|
|
33
|
+
3. Alpha-Beta Pruning — binary game tree
|
|
34
|
+
4. Tower of Hanoi — BFS state-space search
|
|
35
|
+
5. Sudoku — constraint propagation and backtracking
|
|
36
|
+
6. Local Beam Search — Traveling Salesman Problem
|
|
37
|
+
7. BFS — Robot Path Planning
|
|
38
|
+
8. DFS — Maze Solving
|
|
39
|
+
9. 8-Queens — backtracking and solution counting
|
|
40
|
+
10. Rule-Based Chatbot — regular expressions, random responses and AND rule
|
|
41
|
+
11. Tic-Tac-Toe — Minimax, demonstration mode and optional human-vs-AI mode
|
|
42
|
+
|
|
43
|
+
## Recommended offline installation on Windows
|
|
44
|
+
|
|
45
|
+
### Method A — install the wheel (works without internet)
|
|
46
|
+
|
|
47
|
+
1. Extract the `AIPracticalKit_Offline_Install.zip` package.
|
|
48
|
+
2. Open the extracted folder. It contains `dist/ai_practical_kit-1.1.0-py3-none-any.whl`.
|
|
49
|
+
3. Double-click `INSTALL_OFFLINE.bat`, or open PowerShell in that folder and run:
|
|
50
|
+
|
|
51
|
+
```powershell
|
|
52
|
+
py -m pip install --no-index --no-deps --upgrade .\dist\ai_practical_kit-1.1.0-py3-none-any.whl
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
If the `py` launcher is unavailable, use `python -m pip` instead.
|
|
56
|
+
4. In VS Code, select the same Python interpreter that you used for installation.
|
|
57
|
+
5. Test the installation:
|
|
58
|
+
|
|
59
|
+
```powershell
|
|
60
|
+
py -c "from ai_practical_kit import solve_astar; print(solve_astar('123406758')['moves'])"
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
The expected number of moves is `2`.
|
|
64
|
+
|
|
65
|
+
The wheel is pure Python and the project has no third-party runtime dependencies. `--no-index` tells pip not to contact a package index; `--no-deps` prevents dependency downloads.
|
|
66
|
+
|
|
67
|
+
### Method B — use the source folder without installing
|
|
68
|
+
|
|
69
|
+
Extract the full source ZIP, open the `AIPracticalKit` folder in VS Code, and run:
|
|
70
|
+
|
|
71
|
+
```powershell
|
|
72
|
+
py app.py
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
For a text menu, run:
|
|
76
|
+
|
|
77
|
+
```powershell
|
|
78
|
+
py run.py
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
This source-folder method also works offline and leaves the package uninstalled.
|
|
82
|
+
|
|
83
|
+
## Open the source browser after installing the wheel
|
|
84
|
+
|
|
85
|
+
After the wheel is installed, launch:
|
|
86
|
+
|
|
87
|
+
```powershell
|
|
88
|
+
ai-practical-kit-gui
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Or run the module directly:
|
|
92
|
+
|
|
93
|
+
```powershell
|
|
94
|
+
py -m ai_practical_kit.gui
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
The GUI lets you select an experiment, view its entire source, run it, open its `.py` file in an editor, copy its source, or save a separate copy. If VS Code's `code` command is configured, the GUI opens the selected source in VS Code; otherwise, it uses a system text editor where available.
|
|
98
|
+
|
|
99
|
+
For the terminal menu, use:
|
|
100
|
+
|
|
101
|
+
```powershell
|
|
102
|
+
ai-practical-kit
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
or:
|
|
106
|
+
|
|
107
|
+
```powershell
|
|
108
|
+
py -m ai_practical_kit.cli
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Import individual algorithms into your own file
|
|
112
|
+
|
|
113
|
+
After installing the wheel, you can import the functions from any working directory using the same Python interpreter.
|
|
114
|
+
|
|
115
|
+
### A* Search for 8-Puzzle
|
|
116
|
+
|
|
117
|
+
```python
|
|
118
|
+
from ai_practical_kit import solve_astar
|
|
119
|
+
|
|
120
|
+
result = solve_astar("123406758")
|
|
121
|
+
print("Found:", result["found"])
|
|
122
|
+
print("Moves:", result["moves"])
|
|
123
|
+
print("Path:", result["path"])
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### 8-Queens
|
|
127
|
+
|
|
128
|
+
```python
|
|
129
|
+
from ai_practical_kit import solve_8_queens
|
|
130
|
+
|
|
131
|
+
result = solve_8_queens()
|
|
132
|
+
print("First solution:", result["solution"])
|
|
133
|
+
print("Total solutions:", result["total_solutions"])
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Rule-based chatbot
|
|
137
|
+
|
|
138
|
+
```python
|
|
139
|
+
from ai_practical_kit import respond
|
|
140
|
+
|
|
141
|
+
print(respond("hello"))
|
|
142
|
+
print(respond("Tell me about admission and fees"))
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Other exported functions
|
|
146
|
+
|
|
147
|
+
```python
|
|
148
|
+
from ai_practical_kit import (
|
|
149
|
+
solve_vacuum,
|
|
150
|
+
solve_alpha_beta,
|
|
151
|
+
solve_hanoi_bfs,
|
|
152
|
+
solve_sudoku,
|
|
153
|
+
local_beam_tsp,
|
|
154
|
+
solve_robot_bfs,
|
|
155
|
+
solve_maze_dfs,
|
|
156
|
+
find_best_move,
|
|
157
|
+
minimax,
|
|
158
|
+
)
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
Read `ai_practical_kit/experiments/` in the source ZIP or select an experiment in the source browser to see full implementations and exact inputs.
|
|
162
|
+
|
|
163
|
+
## Test the package
|
|
164
|
+
|
|
165
|
+
From the source project directory, run:
|
|
166
|
+
|
|
167
|
+
```powershell
|
|
168
|
+
py tests\smoke_test.py
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
Expected final line:
|
|
172
|
+
|
|
173
|
+
```text
|
|
174
|
+
All 11 AIPracticalKit smoke tests passed.
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## Publishing to PyPI later (optional)
|
|
178
|
+
|
|
179
|
+
Offline installation does not require PyPI. If you later decide to publish the package for public installation, use `PUBLISH_TO_PYPI.md`. Publishing requires internet access, a PyPI account, and a package name that is available. This project is built locally; it has **not** been uploaded to PyPI by this ZIP.
|
|
180
|
+
|
|
181
|
+
## Notes
|
|
182
|
+
|
|
183
|
+
- The package is designed for study and practical examinations, not as a highly optimized production solver.
|
|
184
|
+
- A* validates the 8-puzzle state and checks parity before searching.
|
|
185
|
+
- BFS finds a shortest path when every move has equal cost. DFS finds a path but does not guarantee the shortest one.
|
|
186
|
+
- Local Beam Search is a heuristic and does not guarantee a globally optimal TSP tour.
|
|
187
|
+
- Alpha-Beta Pruning and Minimax evaluate the supplied game tree or board.
|
|
188
|
+
- Sudoku applies constraint propagation before recursive backtracking.
|
|
189
|
+
- The package distribution name is `ai-practical-kit`; the import name is `ai_practical_kit`.
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# Publish AIPracticalKit to PyPI
|
|
2
|
+
|
|
3
|
+
This project is packaged as `ai-practical-kit`; the Python import name is `ai_practical_kit`.
|
|
4
|
+
|
|
5
|
+
## Recommended method: PyPI Trusted Publishing with GitHub Actions
|
|
6
|
+
|
|
7
|
+
This method avoids storing a long-lived PyPI API token in GitHub. It requires a GitHub repository and an internet connection during publication.
|
|
8
|
+
|
|
9
|
+
### 1. Create a GitHub repository
|
|
10
|
+
|
|
11
|
+
Create a repository, for example `AIPracticalKit`, under your own GitHub account. Upload the **contents** of this project folder to the repository root (so `pyproject.toml` is at the root). Include `.github/workflows/publish.yml`.
|
|
12
|
+
|
|
13
|
+
### 2. Create the GitHub environment
|
|
14
|
+
|
|
15
|
+
In the GitHub repository, open **Settings → Environments**, create an environment named exactly `pypi`. The workflow uses this environment name.
|
|
16
|
+
|
|
17
|
+
### 3. Register the pending publisher on PyPI
|
|
18
|
+
|
|
19
|
+
Open https://pypi.org/manage/account/publishing/ and select **GitHub**. Enter:
|
|
20
|
+
|
|
21
|
+
- **PyPI Project Name:** `ai-practical-kit`
|
|
22
|
+
- **Owner:** your exact GitHub username or organization (not automatically your PyPI username)
|
|
23
|
+
- **Repository name:** the exact repository name you created, e.g. `AIPracticalKit`
|
|
24
|
+
- **Workflow name:** `publish.yml`
|
|
25
|
+
- **Environment name:** `pypi`
|
|
26
|
+
|
|
27
|
+
Click **Add**. This is a pending publisher: it does not reserve the package name until the first successful publishing workflow runs.
|
|
28
|
+
|
|
29
|
+
### 4. Commit and push the workflow
|
|
30
|
+
|
|
31
|
+
Confirm `.github/workflows/publish.yml` is at the repository root under `.github/workflows/` and that `pyproject.toml` is also at the repository root.
|
|
32
|
+
|
|
33
|
+
### 5. Publish the first release
|
|
34
|
+
|
|
35
|
+
The current package version is `1.1.0`. After the files are pushed, create a GitHub Release with tag `v1.1.0` and publish the release. That triggers the workflow to build the wheel and source archive, check them, and upload them to PyPI using Trusted Publishing.
|
|
36
|
+
|
|
37
|
+
If the project name was claimed by someone else before the first upload, the workflow will fail. In that case, choose a new unique `project.name` in `pyproject.toml`, rebuild, and update the PyPI pending publisher to match before publishing.
|
|
38
|
+
|
|
39
|
+
### 6. Verify
|
|
40
|
+
|
|
41
|
+
After a successful workflow, check https://pypi.org/project/ai-practical-kit/ . Then, on a computer with internet, install it with:
|
|
42
|
+
|
|
43
|
+
```powershell
|
|
44
|
+
py -m pip install ai-practical-kit
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Use it in Python with:
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
from ai_practical_kit import solve_8_queens
|
|
51
|
+
|
|
52
|
+
result = solve_8_queens()
|
|
53
|
+
print(result["total_solutions"])
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Expected total: `92`.
|
|
57
|
+
|
|
58
|
+
## Alternative: manual upload with an API token
|
|
59
|
+
|
|
60
|
+
You do not need to use the Trusted Publisher screen if you prefer to upload manually. Follow the current PyPI packaging guide: https://packaging.python.org/en/latest/tutorials/packaging-projects/
|
|
61
|
+
|
|
62
|
+
From the project root, build and check the distributions:
|
|
63
|
+
|
|
64
|
+
```powershell
|
|
65
|
+
py -m pip install --upgrade build twine
|
|
66
|
+
py -m build
|
|
67
|
+
py -m twine check dist/*
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Then create a PyPI API token in **Account settings → API tokens** and upload:
|
|
71
|
+
|
|
72
|
+
```powershell
|
|
73
|
+
py -m twine upload dist/*
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
When Twine prompts for credentials, use username `__token__` and paste the API token (including its `pypi-` prefix) as the password. Never put the token in source code or send it in chat. If the package does not yet exist, an account-scoped token may be required for the first upload; after creating the project, consider a project-scoped token and revoke the broader token.
|
|
77
|
+
|
|
78
|
+
## Offline use
|
|
79
|
+
|
|
80
|
+
PyPI publication does not make installation possible without internet on a new machine. For offline systems, copy the `.whl` file from `dist/` to the machine and install it locally:
|
|
81
|
+
|
|
82
|
+
```powershell
|
|
83
|
+
py -m pip install --no-index --no-deps .\dist\ai_practical_kit-1.1.0-py3-none-any.whl
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
The package itself has no third-party runtime dependencies. Python must already be installed on the computer.
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
# AIPracticalKit — Offline AI Laboratory Practical Library
|
|
2
|
+
|
|
3
|
+
AIPracticalKit packages the 11 AI practicals as reusable Python functions and includes each complete `.py` implementation. It also provides a text menu and a desktop source browser so a student can run an experiment, inspect its code, copy it, or save a separate copy.
|
|
4
|
+
|
|
5
|
+
**No third-party runtime dependencies. No internet is needed after you have downloaded the wheel or ZIP.** Python must already be installed on the computer. The graphical source browser uses Tkinter, which is included with most desktop Python installations.
|
|
6
|
+
|
|
7
|
+
## Included experiments
|
|
8
|
+
|
|
9
|
+
1. Simple Reflex Agent — Vacuum Cleaner World
|
|
10
|
+
2. A* Search — 8-Puzzle using Manhattan distance
|
|
11
|
+
3. Alpha-Beta Pruning — binary game tree
|
|
12
|
+
4. Tower of Hanoi — BFS state-space search
|
|
13
|
+
5. Sudoku — constraint propagation and backtracking
|
|
14
|
+
6. Local Beam Search — Traveling Salesman Problem
|
|
15
|
+
7. BFS — Robot Path Planning
|
|
16
|
+
8. DFS — Maze Solving
|
|
17
|
+
9. 8-Queens — backtracking and solution counting
|
|
18
|
+
10. Rule-Based Chatbot — regular expressions, random responses and AND rule
|
|
19
|
+
11. Tic-Tac-Toe — Minimax, demonstration mode and optional human-vs-AI mode
|
|
20
|
+
|
|
21
|
+
## Recommended offline installation on Windows
|
|
22
|
+
|
|
23
|
+
### Method A — install the wheel (works without internet)
|
|
24
|
+
|
|
25
|
+
1. Extract the `AIPracticalKit_Offline_Install.zip` package.
|
|
26
|
+
2. Open the extracted folder. It contains `dist/ai_practical_kit-1.1.0-py3-none-any.whl`.
|
|
27
|
+
3. Double-click `INSTALL_OFFLINE.bat`, or open PowerShell in that folder and run:
|
|
28
|
+
|
|
29
|
+
```powershell
|
|
30
|
+
py -m pip install --no-index --no-deps --upgrade .\dist\ai_practical_kit-1.1.0-py3-none-any.whl
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
If the `py` launcher is unavailable, use `python -m pip` instead.
|
|
34
|
+
4. In VS Code, select the same Python interpreter that you used for installation.
|
|
35
|
+
5. Test the installation:
|
|
36
|
+
|
|
37
|
+
```powershell
|
|
38
|
+
py -c "from ai_practical_kit import solve_astar; print(solve_astar('123406758')['moves'])"
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
The expected number of moves is `2`.
|
|
42
|
+
|
|
43
|
+
The wheel is pure Python and the project has no third-party runtime dependencies. `--no-index` tells pip not to contact a package index; `--no-deps` prevents dependency downloads.
|
|
44
|
+
|
|
45
|
+
### Method B — use the source folder without installing
|
|
46
|
+
|
|
47
|
+
Extract the full source ZIP, open the `AIPracticalKit` folder in VS Code, and run:
|
|
48
|
+
|
|
49
|
+
```powershell
|
|
50
|
+
py app.py
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
For a text menu, run:
|
|
54
|
+
|
|
55
|
+
```powershell
|
|
56
|
+
py run.py
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
This source-folder method also works offline and leaves the package uninstalled.
|
|
60
|
+
|
|
61
|
+
## Open the source browser after installing the wheel
|
|
62
|
+
|
|
63
|
+
After the wheel is installed, launch:
|
|
64
|
+
|
|
65
|
+
```powershell
|
|
66
|
+
ai-practical-kit-gui
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Or run the module directly:
|
|
70
|
+
|
|
71
|
+
```powershell
|
|
72
|
+
py -m ai_practical_kit.gui
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
The GUI lets you select an experiment, view its entire source, run it, open its `.py` file in an editor, copy its source, or save a separate copy. If VS Code's `code` command is configured, the GUI opens the selected source in VS Code; otherwise, it uses a system text editor where available.
|
|
76
|
+
|
|
77
|
+
For the terminal menu, use:
|
|
78
|
+
|
|
79
|
+
```powershell
|
|
80
|
+
ai-practical-kit
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
or:
|
|
84
|
+
|
|
85
|
+
```powershell
|
|
86
|
+
py -m ai_practical_kit.cli
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Import individual algorithms into your own file
|
|
90
|
+
|
|
91
|
+
After installing the wheel, you can import the functions from any working directory using the same Python interpreter.
|
|
92
|
+
|
|
93
|
+
### A* Search for 8-Puzzle
|
|
94
|
+
|
|
95
|
+
```python
|
|
96
|
+
from ai_practical_kit import solve_astar
|
|
97
|
+
|
|
98
|
+
result = solve_astar("123406758")
|
|
99
|
+
print("Found:", result["found"])
|
|
100
|
+
print("Moves:", result["moves"])
|
|
101
|
+
print("Path:", result["path"])
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### 8-Queens
|
|
105
|
+
|
|
106
|
+
```python
|
|
107
|
+
from ai_practical_kit import solve_8_queens
|
|
108
|
+
|
|
109
|
+
result = solve_8_queens()
|
|
110
|
+
print("First solution:", result["solution"])
|
|
111
|
+
print("Total solutions:", result["total_solutions"])
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Rule-based chatbot
|
|
115
|
+
|
|
116
|
+
```python
|
|
117
|
+
from ai_practical_kit import respond
|
|
118
|
+
|
|
119
|
+
print(respond("hello"))
|
|
120
|
+
print(respond("Tell me about admission and fees"))
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Other exported functions
|
|
124
|
+
|
|
125
|
+
```python
|
|
126
|
+
from ai_practical_kit import (
|
|
127
|
+
solve_vacuum,
|
|
128
|
+
solve_alpha_beta,
|
|
129
|
+
solve_hanoi_bfs,
|
|
130
|
+
solve_sudoku,
|
|
131
|
+
local_beam_tsp,
|
|
132
|
+
solve_robot_bfs,
|
|
133
|
+
solve_maze_dfs,
|
|
134
|
+
find_best_move,
|
|
135
|
+
minimax,
|
|
136
|
+
)
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Read `ai_practical_kit/experiments/` in the source ZIP or select an experiment in the source browser to see full implementations and exact inputs.
|
|
140
|
+
|
|
141
|
+
## Test the package
|
|
142
|
+
|
|
143
|
+
From the source project directory, run:
|
|
144
|
+
|
|
145
|
+
```powershell
|
|
146
|
+
py tests\smoke_test.py
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Expected final line:
|
|
150
|
+
|
|
151
|
+
```text
|
|
152
|
+
All 11 AIPracticalKit smoke tests passed.
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## Publishing to PyPI later (optional)
|
|
156
|
+
|
|
157
|
+
Offline installation does not require PyPI. If you later decide to publish the package for public installation, use `PUBLISH_TO_PYPI.md`. Publishing requires internet access, a PyPI account, and a package name that is available. This project is built locally; it has **not** been uploaded to PyPI by this ZIP.
|
|
158
|
+
|
|
159
|
+
## Notes
|
|
160
|
+
|
|
161
|
+
- The package is designed for study and practical examinations, not as a highly optimized production solver.
|
|
162
|
+
- A* validates the 8-puzzle state and checks parity before searching.
|
|
163
|
+
- BFS finds a shortest path when every move has equal cost. DFS finds a path but does not guarantee the shortest one.
|
|
164
|
+
- Local Beam Search is a heuristic and does not guarantee a globally optimal TSP tour.
|
|
165
|
+
- Alpha-Beta Pruning and Minimax evaluate the supplied game tree or board.
|
|
166
|
+
- Sudoku applies constraint propagation before recursive backtracking.
|
|
167
|
+
- The package distribution name is `ai-practical-kit`; the import name is `ai_practical_kit`.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"""AIPracticalKit: reusable, beginner-friendly AI practical algorithms."""
|
|
2
|
+
|
|
3
|
+
from .experiments.vacuum_cleaner import solve_vacuum
|
|
4
|
+
from .experiments.astar_8_puzzle import solve_astar, heuristic
|
|
5
|
+
from .experiments.alpha_beta_pruning import solve_alpha_beta
|
|
6
|
+
from .experiments.tower_of_hanoi_bfs import solve_hanoi_bfs
|
|
7
|
+
from .experiments.sudoku_solver import solve_sudoku
|
|
8
|
+
from .experiments.local_beam_tsp import local_beam_tsp, tour_cost
|
|
9
|
+
from .experiments.robot_path_bfs import solve_robot_bfs
|
|
10
|
+
from .experiments.maze_dfs import solve_maze_dfs
|
|
11
|
+
from .experiments.eight_queens import solve_8_queens
|
|
12
|
+
from .experiments.rule_chatbot import respond
|
|
13
|
+
from .experiments.tictactoe_minimax import find_best_move, minimax
|
|
14
|
+
|
|
15
|
+
__version__ = "1.1.0"
|
|
16
|
+
|
|
17
|
+
__all__ = [
|
|
18
|
+
"solve_vacuum", "solve_astar", "heuristic", "solve_alpha_beta",
|
|
19
|
+
"solve_hanoi_bfs", "solve_sudoku", "local_beam_tsp", "tour_cost",
|
|
20
|
+
"solve_robot_bfs", "solve_maze_dfs", "solve_8_queens", "respond",
|
|
21
|
+
"find_best_move", "minimax",
|
|
22
|
+
]
|