Tierra Tutorial

Download Report

Transcript Tierra Tutorial

Digital Universes
< Previous
BARAK NAVEH, www.cs.bgu.ac.il/~barnav
Next >
1
Evolution in Other Contexts
 Life on Earth is a product of evolution by
natural selection operating in the medium of
carbon chemistry.
 However, in theory, evolution is not limited
to Earth, nor to carbon chemistry.
 Just as it may occur on other planets, it
may also operate in other media, such as
the medium of digital computation.
2
Carbon-Based Organization
 The organization generated by evolution
spans about twelve orders of magnitude of scale.
 from the molecular to the ecosystem level.
3
Evolution in Organic Medium
 Organic life uses energy and
organizes matter.
 Evolution on Earth has
organized matter from the
molecular level up to the
ecosystem level.
4
Evolution in Digital Medium
 Can we use evolution to
develop such
organization?
 Can life use CPU-time to
organize memory?
 Can we use evolution to
synthesize digital life?
5
What is
Life ?
 No clear definition.
 We will regard to an object as alive if it is
 Self-replicating
 Capable of open-ended evolution
6
Tom Ray’s
Tierra Project
7
The Creatures
 Self-replicating machine code programs.
 Why machine code?
(most natural to the machine)
 Machine instructions remind us of amino
acids because they are “chemically active”.
(actively manipulate bits, bytes, CPU registers)
 The “genome” of a creature is the sequence
of its machine instructions.
8
The Environment – Tierra VM
 Why Virtual Machine?



Avoid the threat of evolving hostile code such as
viruses or worms.
Von Neumann type machine languages are
fragile, any mutation or recombination event is
almost certain to completely break program.
To make it especially hospitable to synthetic life.
 Tierra is a (simulated) parallel computer

with a processor for each creature.
9
Each CPU
 Contains
•
•
•
•
2 address registers + 2 numeric registers
Small Stack + Stack pointer
Instruction pointer
Flags register to indicate error conditions
 Performs fetch-decode-execute-inc(IP) cycle
 Has a simple instruction set for
• Arithmetics, bit manipulation
• Moving data between registers and RAM
• Control “instruction pointer” (IP)
 Computations are probabilistic
• Mutations occur at some low rate 
10
The Tierran Language
 32 instructions represented by five bits,
operands included.
 Numeric operands eliminated



Instruction set need not include all possible
integers.
CPU registers and stack are the only operands of
instructions.
Bit flipping and shifting is used to synthesize
numbers.
 Errors that cause instructions to fail make
them have no effect.
11
Template Addressing
 Numeric operands are normally used to
specify addresses, such as absolute or
relative addresses for jmp instruction.
 Numeric operands were eliminated
• (another method is needed)
 In Tierra, the jmp instruction uses a
template instead of an absolute or
relative address.
12
Template Addressing
 Templates are “borrowed” from
molecular biology.
 Molecules “address” one another by
having complementary shapes.
 Templates are complementary
patterns of zeros and ones.
 Templates are built from two kinds of
nop instructions: nop0 and nop1
13
Template Addressing
 The instruction sequence:
jmp nop0 nop0 nop1
 causes execution of the program to
jump to the nearest occurrence of the
instruction sequence:
nop1 nop1 nop0
 Why use complementarity?

so that the jmp will never jump to itself.
14
Instruction Set
nop_0 | nop_1
no operation (template markers)
or1
cx ^= 1
shl
cx <<= 1
zero
cx = 0
if_cz
if cx==0 execute next instruction
sub_ab | sub_ac
cx = ax – bx
inc_a | inc_b | inc_c
ax++
dec_c
cx--
push_ax
push ax on stack. (also bx cx dx versions)
pop_ax
pop top of stack into ax. (also bx cx dx versions)
jmp
move ip to template
jmpb
move ip backward to template
call
call a procedure
ret
return from a procedure
mov_cd
|
mov_ab
|
dx = cx
bx++
|
|
|
ax = ax - cx
cx++
bx = ax
mov_iab
move instruction at address in bx to address in ax
adr
address of nearest template to ax
adrb
search backward for template
adrf
search forward for template
mal
allocate memory for daughter cell
15
Memory Allocation




