Quantcast
Channel: Ben Turner's Blog » ICM
Viewing all articles
Browse latest Browse all 9

Genetic Crossings (ICM Final Project Presentation)

$
0
0

[see more documentation: proposal, part 2, part 1]

Focus

For Heather Dewey-Hagborg’s Intro to Computational Media class at NYU’s Interactive Telecommunications Program, I decided my final project would involve creating a simulation incorporating the traits of people, nations, and religions, creating offspring who are summations of their genetics and environments.

Processing is a great language for easily visualizing data.  I early on realized I wanted to make a visualization as a study for Galapag.us, my eventual thesis for developing a reputation and identity system that centralizes all the data you’ve ever created about yourself and what others say about you so that you can develop algorithms and formulas for evaluating and comparing your results with others.

Inspirations

Visually, I was interested in karyograms, Punnett squares, chromosome stainings, and representations of solar systems.

 

Application

The sketch initializes a world and fills it with 5 people to start off with, Albert Einstein and Gisele Bundchen, and 3 random individuals.  Time begins, with each pass of the draw() loop aggregated and calculated into a rough approximation of years in time.

People have innate traits and characteristics saved into variables: strength, intelligence, wisdom, charisma, stamina, wit, humor, education, creativity, responsibility, discipline, honesty, religiosity, entrepreneurialism, appearance, money, gracefulness, stress, health, luck, talent at math, talent at art, talent at sports, whether employed, happiness, nationality, religion.  They are on a scale from 1-10, with 1 implying the most negative state and 10 being the best. (e.g. poor health vs. superb health, ugly vs. gorgeous, a stressed-out person vs. a carefree one, etc.)

They are born into nationalities/regions: USA, UK, Africa, China, South America, with the traits security, innovation, job opportunity, immigration policy, life expectancy, education, sanitation, standard of living, pollution, biodiversity, crime, political freedom, and nutrition.

They have religions/ways of life: Christianity, Catholicism, Judaism, Islam, Taoism, Buddhism, Confucianism, with the traits commercial, morality, hierarchy, and portability.

You can already see the terminology isn’t precise (nations vs. regions), and I’m missing tons of variables.  Had I more time to code in more negative effects, I would add personality traits like deception, violence, libido, etc.

God is in the sketch.  All people are connected with him.  He also has baller stats:

// who art in Heaven
  god = new Person(-1, 0, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
    0, 0, 10, 0, 10, 10, 10, 10, 10, 10, 10, 10, "God", "null", -2, -2, -1, 0, -1, 0, 1, 1100, 600);

Every pass through draw(), it’s determined whether 1) there’s a potential match (via the flirt() function), matching a male and a female (sorry, I didn’t have time to code in adoption et al), 2) there’s chemistry, and 3) if so, then sex().  Chemistry() requires a degree of likeness in appearance, money, religiosity, and some other superficial requirements. Then again, there’s also the matingDance.beer() function, which I’m particularly proud of:

else if (matingDance.beer(flirter1, flirter2)) {}

Social lubrication — some of the basic requirements for chemistry are, um, degraded, leading to easier baby-making.  This is also good for preventing my sketch from not having enough chemistry to produce offspring between the people.

Women between ages 18 and 50-ish are fertile (I had to adjust the numbers so that the sketch would work throughout its duration instead of the whole civilization losing an ability to breed by becoming too old) and need at least 5 “years” or something between babies before they can have another child.

boolean checkFertile(int _flirter1, int _flirter2) {
    int female = 0;
    boolean fertile = false;
    if (person[_flirter1].gender == "female" && person[_flirter1].alive == true) {
      female = 1;
      if ((currentYear - person[_flirter1].lastBaby > gestationRate) &&
       (person[_flirter1].age >= 18) && (person[_flirter1].age = 18)) {
        fertile = true;
      }
    }
    else if (person[_flirter2].gender == "female" && person[_flirter1].alive == true) {
      female = 2;
      if ((currentYear - person[_flirter2].lastBaby > gestationRate) &&
       (person[_flirter2].age >= 18) && (person[_flirter2].age = 18)) {
        fertile = true;
      }
    }
    return fertile;
  }

Children are created through matingDance.punnettSquare() of their parents.  The parents’ traits are averaged together and then some mutation is introduced for variability in the children.  I think I coded it so some traits change more than others, and some don’t change at all.

People can reach somewhere around 65-ish before death becomes a regular reality.  Once people die, they are removed from the population size, which is capped at 40 — allowing another child to be born somewhere if there’s less than 40 people alive.  The maximum number for the duration of the sketch is 90 people, so if 40 people are dead, up to 50 others can be alive.  The sketch starts to slow down once there’s more and more computation via people objects.

The orange-yellow buttons toggle between the main universe-like view and another view, which contains system stats and karyogram-like views of each person’s traits.  The traits are displayed as circles, with their sizes representing the size of the traits.

