Wrong section: but it's the only section that I can see:
Does anyone see any issue with this code?
http://cfrancis.heliohost.org/Tests/(This isn't my homework, by the way, it's something unrelated)
It's supposed to be generating a series of triangles similar to this article:
http://rogeralsing.com/2008/12/07/genetic-programming-evolution-of-mona-lisa/I know the American flag is complex, I've tried it with a solid color image and it works well (Nearly perfectly), but trying it with an image of the American Flag, Darth Vader, or even a photo of Adam Sandler makes the program fail to work.
Thanks, SGDK2 Community.
EDIT: I've seemed to have found the heart of the problem!
But I don't understand why it's a problem.I want to get/set the DNAA for a particular Polygon instance using this.DNAA and this.child.DNAA, but for some reason, JavaScript sets
every DNA member to the value that I say for every Polygon Instance in the Population array when I do so, why is JavaScript doing this? In my fight() function, whenever I set the DNAA value of this.DNAA, the browser console is telling me that for all objects in Population, their DNAA is also being set to my value automatically.
My main question: Why is it that whenever I try to set the value of this.DNAA, it just ends up setting the value of all of the DNA arrays for every Polygon Object in my Population Array, rather than just setting it for the Polygon Object I'm trying to reference with, "this". I can get all other members of my Polygon Instance with "this.v1" or "this.red" but for "this.DNAA", it throws errors.
(DNAA is just an Array<Number> of size 3.. Once I can set the DNA for specific
instances of Polygon, rather than using a shared DNA pool for all Polygons, I can end up with distinct colors, rather than a jumbled mess of all of the colors on the screen.)
I'm reading up and it says that JavaScript isn't good with instances, that there are only singletons in JavaScript. That's funny, because for every other member of my Polygon class, getting and setting instance-wise is working fine, but for DNA, it seems to be failing severely.
http://javascript.about.com/od/objectorientedjavascript/a/oop21.htmAnother area that I can't understand is why my Array.splice method doesn't work as expected. It's removing certain Polygon instances that honestly, shouldn't be removed from my list. The underlying code is right, but the splicer is splicing the wrong objects from my collection.