Library / SDK
rishal-hurbans/Grokking-Artificial-Intelligence-Algorithms avatar
rishal-hurbans/Grokking-Artificial-Intelligence-Algorithms

Grokking AI Algorithms: A Chapter-Indexed Python Reference for Classic AI Techniques

The official code repository supporting the book, Grokking Artificial Intelligence Algorithms

431 stars134 forksPythonAGPL-3.0

At a glance

What is it?
This repository is the official companion code for the Manning book Grokking Artificial Intelligence Algorithms. It is a per-chapter collection of runnable Python scripts covering search, evolutionary methods, swarm optimisation, neural networks, reinforcement learning and generative demos, and it is meant to be consulted while implementing an algorithm rather than read front to back.
Who is it for?
Adopt this repository if you want a working Python script for a named algorithm (A* on a maze, ant colony optimisation, particle swarm, Q-learning) that you can read and modify, and if you already have the book or are willing to treat the code as the entry point. Do not adopt it if you need a supported library with an API contract, versioned releases, or a test suite you can rely on in production.
Can I use it commercially?
Yes, with strict conditions. AGPL-3.0 is a network copyleft licence: if people use a modified version over a network, for example as a hosted service, you must offer them its source code under the same licence.
Is it still maintained?
Yes. The repository last received commits 40 days ago.
What is it written in?
Mainly Python, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on September 15, 2026, and from our analysis. They are not legal advice.

DEEP OPEN-SOURCE ANALYSIS

What the repository is and who it is written for

This is the official supporting code for Grokking AI Algorithms, published by Manning and authored by Rishal Hurbans. The README is explicit about intent: the repository exists to be a practical reference for how the algorithms in the book can be implemented, and it states that the examples make more sense if you have read the book, though they may be somewhat useful otherwise. That sentence is the whole positioning. This is not a library you install and call. It is a set of scripts organised by chapter, and the README tells you not to read it page by page alongside the book but to reach for it when you are trying to implement an algorithm or want a programming-level view of one. The topics list confirms the breadth: search algorithms, genetic and evolutionary algorithms, ant colony optimisation, particle swarm optimisation, linear regression, classification, artificial neural networks, Q-learning and reinforcement learning, generative art and generative AI, and large language models. The audience is therefore a reader who already knows roughly what a genetic algorithm is and wants to see the loop written out in Python, not someone looking for a maintained dependency to import into a service.

How the code is organised and how a run actually flows

The layout is chapter directories with topic subdirectories beneath them. The README's own example path is ch03-intelligent_search/informed_search, and the command it gives is python3 maze_astar.py executed from inside that directory. Two things follow from that structure. First, navigation is by chapter number, so you need the book's table of contents or the directory listing to find anything; there is no package namespace, no top-level module you import, and no index file described in the README. Second, scripts are expected to be run from their own directory, which is the common pattern for textbook code that reads local data files or writes output next to itself. The README does not describe a shared utilities module, a test directory, or a configuration layer, so the reasonable reading is that each script is self-contained and prints or plots its result. The data flow is therefore the simplest possible one: a script constructs its problem representation in code, runs the algorithm, and emits a result to standard output or a figure. There is no service, no serialised model artefact, and no pipeline that moves data between chapters. If you want to see how A* is expressed in Python, you open the file. If you want a reusable A* component, you are expected to lift the code and adapt it.

Getting it running: the exact setup the README prescribes

The requirements are Python 3.9 or later, with 3.11 recommended, and pip 23.1 or newer, which the README notes comes with recent Python installers. A PyTorch-compatible GPU is listed as optional and is tied specifically to the heavy demos in Chapters 11 and 12, which is the only performance-related claim the material makes. Setup is the standard three steps. Create a virtual environment with python3 -m venv .venv followed by source .venv/bin/activate on macOS or Linux, or py -3 -m venv .venv followed by .\.venv\Scripts\Activate.ps1 in Windows PowerShell. Then upgrade pip and install the dependency file: pip install --upgrade pip, then pip install -r requirements.txt. The README warns that PyTorch wheels are large, and points Apple Silicon users at the arm64 build from pip while directing anyone needing CUDA to the official PyTorch installation instructions. Finally, run an example by changing into a chapter directory and executing the script, for example cd ch03-intelligent_search/informed_search then python3 maze_astar.py. The README also suggests checking that python and pip point at the same interpreter with python -m pip --version. There is a Colab notebook hosted in a separate repository, linked from the README, for readers who would rather explore the code in a browser than set up a local environment.

