Log In  


Cart #ccga-49 | 2024-12-20 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

CC GENETIC ALGORITHM

If runs are taking too long, Consider disabling FLIP? on page 3 of the settings (READ SETTINGS REFERENCE BELOW)

This is a mod of Celeste classic where you get to watch a genetic algorithm learn how to play Celeste classic.

Wiki page for the Genetic Algorithm

SETTINGS REFERENCE

CELESTE CLASSIC GENETIC ALGORITHM [CCGA]
MOD BY ANTIBRAIN

[SETTINGS REFERENCE]

`FPS` : Simulation FPS. The timer in the corner will not be affected. 
You do not need to set it to a normal number. framerates like 22 and 46 are just fine.

`# OF PLAYERS` : How many players to simulate at once. 
More players means it will learn faster, but too many can lag the machine.

`CYCLE LEN` : How many cycles to run before selecting iteration to reproduce and grow.

`ADDED PER C` : How many FRAMES to add after every cycle SET. [after `cycle>max_cycle`]

`FALLBACK` : Min # of frames the ai is allowed to go back from preserved solution in the event of failure.

`MAX_H YSPD` : If enabled, MAX_HEIGHT will ONLY be updated if THIS.SPD.Y==0

`COIN REWARD` : Amount of points given for collecting a coin.

`BASE MUTATE` : The base mutate chance from 0-100%, without any deaths or changes. 
The mutate chance for each instance will never go below this number.

`SFX?` : Toggles sound effects that instances can make. (dashing, jumping, etc)

`MUSIC?` : Toggles music.

`SHOW N` : Toggles whether to display each player's instance number on itself. Enable to keep track of players.

`FLIP?` : Toggles whether to call flip() every frame to update the screen. When disabled, each frame will be updated instantly after the last frame. When disabled, It does break menus and cause a LOT of flickering, so use caution.

`IMPRV FALLBK` : Number of frames to wait after last improvement to try again from improvement.

`IMPRV MOD` : Number of frames to add after improvement fallback, to avoid an infinite loop. Can be disabled.

`MTATE KEEP` : Toggles if kept frames can be mutated.

`SEED RND?` : Toggles weather to seed the rnd function. Read below for info about modifying the seed.

NOTE THAT PAGE 5 SEED SETTINGS ARE ONLY AVAILABLE IF `SEED RND?` IS ENABLED.

`S` : Shows current seed.

`INC BY .1` : Increments or decrements seed by .1.

`INC BY 1` : Increments or decrements seed by 1.

`INC BY 10` : Increments or decrements seed by 10.

`DASH CHANCE` : % Chance for GA to decide to dash each frame. 10% by default.

`â–¤  PAGE X/Y  â–¤` : Current page number. Left/right to view other pages.

Numbers can be changed with L/R. Booleans [TRUE/FALSE] can be changed with any button.

CHANGELOG

CELESTE CLASSIC GENETIC ALGORITHM [CCGA]
MOD BY ANTIBRAIN

[CHANGELOG]

1.0: 
- Initial release

1.1:
- Added - This changelog
- Changed - Balloons now reward the ai for collecting them THE FIRST TIME
    - This is to increase the chances of winning levels like 2800m and 900m, where balloons are the only way of beating them, and there isn't much vertical reward.

1.2:
- Added - Reward coin collectibles that make ai happy when grabbed :D
    - This is to make sure the ai wont just ignore certain VERY IMPORTANT sections of levels. aka ALL OF 200M AAAAAAAAAAAAA

1.3:
- Added - Several menuitem features to change how the AI "Learns", As well as sim speed and such.
    - Functions include: FPS (10-60), Weather springs reward the AI, Weather Walljumping rewards the ai (Based on height walljumped from), Reward granted from collecting a coin, Score penalty for dying, Frames added per generation, % chance to mutate each instruction not kept, and the ability to reset the AI, starting fresh with new params.
- Changed - Coins no longer respawn once collected, as the ai would just die to get them again, and it follows the same path regardless of if the coin is there or not if it was collected at least once. (unless it died and the death pen is more then coin reward)

1.4:
- Removed - Reset AI menuitem
    - Caused too many issues, might add back later once fixed.

1.41:
- Fixed - "Last Improvement" Showed FRAME number instead of GENERATION number

1.5:
- Added - Simple title screen with basic instructions
    - This is to allow changing settings before a simulation has been started.
- Added - SRAND settings
    - Accessible when on title screen, select to enable, l/r to change seed.

1.6:
- Changed - Dying now removes all collectibles.
    - This is to prevent the ai from just dying over and over again to keep getting the reward from grabbing coins or berries.

1.61:
- Removed - Testing things i accidentally left behind (Whoops!)
- Fixed - Typos

2.0 :
- Major release
- Removed - A ton of settings that dont work anymore
- Removed - Some text that doesn't apply anymore
- Added - Multiple players at once
- Added - Fallback system
    - Based on deaths that generation. The more deaths the farther back mutations can be made, up to two seconds if 90% die, and 10 seconds if 100% die. This is to ensure that they dont get softlocked.
