Skip to content

Commit

Permalink
Made the grid, and started implementing the A-star algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
Gyakobo committed Oct 19, 2024
1 parent ec4dbca commit 38e6b19
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
16 changes: 16 additions & 0 deletions git_push.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

# Promp the user for input
echo "Enter a commit comment:"
read user_command

# Check if the input is empty
if [ -z "$user_command" ]; then
echo "Error: No comment entered."
exit 1
fi

# Run the command provided by the user
eval "sudo git add ."
eval "sudo git commit -m \"$user_command\""
eval "sudo git push -u origin main"
36 changes: 36 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import heapq

# A* Algorithm Class
class AStar:
def __init__(self, grid, start, end):
# Grid
self.grid = grid

# Positions
self.start = start
self.end = end

self.open_list = []
heapq.heappush(self.open_list, (0, start)) # (priority, node)

def print_grid(grid, path=None):
if path:
for (x, y) in path:
if (x, y) != start and (x, y) != end:
grid[x][y] = "*"
for row in grid:
print(" ".join(str(cell)) for cell in row)

# Define a 5x5 grid (0 = false, 1 = obstacle)
grid = [
[0, 1, 0, 0, 0],
[0, 1, 0, 1, 0],
[0, 0, 0, 1, 0],
[0, 1, 1, 0, 0],
[0, 0, 0, 0, 0]
]

start = (0, 0)
start = (4, 4)


0 comments on commit 38e6b19

Please sign in to comment.