simulated-genetics/docs/codox/intro.html

66 lines
13 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html PUBLIC ""
"">
<html><head><meta charset="UTF-8" /><title>Introduction to simulated-genetics</title><link rel="stylesheet" type="text/css" href="css/default.css" /><link rel="stylesheet" type="text/css" href="css/highlight.css" /><script type="text/javascript" src="js/highlight.min.js"></script><script type="text/javascript" src="js/jquery.min.js"></script><script type="text/javascript" src="js/page_effects.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div id="header"><h2>Generated by <a href="https://github.com/weavejester/codox">Codox</a></h2><h1><a href="index.html"><span class="project-title"><span class="project-name">Simulated-genetics</span> <span class="project-version">0.1.0-SNAPSHOT</span></span></a></h1></div><div class="sidebar primary"><h3 class="no-link"><span class="inner">Project</span></h3><ul class="index-link"><li class="depth-1 "><a href="index.html"><div class="inner">Index</div></a></li></ul><h3 class="no-link"><span class="inner">Topics</span></h3><ul><li class="depth-1 current"><a href="intro.html"><div class="inner"><span>Introduction to simulated-genetics</span></div></a></li></ul><h3 class="no-link"><span class="inner">Namespaces</span></h3><ul><li class="depth-1"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>cc</span></div></div></li><li class="depth-2"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>journeyman</span></div></div></li><li class="depth-3"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>simulated-genetics</span></div></div></li><li class="depth-4 branch"><a href="cc.journeyman.simulated-genetics.genome.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>genome</span></div></a></li><li class="depth-4 branch"><a href="cc.journeyman.simulated-genetics.launcher.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>launcher</span></div></a></li><li class="depth-4 branch"><a href="cc.journeyman.simulated-genetics.makehuman-bridge.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>makehuman-bridge</span></div></a></li><li class="depth-4"><a href="cc.journeyman.simulated-genetics.utils.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>utils</span></div></a></li></ul></div><div class="document" id="content"><div class="doc"><div class="markdown"><h1><a href="#introduction-to-simulated-genetics" id="introduction-to-simulated-genetics"></a>Introduction to simulated-genetics</h1>
<h1><a href="#simulated-genetics" id="simulated-genetics"></a>simulated-genetics</h1>
<p>A clojure library (OK, at this moment its an app, but thats during development only) to generate character models for games, such that characters who are represented as related to one another will have systematically similar appearance, as creatures of natural species (including humans) do. This is specifically <strong>NOT</strong> simulating genetics on any deep or quasi-scientific level, just experimenting to see how adequate a solution can be achieved with simple code and limited data.</p>
<p>Part of <a href="https://simon-brooke.github.io/the-great-game/codox/index.html">The Great Game</a> project.</p>
<h2><a href="#status" id="status"></a>Status</h2>
<p>Very pre-alpha.</p>
<h2><a href="#concept" id="concept"></a>Concept</h2>
<p>If were going to have a world with a multi-generational population of hundreds of thousands of procedurally generated characters, and were to persuasively represent each character as being related to others, then we have to have a mechanism for making children look reasonably like their parents, to have family resemblances among cousins, and so on. We need to do this at reasonably low data storage and algorithmic cost, firstly because we have to store all these characters, and secondly because (especially when the player approaches an urban centre), we may need to instantiate models for a lot of them in limited time.</p>
<p>This note discusses how this might be done.</p>
<h3><a href="#the-pseudo-genome" id="the-pseudo-genome"></a>The pseudo-genome</h3>
<p>Suppose we have a binary vector of memory, such that when a child was born to two parents, bits were taken at random from the parents chromosomes to populate the childs genome which is sort of, very roughly, what happens in actual biology how big would that genome have to be? After all, the full data size of the human genetic code is enormous. But actually, we dont need to simulate anything like so large. After all, all our genome needs to encode is morphology, and only sufficiently to enable the player to recognise and distinguish characters.</p>
<p>My hunch is that a 64 bit genome is more than sufficient, if we code it carefully. So heres how such a genome might be structured:</p>
<table>
<thead>
<tr><th> Field </th><th> Bits </th><th> Interpretation </th></tr>
</thead>
<tbody>
<tr><td> Ethnic type </td><td> 4 </td><td> Ethnic type. Most significant bits both indicate dark skin, with <a href="??11">??11</a> indicating dark skin/curly hair and <a href="??01">??01</a> indicating dark skin/straight hair </td></tr>
<tr><td> Skin tone </td><td> 3 </td><td> Plus most significant bit from ethnic type (i.e. <a href="???1">???1</a>) as most significant bit. This means sixteen distinct tones, with the darkest tone of pale skinned ethnicities just very slightly lighter than the palest tone of dark skinned ethnicities. </td></tr>
<tr><td> Freckles? </td><td> 2 </td><td> <a href="11">11</a> means freckles, any other value means no freckles. Freckles wont be visible on very dark skin. </td></tr>
<tr><td> Hair colour </td><td> 3 </td><td> Plus most significant bit from ethnic type (i.e. <a href="???1">???1</a>) as most significant bit. Least significant bit does not contribute to tone but indicates red tint. Thus eight distinct degrees of darkness from pale blond to black, plus red tint which can affect any degree of darkness. </td></tr>
<tr><td> Eye colour </td><td> 2 </td><td> Plus most significant bit from ethnic type (i.e. <a href="???1">???1</a>) as most significant bit. Thus eight values: <a href="000">000</a> blue; <a href="001">001</a> hazel; <a href="010">010</a><a href="111">111</a> shades of brown lighter-&gt;darker. </td></tr>
<tr><td> Height </td><td> 3 </td><td> Height when adult; children will have a scaled proportion of their adult height, and the same height value in the genome will result in female body models 95% the height of an equivalent male body model. So <a href="000">000</a> codes for 150mm, <a href="111">111</a> codes for 200mm, with eight distinct values </td></tr>
<tr><td> Gracility/Robustness </td><td> 3 </td><td> Slenderness to stockiness of skeleton/armature build, with <a href="000">000</a> being very slender and <a href="111">111</a> being very broad/heavy. </td></tr>
<tr><td> Age-related change </td><td> 3 </td><td> People get white haired at different ages; some men go bald and some do not. The sons of the daughter of a bald man should have a chance of inheriting age-related baldness, although their mother wont express that gene. So Im allowing here for eight different profiles for age related change, although Im not yet clear what the exact values would mean. </td></tr>
</tbody>
</table>
<p>Thats twenty-nine of our sixty-four bits, leaving plenty for face models, gender and so on.</p>
<h3><a href="#whats-not-included-in-the-genome" id="whats-not-included-in-the-genome"></a>Whats not included in the genome</h3>
<p>Things which are cultural are not included in the genome; things which are lifestyle related are not included in the genome. So, for example, gracility/robustness, is not the same as skinniness/fatness, which are mostly lifestyle/diet related rather than genetic. There are some occupations (e.g., blacksmith) where youd be unlikely to be fat (but might be very robust). Also, the same character might grow fatter (or thinner) over time.</p>
<p>Similarly, hairstyle and beard-wearing are cultural (and occupational) rather than genetic, and closely related to choice of clothing. So while we do need to represent these things, theyre not things which should be represented in the genome.</p>
<p>Injury-related change which would especially affect soldiers and outlaws especially but could affect any character also needs to be encoded somehow (and may cause real problems), but this is also not a problem for the genome.</p>
<h3><a href="#what-additionally-might-be-included-in-the-pseudo-genome" id="what-additionally-might-be-included-in-the-pseudo-genome"></a>What additionally might be included in the pseudo-genome</h3>
<p>There is a variable Im proposing for non-player characters that Im calling <code>disposition</code>, which has a range of values between -5 (surly) and +5 (sunny), which stands in for the general friendliness of the character towards random strangers, their generosity, their optimism, their degree of compassion, and so on. I dont personally believe these things are genetic I believe theyre nurture, not nature but I believe that they are nevertheless inherited through families to some extent.</p>
<p>If we made a characters setting for <code>disposition</code> a function of their parents dispositions, then that would need to be an entirely unrelated value from the physical appearance values, because otherwise you would end up having some racial appearances being friendlier and more optimistic than others, which would lead to accusations of racism and other bad things. This is simulated genetics, not simulated phrenology!</p>
<p>I mean, you may be planning the sort of game in which there are races like orcs or kobolds or whatever which are systematically less friendly and generous than characters of other races, in which case you might want to fork this library and change this decision, but if so:</p>
<p>a. thats on you; and b. I politely suggest that you might want to examine your own attitudes.</p>
<h3><a href="#making-this-all-work" id="making-this-all-work"></a>Making this all work</h3>
<p><strong>NOTE:</strong> At this stage none of this works.</p>
<h4><a href="#the-python-ecosystem" id="the-python-ecosystem"></a>The Python ecosystem</h4>
<p><a href="http://www.makehumancommunity.org/">MakeHuman</a> exposes an <a href="https://github.com/makehumancommunity/community-plugins-mhapi/blob/master/docs/MHAPI.md">API</a> which allows at least many of the morphological changes required by the pseudo-genome to be applied to a human model.</p>
<p>Theres a well regarded library, <a href="https://www.futurile.net/2020/02/20/python-from-clojure-with-libpython-clj/">libpython-clj</a>, which allows calling of Python code from Clojure code. So in theory it should be possible to make this work.</p>
<p>If not, there are other human-model-morphing libraries out there, e.g. <a href="https://mb-lab-community.github.io/MB-Lab.github.io/">ManuelBastioniLab</a>, but theyre mainly also in Python. In the worst case, the heavy lifting is in the data, and it might be possible to rewrite the code thatmorphs the data into Clojure. However, development of ManuelBastioniLAB <a href="https://www.cgchannel.com/2018/11/manuel-bastioni-to-discontinue-manuel-bastioni-lab/">ceased in 2018</a>, and although there are forks available on GitHub and elsewhere, none of them seem to be active.</p>
<h4><a href="#maud" id="maud"></a>Maud</h4>
<p>While things in the Python ecosystem are very polished, getting them to play nicely with Clojure/Java is non-trivial. Theres a less-polished but apparently-functional character editor built using jMonkeyEngine frameworks called <a href="https://github.com/stephengold/Maud">Maud</a>. This might be an easier fit.</p>
<h2><a href="#installation" id="installation"></a>Installation</h2>
<p>You cant, it doesnt (yet) work.</p>
<h2><a href="#usage" id="usage"></a>Usage</h2>
<p>FIXME: explanation</p>
<pre><code>$ java -jar simulated-genetics-0.1.0-standalone.jar [args]
</code></pre>
<h2><a href="#options" id="options"></a>Options</h2>
<p>FIXME: listing of options this app accepts.</p>
<h2><a href="#examples" id="examples"></a>Examples</h2>
<p></p>
<h3><a href="#bugs" id="bugs"></a>Bugs</h3>
<p></p>
<h3><a href="#any-other-sections" id="any-other-sections"></a>Any Other Sections</h3>
<h3><a href="#that-you-think" id="that-you-think"></a>That You Think</h3>
<h3><a href="#might-be-useful" id="might-be-useful"></a>Might be Useful</h3>
<h2><a href="#license" id="license"></a>License</h2>
<p>Copyright © 2024 Simon Brooke</p>
<p>This Source Code is made available under the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version, with the GNU Classpath Exception which is available at <a href="https://www.gnu.org/software/classpath/license.html">https://www.gnu.org/software/classpath/license.html</a>.</p>
</div></div></div></body></html>