📜 ⬆️ ⬇️

Proposal for modifying the rules of the game Life

Good time to read, dear users of Habr! Game Life was proposed by John Conway in 1970, and was repeatedly discussed on habrahabr.ru. The main tags used are given in the labels for this article.


A number of changes are proposed that may lead to a new direction in development.


image


Proposition 1. In the original game, an infinite field is proposed, but in implementations the torus sweep rule is usually used - horizontals and verticals are closed in cycles.


A variant is proposed in which the horizontals of a rectangular field of finite size are closed into a cylinder, and the verticals are pairwise connected in steps of half the size of the field horizontally. Thus it is possible to obtain an analogue of the sphere that is easy to calculate


To simulate isotropy, it is proposed to use a triangular grid, which in the calculations is replaced by an estimate of the proximity of the horizontal, vertical, and one of the diagonals.


Horizontal layers can be used to change the environment:
one layer 20% high at the equator - with good living conditions (3-4 neighbors for conservation, 4 for nucleation)
two layers of 10% each - with poor living conditions (1-2 neighbors to save, 2 - for the origin of life)
for the rest of the usual rules apply (2-3 neighbors to save, 3 - for the birth of life)


Proposal 2. For organisms, it is proposed to add levels of complexity, possibilities for combining, genetic modification, and learning. Each organism is assigned up to 10 levels of complexity, each level is represented both in the material and in the abstract field.


The level of difficulty in the material area affects the maximum speed (the number of cells to which the body moves in one direction in one turn). Thus, organisms with the first level of complexity (array index 0) are fixed. The whole organism moves entirely.


The level of complexity in the abstract area affects the number of neighboring cells surveyed in a straight line. A viewing radius doubled compared with the ability to move is proposed: for the first level - 1, for the second level - 3, etc. Visibility is determined from the most extreme cells of the body.


The implementation of such games may be of interest to modern students studying big data processing and learning algorithms. Own implementation options at the moment there.


Genetic evolution of algorithms from a supreme algorithm is recommended.


Upd: a variant in a section of groups of complexity of tunnel modeling https://habrahabr.ru/post/259291/ :


in terms of natural systems


probabilistic inference (Bayes) - chaotic
genetic search (evolution) - fractal
optimization with constraints (analogies) - energy
reverse deduction (symbolists) - informational
gradient descent (connectionist) - static


then systems begin to show behavior, and the chain repeats at the level of the living:


probabilistic inference (Bayes) - dynamic (processes)
genetic search (evolution) - synergistic (market)
optimization with constraints (analogies) - corporate (childbirth)
reverse deduction (symbolists) - bureaucratic (regulations)
gradient descent (connectionist) - ecological


Literature: Pedro Domingos, High Algorithm. How machine learning will change our world.


References:
https://habr.com/en/post/435670/ - High Algorithm - Algorithm Distribution by Levels of Difficulty


Python option

Sources in Python:
life.py


import pygame import field import numpy as np running = True v = field.area() step=0 pygame.init() screen = pygame.display.set_mode([640, 550]) font = pygame.font.Font(None, 50) while running: screen.fill([0, 0, 0]) clr = 0 for r in range(1, v.height): for c in range(1, v.width): if v.val[r, c] != 0: clr=clr+64 if r % 2 == 0 and c % 2 == 0: if clr > 255: clr = 255 screen.set_at([r/2, c/2], [clr, clr, clr]) clr = 0 step_text = font.render(str(step),1, (255, 255, 0)) screen.blit(step_text, [10, 520]) pygame.display.flip() for event in pygame.event.get(): if event.type == pygame.QUIT: running = False v.generate() step=step+1 pygame.quit() print "Done" 

field.py


 import numpy as np import random class area: def __init__(self): self.width = 1000 self.height = 1000 self.debug = False self.val = np.zeros((self.height, self.width), dtype = int) self.val1 = np.zeros((self.height, self.width), dtype = int) self.val[250, 140] = 1 self.val[250, 141] = 1 self.val[251, 140] = 1 self.val[251, 141] = 1 self.val[252, 140] = 1 self.val[252, 141] = 1 self.rw = range(1, self.width-2) self.rh = range(1, self.height-2) self.r3 = range(-1, 2) self.dh = int(self.height/10) self.h1 = [self.dh*2, self.height-self.dh*2] self.h2 = [self.dh, self.height-self.dh] def generate(self): for cnt in self.r3: c = random.randint(0, self.width-1) r = random.randint(0, self.height-1) self.val[r, c] = 1 c = random.randint(0, self.width-1) r = random.randint(0, self.height-1) self.val[r, c] = 0 for c in self.rw: for r in self.rh: self.val1[r, c] = 0 cnt = 0 for r1 in self.r3: for c1 in self.r3: if not ((r1 == 0) and (c1 == 0)) and not (r1==-1 and c1==1) and not (r1==1 and c1==-1): if self.val[r+r1, c+c1] != 0: cnt = cnt + 1 self.val1[r, c] = self.store_value(c, cnt, self.val[r, c]) for r in self.rh: for c in self.rw: self.val[r, c] = self.val1[r, c] for c in self.rh: if self.val[c, self.width-2] == 1: self.val[0, c] = self.val[self.width-2, c] if self.val[1, c] == 1: self.val[self.width-1, c] = self.val[2, c] def store_value(self, c, cnt, cur): val = 0 if self.h1[0] < c < self.h1[1]: if 1 <= cnt <= 4: val = 1 if cur == 1 and cnt < 3: val = 1 else: if self.h2[0] < c < self.h2[1]: if 2 <= cnt <= 3: val = 1 if cur == 1 and 2 <= cnt <= 3: val = 1 else: if cnt == 2: val = 1 if cur == 1 and 1 <= cnt <= 2: val = 1 return val 

Result:
image


')

Source: https://habr.com/ru/post/316198/


All Articles