Skip to content

Add Basic Theta* any-angle path planning - #15569

Closed
UziaPeer wants to merge 4 commits into
TheAlgorithms:masterfrom
UziaPeer:codex/theta-star-implementation
Closed

UziaPeer wants to merge 4 commits into
TheAlgorithms:masterfrom
UziaPeer:codex/theta-star-implementation

Conversation

@UziaPeer

Copy link
Copy Markdown

Describe your change

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Add or change doctests?
  • Documentation change?

This PR adds Basic Theta* for obstacle grids with paths through cell corners. The search follows the parent-shortcut update from Nash et al. (2007). It includes grid validation, line-of-sight checks, logging and doctest examples. The diff has exactly two new files: graphs/theta_star.py (the algorithm) and graphs/tests/test_theta_star.py (separate tests). It contains no AP Theta* or performance cache.

Local checks: 26 pytest cases passed; doctests passed; Ruff check and format check passed. The full repository suite is left to CI.

Checklist

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. The PR changes one algorithm file and one separate test file.
  • All new Python files are placed inside an existing directory.
  • All filenames are in all lowercase characters with no spaces or dashes.
  • All functions and variable names follow Python naming conventions.
  • All function parameters and return values are annotated with Python type hints.
  • All functions have doctests that pass the automated testing.
  • All new algorithms include at least one URL that points to Wikipedia or another similar explanation.

@algorithms-keeper algorithms-keeper Bot added awaiting reviews This PR is ready to be reviewed require descriptive names This PR needs descriptive function and/or variable names labels Oct 13, 2026

@algorithms-keeper algorithms-keeper Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Click here to look at the relevant links ⬇️

🔗 Relevant Links

Repository:

Python:

Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.

algorithms-keeper commands and options

algorithms-keeper actions can be triggered by commenting on this PR:

  • @algorithms-keeper review to trigger the checks for only added pull request files
  • @algorithms-keeper review-all to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.

NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.

Comment thread graphs/theta_star.py Outdated
from itertools import count, pairwise
from math import hypot, inf

Point = tuple[int, int]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Variable and function names should follow the snake_case naming convention. Please update the following name accordingly: Point

Comment thread graphs/theta_star.py Outdated
self.cells = rows
self.height, self.width = len(rows), len(rows[0])

def blocked(self, x: int, y: int) -> bool:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide descriptive name for the parameter: x

Please provide descriptive name for the parameter: y

Comment thread graphs/theta_star.py Outdated
and any(not self.blocked(cx, cy) for cx in (x - 1, x) for cy in (y - 1, y))
)

def line_of_sight(self, a: Point, b: Point) -> bool:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide descriptive name for the parameter: a

Please provide descriptive name for the parameter: b

Comment thread graphs/theta_star.py Outdated
return [q for q in candidates if q != point and self.line_of_sight(point, q)]


def distance(a: Point, b: Point) -> float:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide descriptive name for the parameter: a

Please provide descriptive name for the parameter: b

@algorithms-keeper algorithms-keeper Bot removed the require descriptive names This PR needs descriptive function and/or variable names label Oct 13, 2026
@UziaPeer UziaPeer closed this Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting reviews This PR is ready to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant