Skip to content

🎮 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.

License

Notifications You must be signed in to change notification settings

czs108/Chase-AI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

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
Loading

Dependencies

License

Distributed under the MIT License. See LICENSE for more information.

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

About

🎮 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.

Topics

Resources

License

Stars

Watchers

Forks