{"id":26360407,"url":"https://github.com/arsh-jafri/dijkstra-snake-game","last_synced_at":"2025-03-16T16:52:51.444Z","repository":{"id":279839553,"uuid":"940141051","full_name":"Arsh-Jafri/dijkstra-snake-game","owner":"Arsh-Jafri","description":"A modern take on the classic Snake game featuring an AI opponent that uses Dijkstra's algorithm for pathfinding. Customize snake colors and game speed while competing against an intelligent AI snake.","archived":false,"fork":false,"pushed_at":"2025-02-27T18:25:15.000Z","size":39,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-28T01:59:58.856Z","etag":null,"topics":["dijkstra-algorithm","java","java-awt","java-swing"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Arsh-Jafri.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-27T17:20:23.000Z","updated_at":"2025-02-27T18:50:37.000Z","dependencies_parsed_at":"2025-02-28T02:00:08.289Z","dependency_job_id":"79c558c9-b715-4af3-b761-7c7faa4deb58","html_url":"https://github.com/Arsh-Jafri/dijkstra-snake-game","commit_stats":null,"previous_names":["arsh-jafri/dijkstra-snake-game"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Arsh-Jafri%2Fdijkstra-snake-game","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Arsh-Jafri%2Fdijkstra-snake-game/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Arsh-Jafri%2Fdijkstra-snake-game/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Arsh-Jafri%2Fdijkstra-snake-game/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Arsh-Jafri","download_url":"https://codeload.github.com/Arsh-Jafri/dijkstra-snake-game/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243902269,"owners_count":20366258,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dijkstra-algorithm","java","java-awt","java-swing"],"created_at":"2025-03-16T16:52:50.919Z","updated_at":"2025-03-16T16:52:51.437Z","avatar_url":"https://github.com/Arsh-Jafri.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Dijkstra's Snake Game\n\nA Java implementation of the classic Snake game with an AI opponent that uses Dijkstra's algorithm for pathfinding.\n\n## Features\n\n- Player-controlled snake (blue by default) using arrow keys\n- AI snake (red by default) that automatically finds the shortest path to food using Dijkstra's algorithm\n- Customizable snake colors through color picker\n- Adjustable game speed (Slow, Normal, Fast, Very Fast)\n- 3-second countdown before game starts\n- Grid-based game board with randomly spawning food\n- Collision detection for walls, self, and other snake\n- Game over screen with restart option\n- Pause/Resume functionality\n- Both snakes start with 4 blocks length\n\n## Controls\n\n- Arrow keys: Control the player snake's direction\n- Space: Restart the game when game over\n- P: Pause/Resume the game\n- Restart button: Start a new game at any time\n- Pause/Resume button: Toggle game pause state\n\n## How to Run\n\n1. Make sure you have Java Development Kit (JDK) installed on your system\n2. Compile the Java files:\n   ```bash\n   javac *.java\n   ```\n3. Run the game:\n   ```bash\n   java Game\n   ```\n\n## Game Rules\n\n- Control your snake (blue by default) to eat the food (red squares)\n- Avoid colliding with:\n  - Walls\n  - Your own body\n  - The AI snake (red by default)\n- Each time either snake eats food, it grows longer\n- The AI snake will automatically find the shortest path to the food using Dijkstra's algorithm\n- Game ends if the player snake collides with walls, itself, or the AI snake\n\n## Game Flow\n\n1. Start Screen:\n   - Choose your snake's color (default: blue)\n   - Choose AI snake's color (default: red)\n   - Select game speed (default: Normal)\n   - Click \"Start Game\" to begin\n\n2. Countdown Phase:\n   - 3-second countdown before game starts\n   - Snakes are visible but don't move during countdown\n   - Both snakes start with 4 blocks length\n\n3. Gameplay:\n   - Move your snake with arrow keys\n   - Collect food to grow longer\n   - Avoid collisions\n   - Pause anytime with 'P' key or Pause button\n   - Restart anytime with Restart button\n\n## Implementation Details\n\n- Built using Java Swing for graphics rendering\n- Uses AWT for keyboard input handling\n- Implements Dijkstra's algorithm with a priority queue for efficient pathfinding\n- The AI snake uses an adjacency list representation for the game grid\n- Custom countdown timer for game start\n- Separate timers for game logic and countdown\n- Responsive controls and smooth animation ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farsh-jafri%2Fdijkstra-snake-game","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farsh-jafri%2Fdijkstra-snake-game","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farsh-jafri%2Fdijkstra-snake-game/lists"}