Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
*.pyc
*.json
.vscode
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,39 @@ FlappyBirdLike and AI

Base on this flappy bird like using pygame[1]: https://github.com/sourabhv/FlapPyBird
Follow his instruction to be able to run the game.
You need `numpy` and `pygame` to be able to launch flappy.py. (they are both instalable with `pip`)

Why
---

This is a simple flappybird without any images or welcome screen or what ever. This is made to be able to use AI on it.

I have used a custom and simple neural network. And based the flappy bird on a reinforcement method.


How
---

command :
`python flappy.py <train | notrain> <filename>`
`<train | notrain>` specify if you want to launch the game in training mode or not.
`<filename>`specify the json file where you want to save the best player training brain.

example :
`python flappy.py train goodplayer.json` will use the goodplayer.json (or create it if it doesn't exist) to populate players based on the same brain and train this population to provide a better brain. This new brain will be stocked in the same file.

`python flappy.py notrain goodplayer.json` will use the goodplayer.json (or create it if it doesn't exist) to create a player with the same brain and just play.

Tips :

You can speeding up or slowing down the game by using the arrow key :
- key up : speed up
- key down : slow down

By a simple mouse click, you can save your actual runner.

Enjoy

ScreenShot
----------

Expand Down
13 changes: 13 additions & 0 deletions const.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FPS = 30
SCREENWIDTH = 512
SCREENHEIGHT = 512
# amount by which base can maximum shift to left
PIPEGAPSIZE = 90 # gap between upper and lower part of pipe
PIPEHEIGHT = 320
PIPEWIDTH = 50
BASEY = SCREENHEIGHT * 0.79 # ground is 21% of the total height
BASEX = 0
PIPEVELX = -4
VELYMAX = -18

MAX_POPULATION = 350
Loading