All Projects â†’ czs108 â†’ Chase-AI

czs108 / Chase-AI

Licence: GPL-3.0 license
🎮 An artificial intelligence game to demonstrate the A* pathfinding. The enemy will try to get close to the agent and make it stuck between walls.

Programming Languages

python
139335 projects - #7 most used programming language
javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to Chase-AI

astar-typescript
A* search algorithm in TypeScript
Stars: ✭ 37 (+48%)
Mutual labels:  path-finding

Chase AI

Python ECMAScript License

Introduction

Cover

An artificial intelligence game to demonstrate the A* path-finding. The enemy will try to get close to the agent and make it stuck between walls.

Getting Started

Prerequisites

  • Install Python 3.11.

  • Install all dependencies.

    pip install -r requirements.txt

Running

python main.py

Configurations

The game configuration is in the src/config.json file.

Documents

See docs/wiki.md for the details.

Class Diagram

classDiagram

class Action {
    <<enumeration>>
    Stay
    Up
    Down
    Left
    Right
}

class Occupy {
    <<enumeration>>
    None
    Wall
    Role
}

class Terrain {
    <<enumeration>>
    Wall
    Grass
    Bush
}

class Status {
    int score
    int steps
    Agent agent
    Enemy enemy
}

class Map {
    terrain(x, y) Terrain
    occupied(x, y, Status) Occupy
    move_cost(x, y) float
}

Map ..> Status
Map ..> Occupy
Map *-- Terrain

class Role {
    <<abstract>>
    move() bool
    peek_action() Action
    stuck() bool
}

Role ..> Action
Role --> Map
Role -- Status

class Agent
Role <|-- Agent

class Enemy {
    list~pos~ path
}

Role <|-- Enemy

class ActionLevels {
    dict~Action, float~ weights
}

ActionLevels --> Action

class Strategy {
    <<abstract>>
    action_lvls(Status)* ActionLevels
}

Strategy ..> ActionLevels
Strategy ..> Status
Strategy --> Role

class Random
Strategy <|-- Random

class MoveAway
Strategy <|-- MoveAway

class MoveClose
Strategy <|-- MoveClose

class WallDensity
Strategy <|-- WallDensity

class AStar {
    list~pos~ prev_path
}

Strategy <|-- AStar

Enemy --> Random
Enemy --> AStar
Enemy --> MoveClose
Enemy --> WallDensity

Agent --> Random
Agent --> MoveAway
Agent --> WallDensity

Dependencies

License

Distributed under the GNU General Public License. See LICENSE for more information.

The image resources are from the book "Making Games with Python & Pygame" written by Al Sweigart.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].