I made some formulas (or evolutions, as I call them) for actual vs. potential well-being.  This computes someone’s traits as he is born with, and after they are adjusted for quality of the nation and his religion.  This is then divided by the maximum well-being one could have in the same religion and nation.  Thus you get a ratio of actual vs. potential.  The goal is to bring these numbers as close together as possible, to see if a society is running at full efficiency.

In my fairly generous, unscientific, unsystematic world, people are STILL running far below efficiency.  The best of human achievement is squandered daily, not just by peoples’ own personalities and time constraints, but by poor maximization policy and by inflexible religious traditions.

I also coded in a happiness evolution:

int happiness(int i) {
    int happiness = person[i].health + person[i].money + person[i].stress + person[i].creativity + person[i].religiosity +
    round(nation[person[i].nationality].standardOfLiving / 10) + round(nation[person[i].nationality].pollution / 10) +
    round(nation[person[i].nationality].security / 10) + round(nation[person[i].nationality].crime / 10) + person[i].employed * 10;
    return happiness;
}

This computes someone’s happiness based on personal health, stress levels, creativity, religiosity, and his nation’s standard of living, pollution levels, national security, crime levels, etc.  It also relies on whether someone is employed or not.  Obviously this evolution needs a ton of work and far more variables.

My "EUDAIMONIA" Tattoo

The happiness metric and the actual/potential well-being ratio are key metrics that I want to spend more time nailing down.  I think these metrics are chasing Aristotle’s concept of eudaimonia, which I also have tattooed on my arm.  There’s more to life than money.  There’s all these other variables.  It could be said we are happiest (in a bigger sense) when we feel we are running at our maximum potential and can contribute to the world.  We need to be able to measure this and push it down to the individual level, so people can make better choices towards bettering themselves, and up to government level, so policymakers can make better policy to maximize a nation’s human and social capital.

Download/View

The code is too long to post here, but here’s a direct .txt link to the source .pde (w/ combined classes).  You can go see the sketch running at OpenProcessing.org!  Only thing about that is that it will run in a reduced-size window.  You can try to view the Mac .app version or the Windows .exe version, too.

The code is also now at Github.

Difficulties and Lessons Learned

I used a Hashtable at first, to try it out, but I quickly ran into limitations I didn’t know how to get around.  I would use pretty length functions to recast strings as integers and vice versa, and so on.  Eventually I got so pissed that I rewrote a lot of the code and Person classes so that everything was saved as an integer and then I could look up its “name” in a table via a function.  So the nations are coded as 0-5 or whatever, with 1 equaling the UK, etc.  Much easier to manipulate.  It also meant I could use the ID integer with arrays.

My code got long and complex quickly, so I had to split everything up into classes, just for organization’s sake:  Death, DrawFuncs, Evolutions, GetFuncs, MatingDance, Nation, Person, Religion.   I don’t think at this level of sophistication, I could really build more objects into the sketch.  I wanted to practice inheritance and polymorphism stuff but it didn’t come up.  Any ideas for refactoring?

I really hated recasting strings and integers.

I want to spend more time coding on happiness and actuality vs. potentiality.  What I learned was that you have to build a really large system sandbox before you can begin to tackle those metrics.  This includes modeling and simulating an environment to such a degree that it can begin to calculate and visualize your concept of what happiness is, since it pulls from so many dimensions of one’s life. (not just money, but also charity, family life, employment, etc.)

Ways to Expand

Still want to use real-time data from Galapag.us, fed in from its database into Processing.  Too much to do right now though.  I’d have to redesign my database as well as fix the sketch variables!

The algorithms and equations need a lot of tweaking to be more realistic.  For Galapag.us, I’m hoping to crowdsource algorithms for the most accurate ways to calculate somewhat qualitative figures.

I wanted to be able to introduce outside shocks (natural disasters, etc.) into the system, to see how it would affect various nations and personality types, to see who would be more resilient.

I would like to give random people innate superpowers or traits that are unique or very rare.  So that maybe when they turn 30, something is unlocked within them.  I guess I could also give them random diseases and genetic predispositions.

Conclusion

This project helped me get pretty solid on classes and functions and how to organize a sketch.  If I were to rewrite this, it would be far cleaner and more compact.  Mostly I’m appreciative of how much work it takes just to get to a level where you can start doing interesting network effects on large systems.  I barely scratched the surface, in about 1,590 lines of code, but I did manage to achieve perhaps 90% of the infrastructure that I hoped to build.  All of this helps me build a better reputation and identity system for Galapag.us and for my thesis.  I’m hoping the more solid I get on the infrastructure, the bigger breakthroughs I will have on the algorithms and crowdsourcing enablers that will be at the heart of Galapag.us.


Viewing all articles
Browse latest Browse all 9

Trending Articles