[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4762: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4764: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4765: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4766: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
Anisoptera Games - View topic - Genetic Algorithm/Neural Network integration
View unanswered posts | View active topics It is currently Fri Sep 18, 2020 12:27 pm



Reply to topic  [ 66 posts ]  Go to page 1, 2, 3, 4, 5 ... 7  Next
Genetic Algorithm/Neural Network integration 
Author Message

Joined: Wed Aug 19, 2015 7:00 pm
Posts: 73
Reply with quote
Hello All,

I have some experience writing some programs that use genetic algorithms to optimize designs in non-obvious ways. I see Reassembly as a great simulation to try and write a program dealing with ship designs. I could figure out the ship files and design a program to randomly create designs at certain P values, and I could give that program feedback, but I would have to do that manually have them engage in tournaments and feed the program the results. In order to have an effective program it would need to have thousands of generations happen in a timely manner. Not sure if this is possible, but I think it would be incredibly exciting to see the designs it would come up with. It would also be possible to have a program try to beat a player design, give it enough time and it could probably win.

Here is a good example of genetic functions coming up with novel solutions in advanced simulations.
https://www.youtube.com/watch?v=YZUNRmwoijw

Could be a cool project, let me know if anyone is interested.


Wed Aug 19, 2015 7:11 pm
Profile
User avatar

Joined: Mon Aug 17, 2015 4:44 pm
Posts: 669
Reply with quote
Artificial Intelligence, and by extension genetic algorithms and neural networks, are very interesting to me. It would be pretty neat, I think, if we could have the game run the physics and AI simulation with-or-without the graphic component to allow actually watching the ship in question tested or to simply do massive batches in a reasonable time. Seeing a genetically evolved ship enter and win a tournament would be something of a sight to behold.

Count me interested.

_________________




Thu Aug 20, 2015 11:23 am
Profile
Site Admin
User avatar

Joined: Thu Jan 16, 2014 2:45 pm
Posts: 562
Location: Los Angeles
Reply with quote
Me! Me!

It's possible to run tournaments in headless mode (no graphics, much faster) from the command line (e.g. bash or called from another program), so you could automate it.

path/to/ReassemblyRelease.exe
--HeadlessMode 1
--SandboxScript "arena <ship_file_1> <ship_file_2>"
--EnableDevBindings 1 # needed to expose the "arena" command
--NetworkEnable 0 # optional, makes startup faster
--LoadSuperFast 1 # optional, makes startup faster
--SteamEnable 0 # optional, makes startup faster
--TimestampLog 0 # log always called "log.txt" so it's easier to find

Just parse the log to figure out who won. You can put several arena commands in one startup, separate with a semicolon.

It might be difficult to construct ships programmatically from scratch. If you're comfortable with C++ I could probably extract some relevant bits of game code that would make it easier, we are already generating asteroids, plants, etc.

EDIT: added EnableDevBindings and path/to


Thu Aug 20, 2015 11:31 am
Profile

Joined: Wed Aug 19, 2015 7:00 pm
Posts: 73
Reply with quote
Yeah, I was looking at the LUA files trying to figure out how I would do it. Haha. Any sort of information on that would be helpful. Ironically the actual implementation would be fairly straight forward. The score could be used to judge fitness along with winning the match. Somewhat harder would be figuring out how to cross breed designs. Here is at least one approachable option.

-So, the simplest way would be to have the program randomly create a list of parts adding up to at or below a desired P value. If we wanted the initial population to be 1000 there would be 1000 lists of randomly selected parts. One way to assemble the parts would be to go through the list in order and the program would try and attach the part to put the center of gravity closer to the ship core. This would help the ships in being successful, and would provide a method of attaching parts in a repeatable way. If the CG was on the core then it could randomly attach it. The crossover operation could be done by swapping elements in the list. The top 100 could swap certain elements in the list with others in the top 100 and the top ten could be copied exactly to the next generation as champions of the population. The "mutation" aspect could be done by changing a few random elements in the lists. The higher the mutation, the more parts randomly changed.

Obviously this is one of the more randomized ways of doing it. Some lists wont work at all by producing too many thrusters and running out of attachment points. those would receive low scores or could be ignored entirely. But eventually lists with a lot of weapons, generators, or armor sections at the beginning and a lot of thruster elements at the end of the list would begin to take form. The more successful would crossover and mutate to create more and more diverse solutions which could lead to some novel, non-obvious designs that work well.... Theoretically. Haha.

Anyways, I have had a few years developing my own software for computer vision applications. My best language is c++ so i think it would be in my grasp if I had the proper help. I'm not sure how to run the game from console. Just ~ in game? And of course there is the little issue of making LUAs that make any sense to the game. I need a way to ensure the added parts will work, and I need a clever way of having a repeatable method for constructing lists of parts.

Anyways, I'm glad people like the idea. I would love to try and tackle this. I wanna see what the computer comes up with.

This opens up a possible feature by having a Nemesis faction. Maybe a genetic function running in the background could be developing designs to counter your current pallet. So if you play the game enough eventually a perfect counter to your faction will arise and challenge you for galactic dominance. That could be a fun late game feature if that were remotely possible. Anyways, I love the game and hope people keep showing interest.


Thu Aug 20, 2015 6:11 pm
Profile

Joined: Wed Aug 19, 2015 7:00 pm
Posts: 73
Reply with quote
After a quick google it appears as though \ is console. Excellllllent


Thu Aug 20, 2015 6:16 pm
Profile
User avatar

Joined: Mon Aug 17, 2015 4:44 pm
Posts: 669
Reply with quote
Using Score to judge fitness could be complicated. Score is a direct result of damage dealt and modules destroyed, but a ship that very quickly destroys a target will have a lower score than one that does low damage or distributes it instead. It also reflects the durability of the opponent as much as its own. Even looking at it backward, evaluating the opponents score to determine our fitness, can be misleading too. A ship that is able to win and is able to take a lot of damage (such as spinners or ships from factions without shields) is also noteworthy, as is a ship that is able to win without taking any. I don't know that score is a reliable attribute, there seem to be too many factors involved.

I've been playing with the LUA files for various things, like ship blueprints and block definitions, and I've got a pretty good understanding of it. The only thing I'm not sure about is the third parameter. It seems to be [block ID], {[x coordinate], [y coordinate]}, [rotation]. I think the rotation is in Radians and I'm not sure if the engine will try to snap it into place if the coordinates or rotation are off a bit. Until you mentioned using genetic algorithms to come up with stuff, I hadn't even really considered programmatically generating ships and was only looking at it from the standpoint of reading the files.

And I've been coding for well over a decade myself, but I've really only used PHP lately as my last programming job and most of my project since have been web-related. That said, I cut my teeth on C++ and could work with that, although I'd need a moment to refresh myself on it. I'd only ever done console programming in C++ though.

I think the mutation process would be the hardest to nail down. Generation can largely be handled through random part selection, but I think the mutation could easily break things as components are likely to be tight-fitting. Replacing a small armor with a large thruster, for example, wouldn't work. Coding it to be aware of such limitations before it picked parts would be tremendously difficult. I'd recommend something similar to how Dwarf Fortress seems to handle it. After generating the random world run it through some quick tests. Does it have at least one weapon? Does it have the ability to generate thrust in every direction? Those kinds of things, and if it fails then toss it out and try again. First generation could take a while and may require a bit of tuning to get the generator right, but I'm sure it'll come up with a lot of interesting things.

_________________




Thu Aug 20, 2015 8:16 pm
Profile

Joined: Wed Aug 19, 2015 7:00 pm
Posts: 73
Reply with quote
Agree completely. Wins would be heavily weighted as a fitness, and of course being the overall winner would be the best result. After a little playing around in the LUA I think you are right on the variables. I find it interesting that the importing program can sort of overlook errors. If I try to import a bunch of blocks with the same location it will snap as many of them to points near where I tell them to go, but eventually it will just ignore the blocks. It behaves just like in the building mode, so it seems. This could come in handy in the instance of crossover. If a component cant fit it will simply snap to a location where it can, or it will be ignored, which is not ideal, but it would be extremely hard to teach it otherwise.

another aspect of the lua files I seem to have discovered is that the blocks are loaded in order. If I have a thruster that is on a large block, but i do not load the large block first it doesn't appear to load. Not sure if this is true but it is what I am finding anyways.

The CG appears to be the 0,0 coordinate, which would make sense for thrust calculations, but that does make it difficult to create designs in the lua, especially randomly. This sort of works with the trying to have the ship core be the CG theory. Assume it is and have the program try and attach parts in ways that would balance it to make sure it was. Im fairly certain that any easily made program will have skipped parts in the list, missed data in crossovers, and designs that will load, but would otherwise be impossible to build. I can already get reversed thrusters and intersecting blocks from the tests I have done so far.

I agree with the point of filtering unusable ship designs, no weapons, no thrust, ect. That could be done in the lists, but of course I don't expect the lists to produce exactly what is in them when they are opened.


Thu Aug 20, 2015 8:36 pm
Profile

Joined: Wed Aug 19, 2015 7:00 pm
Posts: 73
Reply with quote
The coordinate system seems to work with the smallest square shape being a 10X10 block. If we gave a program a lookup table for the mass of the blocks, and maybe the size and shape of the blocks it could be possible to give it a better chance of making sure all the parts in the list are used. Maybe it is possible to know where all the attachment points will be depending on orientation and shape. At a min this would be fairly easy for all square blocks. Ha, at least be a start.

For at least a prototype run I could overlook impossible designs, ships not loading completely, crossovers weakening designs, etc. I guess those would be some bugs to work out.

In order to truly let the program produce non glitchy lua files the origin would need to be dynamic. Because the CG is the origin the C++ ship creator would need to solve for the CG before the program uploads it. This would be if we didnt want to limit the CG to being on the ship core, or some other known point.

Yeah, im sure there is a lot that can be thrown at this. I see what happens when I run an knowingly glitchy ship creator.


Thu Aug 20, 2015 8:47 pm
Profile
User avatar

Joined: Mon Aug 17, 2015 4:44 pm
Posts: 669
Reply with quote

_________________




Thu Aug 20, 2015 8:50 pm
Profile
User avatar

Joined: Sun Apr 12, 2015 3:13 am
Posts: 283
Reply with quote
The "CG" as you name it can be at coordinate that are not 0,0, as long as it is not rotated
(I have a few blueprint with non 0,0 core. And the time I tried to rotate the core => the ship didn't load)

I really wish you luck in your project, as it could be quite awesome!

_________________
Using Beta, always! (Well, for Reassembly)
(Also known as GATC on Steam)


Fri Aug 21, 2015 6:47 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 66 posts ]  Go to page 1, 2, 3, 4, 5 ... 7  Next

Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software