Giter VIP home page Giter VIP logo

trashblaster's Introduction

lab3-games

Purpose

Trash Blaster is a simple game written in Python meant to be used to explore machine learning techniques. It was created as part of the Crash Course AI series on Youtube.

Contents

The trash_blaster.py file contains the game as well as the machine learning code. The bigbrain.txt file contains data from a machine which learned how to play Trash Blaster over more than 100,000 iterations of 200 games each. Read below to see how to run it with trash_blaster.py on your computer.

Before You Start

You must install Python 3 on your computer, as well as the following Python modules:

numpy

pygame

The modules can be installed by typing the following in your command line:

python3 -m pip install numpy pygame

Depending on how Python is installed on your computer, you may have to replace python3 with python in the command line.

How to Use trash_blaster.py

From the command line, type

python3 trash_blaster.py MODE

but replace MODE with one of play, learn, or playback. The functionality of each of these is described below.

play mode

This mode allows you to play Trash Blaster yourself, to test your skill. Move using the WASD keys, aim with the mouse pointer, and fire the blaster with the spacebar.

There are no flags applicable to this mode.

Example: python3 trash_blasher.py play

learn mode

This mode allows you to train an AI to play Trash Blaster.

Use the --save-best flag to make the program save the best AI "brain" each iteration.

Use the --save-file flag followed by a filename to determine the name of the file --save-best uses (brain.txt by default).

Use the --load-file flag followed by a filename to use the "brain" in that file as the starting point.

Use the --no-display flag to run the learning algorithm without opening a game window visible to the user. This is recommended to save time on long training sessions.

Use the --display-every flag followed by an integer to determine how many learning iterations pass between games shown to the user.

Use the --num-threads flag followed by an integer to determine how many threads should be used in the learning algorithm (4 by default).

Example: python3 trash_blaster.py learn --save-best --save-file mybrain.txt --display-every 5 --num-threads 2

playback mode

This mode allows you to play a previously-trained "brain" on randomly-generated games to see how it performs.

Use the --load-file flag followed by a filename to play the "brain" in that file. You must use this flag.

Example: python3 trash_blaster.py playback --load-file bigbrain.txt

trashblaster's People

Contributors

tweninger avatar danjr26 avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.