Metadata-Version: 2.4
Name: cosc604
Version: 0.1.0
Summary: Teaching implementations of search algorithms (BFS, DFS, UCS, A*) from Russell & Norvig's Artificial Intelligence: A Modern Approach, developed for COSC604.
Author-email: Andreas Henschel <andreas.henschel@ku.ac.ae>
License: MIT
Keywords: artificial-intelligence,search,aima,education,russell-norvig
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Education
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Education
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy
Requires-Dist: networkx
Provides-Extra: plot
Requires-Dist: matplotlib; extra == "plot"
Dynamic: license-file

# cosc604

Teaching code for **COSC604 – Techniques in Artificial Intelligence**,
developed alongside Assignment 1 (instructor: Andreas Henschel,
andreas.henschel@ku.ac.ae). It implements the generic search infrastructure
from Russell & Norvig, *Artificial Intelligence: A Modern Approach* (Ch. 3):
fringes/queues, the search-tree `Node`, `graph_search`/`tree_search`, and the
standard strategies built on top of them (BFS, DFS, uniform-cost, A*).

`Assignment1.ipynb` walks through the same code interactively, with the
routing-problem and tile-puzzle exercises described there. The modules under
`src/cosc604/` are the packaged, importable version of that code.

## Package layout

| Module | Contents |
| --- | --- |
| `cosc604.searches` | `Fringe`, `FIFO`, `LIFO`, `PriorityQueue`, `Node`, `graph_search`, `tree_search`, and the convenience wrappers `breadth_first_graph_search`, `depth_first_graph_search`, `depth_first_tree_search`, `astar_graph_search`, `uniform_cost_search`. |
| `cosc604.priority_queue_demo` | Standalone examples of how `PriorityQueue`'s priority function `f` shapes ordering (digit-sum, "VIP title" count). Run with `python -m cosc604.priority_queue_demo`. |
| `cosc604.graph_problem` | `GraphProblem` — the routing problem from the lecture slides, built on `networkx`. Includes the toy example and the Romania map. |
| `cosc604.puzzle_problem` | `PuzzleProblem` / `PuzzleState` — the sliding tile puzzle (8-puzzle for `size=3`). `PuzzleState.successors`, `__hash__` and `__eq__` are left as an exercise — implement them to make the puzzle searchable. |

## Installation

From PyPI:

```bash
pip install cosc604
```

Or, from this directory, as an editable install:

```bash
pip install -e .
```

This pulls in `numpy` and `networkx`. To also plot the Romania graph
(`graph_problem.draw_romania()`), install the optional `plot` extra:

```bash
pip install "cosc604[plot]"
```

## Quickstart

```python
from cosc604 import GraphProblem, uniform_cost_search

connections = [('S', 'A', 5), ('S', 'B', 3), ('S', 'C', 1),
               ('A', 'G', 1), ('B', 'G', 2), ('C', 'G', 17)]
toy = GraphProblem('S', 'G', connections, directed=True)

solution = uniform_cost_search(toy)
print([(node.state, node.action) for node in solution.getPath()])
```

## Assignment

Assignment 1 asks you to:

1. Add a `LIFO` fringe and complete the generic search algorithms (both done
   here) — read through `searches.py` to understand how `graph_search` and
   `tree_search` use a `Fringe` to implement each strategy.
2. Implement `PuzzleState.successors`, `__hash__` and `__eq__` in
   `puzzle_problem.py` so `PuzzleProblem` can be solved with the same search
   algorithms used for the routing problem, and reproduce the tile-puzzle
   results shown in the slides (`tileslides.png`).

## License

MIT — see [LICENSE](LICENSE).
