Skip to content

πŸ‘Ύ Creating Pacman Agent using just ML (Classification + Regression)

Notifications You must be signed in to change notification settings

aaronespasa/pacman-ml-agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

23 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Creating Pac-Man Agent using Machine Learning (Classification + Regression)

pac-man banner

Welcome to the Pac-Man Agent project! The aim of this project is to create an intelligent Pac-Man agent using machine learning techniques, specifically classification and regression, to predict Pac-Man's actions and future scores. This repository contains all the necessary files and instructions to get started and understand the project.

Table of Contents

  1. Overview
  2. Getting Started
  3. Project Structure
  4. Methodology
  5. Results
  6. Conclusions and Challenges

Overview

This project uses machine learning algorithms to create a Pac-Man agent that can play the game autonomously. The agent's actions are determined using a classification model, and its future score is predicted using a regression model. The main goal of this project is to develop an agent that can achieve a high score by following the optimal path to eat the ghosts while avoiding obstacles.

Getting Started

To get started with the project, follow these steps:

  1. Clone the repository to your local machine:
$ git clone https://github.com/aaronespasa/pacman-ml-agent.git
$ cd pacman-ml-agent
  1. Install the required dependencies:
pip install -r requirements.txt
  1. Run the project:
$ python pacman.py

Project Structure

The project is organized into the following structure:
pacman-ml-agent
β”‚
β”œβ”€β”€ RandomAgents.py
β”œβ”€β”€ busters.py
β”œβ”€β”€ bustersAgents.py
β”œβ”€β”€ bustersGhostAgents.py
β”œβ”€β”€ data
β”‚   β”œβ”€β”€ future
β”‚   β”œβ”€β”€ present
β”‚   └── raw
β”œβ”€β”€ distanceCalculator.py
β”œβ”€β”€ filterFuture.py
β”œβ”€β”€ filterPresent.py
β”œβ”€β”€ game.py
β”œβ”€β”€ getting_dataset.sh
β”œβ”€β”€ ghostAgents.py
β”œβ”€β”€ grading.py
β”œβ”€β”€ graphicsDisplay.py
β”œβ”€β”€ graphicsUtils.py
β”œβ”€β”€ inference.py
β”œβ”€β”€ keyboardAgents.py
β”œβ”€β”€ layout.py
β”œβ”€β”€ layouts
β”œβ”€β”€ models
β”‚   β”œβ”€β”€ classification
β”‚   └── prediction
β”œβ”€β”€ pacman.py
β”œβ”€β”€ projectParams.py
β”œβ”€β”€ textDisplay.py
β”œβ”€β”€ util.py
└── wekaI.py

Methodology

The project methodology involves several stages:
  1. Data Collection: Game data is collected using various maps and saved in the .arff format.
  2. Data Processing: The raw data is pre-processed and separated into present and future datasets.
  3. Model Training: Classification and regression models are trained using the processed data.
  4. Model Evaluation: The models are evaluated using the Experimenter in Weka.
  5. Model Selection: The best performing models are selected for implementation in the Pac-Man agent.
  6. Agent Implementation: The trained models are used to create an autonomous Pac-Man agent.

Results

The project used various machine learning algorithms for classification and regression tasks. The best performing algorithms were:
  • J48
  • IBK with K = 1
  • RandomForest
  • RandomTree
  • K Star

The results were significantly improved (around 6%) after increasing the number of training instances.

Conclusions and Challenges

The main challenge faced during this project was identifying the most relevant attributes for training a generalizable Pac-Man agent. A large number of tests were performed to find the best combination of instances, maps, attributes, training sets, and test sets. Despite the changes, the best performing algorithms remained consistent throughout the experimentation process.

To overcome this challenge, we iteratively refined the feature set and experimented with various machine learning algorithms, eventually settling on a set of features and models that produced an agent with reasonable gameplay behavior. However, there is still room for improvement, and further research could potentially result in a more advanced and adaptable Pac-Man agent.

In conclusion, this project demonstrates the potential of using machine learning techniques to create an autonomous Pac-Man agent. By carefully selecting the features and algorithms, we were able to develop an agent that can achieve a high score in the game. This project serves as a stepping stone for future research and development in the field of game AI and machine learning.

About

πŸ‘Ύ Creating Pacman Agent using just ML (Classification + Regression)

Resources

Stars

Watchers

Forks