Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
1 registered members (AndrewAMD), 14,661 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Genetic Algorithms in C-script #115404
03/05/07 22:28
03/05/07 22:28
Joined: Jul 2004
Posts: 1,205
Greece
LarryLaffer Offline OP
Serious User
LarryLaffer  Offline OP
Serious User

Joined: Jul 2004
Posts: 1,205
Greece
Hello,

This is a GA implemented in c-script, and demonstrates solving a hard bin packing problem. For more information on Genetic Algorithms and the problem i attempt to solve, read here.


Before downloading this, i would advise to learn a bit about GAs first, or none of this would make much sense. Do NOT attempt to learn how Genetic Algorithms work just by looking at my source code as this is the wrong way to learn.


If you've already done your research, and the following paragraphs makes some sense to you, you may now download this program


Genetic Algorithms Supported:

Encoding
--------
k-ary


Algorithms
---------
steady-state
Hillclimbing


Selection
---------
k-ary tournament
replace-worst

Mutation operators
------------------
Single-gene new-allele
M-random-gene new-allele
probabilistic

Crossover operators
-------------------
one-point
two-point
uniform



The program is configured to run with steady-state binary tournament selection and replace-worst. It runs for 100,000 evaluations, with population size 10, single-new-allele mutation and uniform crossover, which has been proven to be the best configuration for the bin problem. The Fitness function is: (Heaviest Container - Lightest Container) + (Number of invalid type pairs * Total Weight of all items together(TW) )


While you run the program, you'll get a lousy screen like this, since i didn't had time to work on an interface (the whole thing took me a day)



After the GA is completed (100,000 evaluations will take a few minutes, reduce them if you're in a hurry), the program will shut down and you'll be able to see the results from the generated output files:

"Chromosome.txt"
"Containers.txt"
"ContainerWeights.txt"

Code:

ContainerWeights.txt

CONTAINER #0

Items: 15

Weight: 11977



CONTAINER #1

Items: 16

Weight: 11989



CONTAINER #2

Items: 21

Weight: 12077



CONTAINER #3

Items: 19

Weight: 11883

...



Again, don't bother on this unless you've a basic understanding of GAs, or none of this will make much sense. This contribution is to help people implement their own GAs to c-script, or even use my code for their own GA directed problems.



Cheers,
Aris


INTENSE AI: Use the Best AI around for your games!
Join our Forums now! | Get Intense Pathfinding 3 Free!
Re: Genetic Algorithms in C-script [Re: LarryLaffer] #115405
03/06/07 00:36
03/06/07 00:36

A
Anonymous
Unregistered
Anonymous
Unregistered
A



What a contribution!

Without a documentation of the interfaces nobody (even the one knowing about hill climbing, ...) will be able to try/use your code...

Don't throw your genius this way on us

mercuryus

Re: Genetic Algorithms in C-script [Re: ] #115406
03/06/07 00:48
03/06/07 00:48
Joined: Aug 2005
Posts: 1,185
Ukraine
Lion_Ts Offline
Serious User
Lion_Ts  Offline
Serious User

Joined: Aug 2005
Posts: 1,185
Ukraine
Thank you, Larry. Some time ago I've used such algorithms (in C implementation) for an image editor to generate funny images. For what (in C-script) you are using this? (if this isn't a secret)

Re: Genetic Algorithms in C-script [Re: Lion_Ts] #115407
03/06/07 10:53
03/06/07 10:53
Joined: Jul 2004
Posts: 1,205
Greece
LarryLaffer Offline OP
Serious User
LarryLaffer  Offline OP
Serious User

Joined: Jul 2004
Posts: 1,205
Greece
mercuryus, what's with the pun? All i wanted was to spread GAs a little more to the community. And it's not like i didn't write a huge post explaining what Genetic algorithms are, before getting a bit technical. I also gave you a link so you can get started on GAs before attempting this program too, so what more do you want from me?

Hey, Lion_Ts.. I was just fooling around. I knew c-script is slow and wanted to see how GAs would work in it and if i'd get good results in some reasonable time... Eventually, i'll make more reseach on this.. GAs fascinate me like anything else.. I can't stop thinking of stuff I could do with them, given i had more time...