- Changed - Its a real genetic algorithm now
- Changed - Reward values
    - Higher death penalty
- Changed - Height Rewards
    - Only counts as grounded if this.spd.y==0
- Changed - Most of the algorithm and code to work with multiple instances.
- Changed - Title Screen
- Changed - Keep system doesn't HAVE to keep "working" solutions if they are terrible

2.1 :
- Fixed bugs
- Changed - Fallback only resets to unmodified best if ALL instances die in a single generation.

2.2 :
- Fixed bugs
- Working towards fitness choosing error
    - For some reason, the program will choose a different instance then the one who was selected to reproduce, to reproduce. I have no idea why that is, as its not supposed to do that. Also sometimes instruction sets get boggled randomly and i dont know why. Patch in progress.

2.3 :
- Fixed bugs
    - Note that this version is not public, due to some issues regarding the fitness function.

3.0 :
- Added - Cycle Based system
- Added - Ability to change `max_cycles`, and `frames_added_per_cycle` in pause menu. [SEE SETTINGS REFERENCE ABOVE]
- After X cycles, Best of X cycles reproduces, Add X frames.
- Changed - Algorithm now reproduces after `cycle>=max_cycle`
- Removed - Old reproduction system
- Fixed - Issue where system would choose wrong iteration to reproduce.
    - I'm not entirely sure what fixed it, but it definitely shows up way less now.
- Changed - Reformatted [CHANGELOG] and [COMMAND REFERENCE] to be in code blocks, because i think it looks nice.

3.1 :
- Changed - Default Population from 5 -> 10
    - 5 Was simply too slow. 10 is low enough where the flickering wasn't too bad, and high enough where it wont take too long to beat scores and learn.
- Updated - Cart label

3.21 :
- Attempt to fix bugs
    - At STILL for SOME REASON just picks the WRONG instance to reproduce. Most of the time this wont really do much besides make it take longer to beat levels, but sometimes it can lead to them all dying over and over.

3.22 :
- Added - Ability to change fallback length
    - This is to allow users to work around a suspected cause of the wrong_reproduce bug, until it is fixed.

3.3 :
- Added - Many settings accessible from pause menu on title screen. See [COMMAND REFERENCE] Above for more info.

3.31 :
- Changed - Each instance may only pick one coin up per generation
- Changed - Coins no longer despawn on collect
    - These two fixes are to make sure that instances dont mess things up and devalue other, better instances.

3.4 :
- Added - Ability to disable FLIP() call every frame
    - Note that this causes a lot of flickering and breaks the pause menu.
- Removed - FREEZE function. Removed so that the whole cart will not freeze when an instance opens the big chest containing the gem.

3.41 :
- Fixed - Timer silliness when FLIP() is disabled.

3.5 :
- Changed - Fallback system only happens if all instances die in a run
- Changed - Fallback duration is now no longer a dynamic parameter 

3.51 :
- Changed - Changed coin behavior back to what it was before
    - Coins now despawn on collect instead of instances only being able to collect one coin per cycle.

3.52 :
- Fixed - Issue with fallback system not triggering properly, or even at all, upon a failure.

3.6 :
- Fixed - LOTS of bugs
- Removed - Ability to change death penalty
- Changed - Death penalty is now a fixed penalty of "-16000"
    - Why keep bad solutions?

- NOTE - Please note that, due to a few bugs, the ai will not always be able to complete levels quickly, or in rare cases, at all. 
- NOTE - With this new patch, it is now 100% possible for the ai to beat the game.

4.0 :
- Added - AI now plays each level individually (eg, plays 100m until win, then plays 200m until win)
- Added - Able to replay the entire run after ai reaches flag at summit
- Fixed - SO MANY BUGS
    - Every known bug is now fixed!! Please let me know if you find any more issues with the cart.
- Changed - Fallback is now by default 5f (5 frames)

4.1 :
- Changed - Decreased mutate chance on death (70%->20% Per instruction)

4.2 :
- Fixed - Issues when multiple instances interact with a single object at once

4.3 :
- Fixed - Issues with fallback system (again)
- Changed - MAX_FALLBACK is now a dynamic parameter. Repeated failures will increase fallback range.
    - FALLBACK (Setting) Is now the minimum value instead of the maximum value. See settings reference for more information on settings.
- Changed - Default Population is now 25.
    - After a lot of testing, 25 instances was the best and fastest overall. Lower values such as 10 would generate suboptimal solutions, and large values like 50 would take a really long time.
- Note - Larger population sizes generate better solutions but are slower, and small sizes will generate worse solutions, but are much quicker.

4.31 :
- Changed - MAX_H YSPD (setting) is now false by default.

4.4 :
- Changed - Keys now award bonus score
- Changed - Cartridge ID is now #ccga

