Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/ep_merger_straight.py
diff options
context:
space:
mode:
Diffstat (limited to 'ep_merger_straight.py')
-rw-r--r--ep_merger_straight.py81
1 files changed, 81 insertions, 0 deletions
diff --git a/ep_merger_straight.py b/ep_merger_straight.py
new file mode 100644
index 0000000..77ee0e1
--- /dev/null
+++ b/ep_merger_straight.py
@@ -0,0 +1,81 @@
+# coding: UTF8
+# Copyright 2009 Thomas Jourdan
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+import model_allele
+
+class StraightMerger(model_allele.Allele):
+ """StraightMerger
+ """
+
+ def __init__(self, trunk):
+ """Constructor for a simple merger."""
+ super(StraightMerger, self).__init__(trunk)
+
+ def __eq__(self, other):
+ """Equality based on same instance."""
+ equal = isinstance(other, StraightMerger)
+ return equal
+
+ def randomize(self):
+ """No member variables. Nothing to do."""
+ pass
+
+ def mutate(self):
+ """No member variables. Nothing to do."""
+ pass
+
+ def shuffle(self):
+ """No member variables. Nothing to do."""
+ pass
+
+ def crossingover(self, other):
+ """
+ pre: isinstance(other, StraightMerger)
+ pre: isinstance(self, StraightMerger)
+ # check for distinct references, needs to copy content, not references
+ post: __return__ is not self
+ post: __return__ is not other
+ """
+ new_one = StraightMerger(self.get_trunk())
+ return new_one
+
+ def draw_single_layer(self, single_layer, mask_layer, ctx, width, height):
+ """
+ pre: single_layer is not None
+ pre: ctx is not None
+ pre: width > 0
+ pre: height > 0
+ pre: width == height
+ """
+ # paint one layer
+ ctx.save()
+ single_layer.draw(ctx, width, height)
+ ctx.restore()
+
+ def explain(self):
+ return 'Straight merger', \
+ None, \
+ None
+
+ def copy(self):
+ """A copy constructor.
+ post: isinstance(__return__, StraightMerger)
+ # check for distinct references, needs to copy content, not references
+ post: __return__ is not self
+ """
+ new_one = StraightMerger(self.get_trunk())
+ return new_one