dat.py

Created by pikube

Created on October 26, 2019

1.34 KB

Automate cellulaire dans lequel chaque cellule a une teinte de bleu allant de 0 à 25. Essayez pixel(). Pour modifier la fonction qui à chaque cellule associe une teinte à partir de la somme des teintes des 8 cellules environnantes, choisissez une autre fonction dans la ligne ““def function()””. La fonction DEVRA ABSOLUMENT être définie sur [0, 8*25] et le maximum sera 25, le minimum 0.


from math import *
import kandinsky as kan
import random
import cmath

#here is a stupid thing i made
csize=20
global slist
slist=[]

def col(x,y):
  return kan.get_pixel(x,y)[2]

def drw(x,y,col):
  for cx in range(csize):
    for cy in range(csize):
      kan.set_pixel(x+cx,y+cy,kan.color(0,0,col))

def function(x):
  return(int(x/8))
  #int((sin(x-(cmath.pi))+1)*(27/2)) 
  #int((sqrt(x)/sqrt(27*8))*(27))
  #int((((x-108)-abs(x-108)))/(2)+108)

def neighbour(x,y):
  s=0
  s+=col(x-csize,y-csize)
  s+=col(x-csize,y)
  s+=col(x-csize,y+csize)
  s+=col(x,y-csize)
  s+=col(x,y+csize)
  s+=col(x+csize,y-csize)
  s+=col(x+csize,y)
  s+=col(x+csize,y+csize)
  return s
def init():
  for y in range(200/csize):
    slist.append([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])
    
def computep():
  for cy in range(200/csize):
    for cx in range(320/csize):
      slist[cy][cx]=function(neighbour(cx*csize,cy*csize))

def showp():
  for x in range(320/csize):
    for y in range(200/csize):
      ccol=slist[y][x]
      drw(x*csize,y*csize,ccol)
      
def pixel():
  #inizialing main loop
  for x in range(320/csize):
    for y in range(200/csize):
      drw(x*csize,y*csize,random.randint(0,255))
  for x in range(320):
    kan.set_pixel(x,200,kan.color(0,0,0))
  init()
  gen=0
  while 1:
    computep()
    kan.draw_string("gen:%s"%gen,130,201)
    showp()
    gen+=1

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.