The Tierran computer operates on a block
of RAM of the real computer, referred to as
the “soup”.
The soup consisted of 60,000 bytes, which
can hold 60,000 Tierran machineinstructions.
Each “creature” occupies some area in the
soup.
Memory is circular.
16
The Soup
17
Cellularity

The cell membrane is defining its
limits and preserving its structural
integrity.

In digital organisms we need an
analog to cell membrane in order to
prevent them from demolishing one
another easily when they come into
contact
18
Cellularity (cont.)

Each Tierran creature has exclusive
write privileges within its own
memory

A creature may examine the code of
another creature, and even execute it,
but it can NOT overwrite it.
19
Cellularity and Division

Creature has write privileges to:



The memory block it is born with (mother cell).
The memory block it may allocate using mal
instruction (daughter cell), which may be used
to grow or to reproduce into.
Upon creature divide instruction:


The mother cell loses write privileges on
daughter cell’s.
The daughter cell is given its own CPU and
can allocate its own second memory block.
20
The Slicer



Time sharing approximates parallelism.
The number of instructions to be executed
in each slice may be set in proportion to
the size of the creature being executed,
raised to a “slicer-power”.
The power determines if selection favors
large or small creatures
•
•
•
power < 1: favors small
power = 1: size neutral
power < 1: favors large
21
Mortality - The Reaper
 At birth, processes enter the bottom of the
Reaper queue.
 When the memory is full, the Reaper kills
processes at the top of the queue.
 Memory allocated to the dead process is
reclaimed.
 The code of a dead process is NOT removed
from the soup.
22
The Reaper (cont.)
 When a process generates an error, it moves
one position up the Reaper queue.
 Successful execution of divide or mal
moves the process one position down.
 Overall effect:

Flown creatures rise to queue top and die.

Vigorous creatures have a greater longevity.

The probability of death increases with age.
23
Mutations
 Two kinds of mutations of machine
instructions:


a single bit of an instruction is flipped
random replacements - the affected instruction is
replaced by one of the 32 instructions in the set,
chosen at random
 Mutations occur when:

a process is born

code is copied from place to place

any time at random (cosmic ray)
24
Gene Splicing
 There are three classes of splicing:

Crossover

Insertion

Deletion
 Each class can occur in two ways:


Anywhere in the genome
Only at “segment boundaries”, marked by
templates
 Gene splicing is applied to a daughter
process at the time of birth
25
Flaws
 Flaws were originally conceived of as being
analogous to metabolic reactions gone
wrong, or producing side products
 Flaws are “intentional” errors in the
operations of the machine instructions
 Most flaws are errors of magnitude + or – 1
• Increment/decr may add/sub 2 or 0 instead of 1
• Instructions shifting or rotating bits in registers may shift
the bits one place too much or too little
26
Tierra System
 Self replicating individuals
 Genetic alterations
 Natural selection
 Co-evolution