4.41 :
- Changed - Keys are now worth 15 points, to prevent the ai from cheating
- Changed - After ai's time is more then 900 frames, reset to best score. This is to avoid ram crashing.

4.42 :
- Fixed - Issue where scores werent properly reset on level win

4.43 : 
- Added - Reset all instances if all of them died more then 25 times in a row
- Changed - Reset all after 900 frames instead of going back to best

4.44 :
- Changed - Minimum mutate chance per instruction is no longer dependent on current cycle
- Changed - Mutate chance increase on death (+10 -> +30*(DEATH_ROW+1), where 'DEATH_ROW' is failures in a row)

4.5 :
- Added - New coin type for when AI needs to save a dash

4.51 :
- Fixed - Issue with new coin type collecting at wrong times
- Fixed - Bad coin placement in one pregem level

4.6 :
- Fixed - Issue with timer overflowing
    - It now will only overflow after 32768 DAYS (90 Years)
- Fixed - Issue with springs not hiding when below crumble leaves.

4.7 :
- Fixed - Issue where playback was being mutated
- Fixed - Issue where too many players were being spawned during playback

4.71 :
- Fixed - Issue with springs giving their reward more then once

4.72 :
- Changed - Default Minimum Fallback length lowered (5f -> 2f)

4.73 :
- Added - Now shows user current memory usage.

4.74 :
- Fixed - Ai will no longer preserve garbage data. (Eg, if improvement at frame 100, only frames 1-100 are kept). 
    - This may have fixed the replay issue. if anyone reaches the summit, please let me know via discord. (antibrain0)

5.00 :
- Added - Speed based reward incentives
    - Ai will now strive for fast solutions in addition to working ones. If the ai finds a faster solution to a solved area, it will consider that an improvement.
- Added - Since_improvement fallback and setting
    - Ai will reset itself to last improvement after a set number of cycles. 60 by default. feel free to change it in the options.
- Added - Ai is now able to mutate kept solutions
    - This is to allow for the possibility for a faster solution. much smaller chance to mutate an instruction if it is being kept.
- Changed - Default mutate chance is now 0.1%

5.01:
- Added - Mutating kept frames is now toggleable (Off by default)

5.02:
- Changed - Base mutate chance reverted to 0%

5.03:
- Fixed - Issue where best frametimes were not being reset

5.04.1:
- Changed - Temporarily removed some speed functions. GA now works as intended.
    - Please note that speed based learning may not function in this version.

5.1 :
- Added - AI can now increase how long until a frametime fallback. (see settings reference `IMPRV MOD`)
    - Can be disabled, of course.

5.2 :
- Added - Ability to seed RND(). See settings reference for more information.
- Fixed - Issues with kept solutions keeping garbage data.
- Fixed - Issue where frametimes were not being respected properly / being respected too much.

6.0 :
- Fixed - Replay system. Please dm "@antibrain0" on discord if you encounter any issues, or just leave a comment below.
- Changed - Increments for seed

6.1 :
- Changed - GA now presses an input for frame instead of toggling its held state when called.

7.0 :
- Fixed - Issues with removing garbage data
- Fixed - Issues with saving garbage data
- Fixed - Problem where GA would ignore improvements
- Fixed - Problem where GA would ignore frame-based improvement
- Fixed - Issue when checking for improvements each frame and setting variables
- Fixed - Issue with handling garbage data with improved frames
- Fixed - Issue with managing and checking when an improvement took place, and rebuilding kept data based on improved frame.

7.1 :
- Added - Can now chance % chance for GA to dash each frame. (10% by default)
- Added - If run is seeded, now displays seed above timer.

25


1

gonna leave this in the background for a while, brb


2

half an hour later,

last improvement gen: 88
generation: 300

kind of wish pico-8 had turbowarp like for scratch


2

This is an interesting experiment! I wonder if you'd get faster results by evolving a 2d matrix that determines actions based on the player's screen position rather than your current time-based list of actions.


1

AI generation 100 made it past the pink flower.


3

thats so cool, I wonder if you could do the same for other games as well.
After one about 55 minutes, I stopped. I think it couldn't get past gen 175.


3

had the last one running for 13 hours, then v2 came out and now I'm up running it again :) cool stuff friend


1

Really cool with the improvements. Can you make it so that after you pass a level, you don't have to watch it redo all the levels before that level?


1

yes! got past 100m


1

gen 220 to finish the level!!! gen 135 was the one that reached the strawberry platform and it was fabulous, and then gen 199 was the one to reach the end platform
if youre curious my settings were cycle 1, frame increase 1, 20 madelines


1

@hwd2002 yeah i think we already have a bot that does that for every level called searchdelie in the celeste classic discord, except you have to give it a list of inputs to follow and it runs in python. i hope you didn't mean something else.


3

@superboi0119
Let's not confuse a list of predetermined inputs to be an ai


2

AI loses a lot but improves little by little


1

ye



[Please log in to post a comment]