Cheers,
Aris


INTENSE AI: Use the Best AI around for your games!
Join our Forums now! | Get Intense Pathfinding 3 Free!
Re: Genetic Algorithms in C-script [Re: LarryLaffer] #115408
03/06/07 13:46
03/06/07 13:46
Joined: Jan 2003
Posts: 4,305
Damocles Offline
Expert
Damocles  Offline
Expert

Joined: Jan 2003
Posts: 4,305
Well, I am not good in analysing other peoples code,
but the GA algorythm got me thinking of
a Testprogram to link this approach with simple Neural Nets,
without using (the unnatural) Backpropagation.

The Neural Nets themselve dont learn. They are Preprogrammed and wired,
much like in simple Insects. The leaning takes place by the genetic mutation
and selection in the genes that build up, wire and weight the neuron.

Seems much more natural to me than some "Big Brother"
that used Sigma Functions, and mathematical propagation Methods.

Re: Genetic Algorithms in C-script [Re: Damocles] #115409
03/06/07 15:34
03/06/07 15:34
Joined: Jul 2004
Posts: 1,205
Greece
LarryLaffer Offline OP
Serious User
LarryLaffer  Offline OP
Serious User

Joined: Jul 2004
Posts: 1,205
Greece
Hey Damocles,

i'm not sure i follow. How exacly do you intent to use NNs on this problem? If you care to give this a shot, and manage to get results similar or better than GAs, i'd be Really interested in this!

Cheers,
Aris


INTENSE AI: Use the Best AI around for your games!
Join our Forums now! | Get Intense Pathfinding 3 Free!
Re: Genetic Algorithms in C-script [Re: LarryLaffer] #115410
03/06/07 17:02
03/06/07 17:02
Joined: Jan 2003
Posts: 4,305
Damocles Offline
Expert
Damocles  Offline
Expert

Joined: Jan 2003
Posts: 4,305
Oh, this is not directly related to the problem-case you have stated.
It is more a general Idea on evloving neural nets.
I will think out a test application first to apply the nets sensefully
to a problem, and then try to make them evolve using GA.

Re: Genetic Algorithms in C-script [Re: Damocles] #115411
03/06/07 17:20
03/06/07 17:20
Joined: Jul 2004
Posts: 1,205
Greece
LarryLaffer Offline OP
Serious User
LarryLaffer  Offline OP
Serious User

Joined: Jul 2004
Posts: 1,205
Greece
oh i see...
yes, training NN weights with GA is very normal. If you wanna check out some really cool source code for your test app, give this site a try.

I know i've already referenced this site, but i'm just obsessed with this guy. He makes every subject seem like the easiest thing in the world.. definatelly the best tuts on the net about EA stuff.

Cheers,
Aris


INTENSE AI: Use the Best AI around for your games!
Join our Forums now! | Get Intense Pathfinding 3 Free!
Re: Genetic Algorithms in C-script [Re: LarryLaffer] #115412
03/06/07 21:49
03/06/07 21:49
Joined: Aug 2005
Posts: 1,185
Ukraine
Lion_Ts Offline
Serious User
Lion_Ts  Offline
Serious User

Joined: Aug 2005
Posts: 1,185
Ukraine
Quote:

I can't stop thinking of stuff I could do with them, given i had more time...



You are the man! even a feather in a right hands may be a weapon...
good luck and post something further about your research if you want.

Re: Genetic Algorithms in C-script [Re: LarryLaffer] #115413
03/07/07 07:08
03/07/07 07:08

A
Anonymous
Unregistered
Anonymous
Unregistered
A



Quote:

mercuryus, what's with the pun? All i wanted was to spread GAs a little more to the community. And it's not like i didn't write a huge post explaining what Genetic algorithms are, before getting a bit technical. I also gave you a link so you can get started on GAs before attempting this program too, so what more do you want from me?




Sorry for beeing ironic.
I didn't saw the other thread. Without it's hard to understand...

mercuryus

Page 1 of 2 1 2

Moderated by  adoado, checkbutton, mk_1, Perro 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1