Results
27
Ancestor 0080aaa
1111
find 0000 (start) -> bx
find 0001 (end) -> ax
calculate size
-> cx
1101
allocate daughter -> ax
call 0011 (copy procedure)
cell division
jump 0010
Self-examination
Reproduction Loop
1100
save registers to stack
1010
move [bx] -> [ax]
decrement cx
if cx == 0 jump 0100
increment ax & bx
jump 0101
1011
restore registers
return
1110
Copy Procedure
(coded by human)28
29
Ancestor 0080aaa
1111
find 0000 (start) -> bx
find 0001 (end) -> ax
calculate size
-> cx
1101
allocate daughter -> ax
call 0011 (copy procedure)
cell division
jump 0010
Self-examination
Reproduction Loop
1100
save registers to stack
1010
move [bx] -> [ax]
decrement cx
if cx == 0 jump 0100
increment ax & bx
jump 0101
1011
restore registers
return
1110
Copy Procedure
30
Mutant
1111
find 0000 (start) -> bx
find 0001 (end) -> ax
calculate size
-> cx
1101
allocate daughter -> ax
call 0011 (copy procedure)
cell division
jump 0010
Self-examination
Reproduction Loop
1110
save registers to stack
1010
move [bx] -> [ax]
decrement cx
if cx == 0 jump 0100
increment ax & bx
jump 0101
1011
restore registers
return
1110
Copy Procedure
31
Parasite 0045aaa
1111
find 0000 (start) -> bx
find 0001 (end) -> ax
calculate size
-> cx
1101
allocate daughter -> ax
call 0011 (copy procedure)
cell division
jump 0010
Self-examination
Reproduction Loop
1110
32
Ancestor 0080aaa
Parasite 0045aaa
Self-exam
Self-exam
1111
find 0000 (start) -> bx
find 0001 (end) -> ax
calculate size
-> cx
1111
find 0000 (start) -> bx
find 0001 (end) -> ax
calculate size
-> cx
Reproduction Loop
Reproduction Loop
1101
allocate daughter -> ax
call 0011 (copy procedure)
cell division
jump 0010
1100
1101
allocate daughter -> ax
call 0011 (copy procedure)
cell division
jump 0010
1110
Copy Procedure
save registers to stack
1010
move [bx] -> [ax]
decrement cx
if cx == 0 jump 0100
increment ax & bx
jump 0101
1011
restore registers
return
1110
33
34
35
36
37
38
Parasite 0045aaa
0080gai
Self-exam
Self-exam
1111
find 0000 (start) -> bx
find 0001 (end) -> ax
calculate size
-> cx
1111
find 0000 (start) -> bx
find 0001 (end) -> ax
calculate size
-> cx
Reproduction Loop
Reproduction Loop
1101
allocate daughter -> ax
call 0011 (copy procedure)
cell division
jump 0010
1110
allocate daughter -> ax
call 0011 (copy procedure)
cell division
jumpb 0000
1100
Copy Procedure
1010
move [bx] -> [ax]
decrement cx
if cx == 0 jumpb 1100
increment ax & bx
jumpb 0101
1110
Hyper Parasite!
39
40
1010
move [bx] -> [ax]
decrement cx
if cx == 0 jumpb 110
increment ax & bx
jumpb 0101
111
??
0061acg
Social
Hyper-parasite
110
find 001 (start) -> bx
find 000 (end) -> ax
calculate size
-> cx
allocate daughter -> ax
call 001 (copy procedure)
cell division
jumpb 010
Self-examination
Reproduction Loop
1100
Copy Procedure
1010
move [bx] -> [ax]
decrement cx
if cx == 0 jumpb 110
increment ax & bx
jumpb 0101
111
41
Other Results
 Immunity to parasites
 Circumvention of immunity to parasites
 Cheaters (e.g., 0027aab)

Abuse the cooperation of social hyper-parasites
 Novel forms of self examination
 Optimization


Size decrease
Loop unrolling
 Emergence of Ecology
42
More Info
www.isd.atr.co.jp/~ray/tierra/index.html
It’s life Jim, but not as we know it
(Dr. McCoy, Star Trek)
43
Related Works
 Network Tierra (T. Ray)

Connect many machines together to form a bigger “soup”.
 “Avida” (Adami, Brown, 94), similar idea but



On a grid (locality)
I/O and (limited) ability to train organisms to perform
functions
Active research
 “Amoeba” (Pargellis, 96), similar idea

Simpler instruction set

Spontaneous emergence of self-replicators
44
Related Works (cont.)
 “Physis” (A. Egri-Nagy, ‘03)

Evolves both: VM and programs

Encodes the computer together with the program
 “String Based Tierra” (K. Sigiura, ‘03)

Encodes programs into strings

Uses reg-expr rules to match-and-substitute (to compute)

Rules are strings as well

Evolve programs and their rules as a single individual
45
Open Challenges
 Why creature complexity has stopped
increasing?
 What’s limiting further development?
 Over 10 years have passed:

Memory space can support x10,000 bigger soup

CPUs can crunch x100 faster

In many cases “more is different” – is it here?
46
Demos of Other
Artificial-Life Works
Karl Sims
Demetri Terzopoulos
47
Evolving Virtual Creatures
Karl Sims ’94
Play
48
Evolving Artificial Fish
Demetri Terzopoulos ’94-’99
Evolving a Swimmer
Go Fish
Jack Cousto
49
Thank You
Good Luck
50
We will NOT try to do
 Computer viruses and worms
 Core Wars
 Evolutionary simulations with artificial
fitness and selection
 Pre-biotic conditions from which life may
emerge spontaneously
51