The dependency install is the first real obstacle

The single requirements.txt covering every chapter is the design decision with the most practical consequence. A reader who wants the maze search example in Chapter 3 still installs the full dependency set, which by the README's own admission includes large PyTorch wheels needed only for Chapters 11 and 12. On a slow connection or a constrained machine, that is a meaningful cost for a script that may use nothing beyond the standard library. The README acknowledges the wheel size but does not offer a per-chapter requirements file, an extras layout, or any documented way to install a subset. The second consequence is version drift. The repository pins nothing that the README describes, and it lists no releases, so there is no tagged snapshot corresponding to a particular printing of the book. A reader in 2026 running pip install -r requirements.txt is installing whatever the current transitive dependency resolution produces, which may not match the environment the book's listings were written against. The README's GPU note for Chapters 11 and 12 is the only place it hints that some examples are computationally heavier than others, and it gives no runtime figures, so you cannot plan around it from the documentation alone.

Where the book-companion model breaks down

Companion code is optimised for legibility, not for reuse, and this repository follows that convention. There is no described test suite, so nothing in the material lets you confirm that a given algorithm still produces correct output after you edit it. There is no packaging metadata described beyond requirements.txt, so you cannot pip install this as a dependency and import it. There is no CLI, no config file, and no documented API surface, which means integrating any of these implementations into an existing codebase is a copy-and-adapt exercise rather than a dependency decision. That is fine for the stated purpose and wrong for several others. If you need a solver in a production path, you want a maintained library with tests and semantic versioning, not a script whose correctness you are expected to reason about from the book. If you need to run the same algorithm over your own data at scale, you will be rewriting the problem representation, because the scripts construct their inputs in code. And if you are looking for a curriculum that stands alone without the book, the README's own admission that the examples make more sense having read it is a fair warning. The repository is a reference implementation collection, and the absence of releases means there is no upgrade path to reason about, only a moving main branch.

AGPL-3.0 is the constraint that outlives the code

The licence is AGPL-3.0, which is a copyleft licence with a network-use clause. For a reader studying algorithms at a desk, this changes nothing. For anyone who lifts a script into a hosted service, it is the most consequential fact on this page, and it is the one most likely to be overlooked because the repository presents itself as educational material rather than a library. A permissive alternative would let you copy a genetic algorithm implementation into a closed product without further thought; AGPL-3.0 does not. The practical effect is that the copy-and-adapt workflow the repository invites has a licence boundary attached to it, and that boundary is broader than most textbook code carries. This is not legal advice and the exact obligations depend on how you distribute or expose the derived work, so if the code is heading anywhere near a product, that question belongs with someone qualified to answer it. What can be said plainly from the repository metadata is that the licence is AGPL-3.0, it is not a permissive one, and it applies to the code you would be copying.

How it differs from a maintained algorithm library

The obvious comparison is scikit-learn. The difference is not quality, it is contract. scikit-learn exposes a stable estimator interface, fit and predict, with documented parameters, versioned releases, deprecation cycles and a test suite, and its implementations are written for numerical efficiency over arrays. This repository exposes scripts. You read maze_astar.py to understand how A* expands a frontier; you call sklearn's estimators when you want a result you can regression-test. The same split applies to reinforcement learning, where a framework like Stable-Baselines3 wraps environments and training loops behind a maintained API, while the Q-learning material here is a teaching implementation you read to see the update rule. Choosing between them is not a matter of which is better. It is a question of whether your goal is understanding the mechanism or shipping it. The repository's value is precisely that it does not abstract the mechanism away, and that value evaporates the moment you need the abstraction.

Editorial conclusion

Adopt this repository if you want a working Python script for a named algorithm (A* on a maze, ant colony optimisation, particle swarm, Q-learning) that you can read and modify, and if you already have the book or are willing to treat the code as the entry point. Do not adopt it if you need a supported library with an API contract, versioned releases, or a test suite you can rely on in production. Before committing, verify three things yourself: that pip install -r requirements.txt resolves cleanly on your Python 3.9+ interpreter, that the chapter directory you care about runs standalone rather than importing shared state from a sibling chapter, and that AGPL-3.0 is acceptable for your distribution model, since the licence choice is the repository's, not a detail you can set aside.

Official sources

  1. Issues
  2. License: AGPL-3.0
  3. Project website
  4. README
  5. rishal-hurbans/Grokking-Artificial-Intelligence-Algorithms on GitHub
Community notes

Community notes