Artificial Life gadget using Python

This forum is currently in read-only mode.
From the Asset Store
High quality sound effect pack, in the following categories: computer voice
  • Hey all, im now experimenting with Alife game. Im trying to make my "Cell's" reproduce and mutate wich is represented by colour filter changed by random number.

    This is roughtly what i want to achieve:

    If Cell has enough eneregy
    get Cell colour
    Spawn new cell
    set new cell colour to parent cell colour +random[/code:2g5y6fog]
    The script i made so far goes like that:
    [code:2g5y6fog]import random
    but when it is executed it generates error :
    [code:2g5y6fog]File 'string' line 1061(??)
    def swap values (self,p0,p1,p2,p3)
    syntax error invalid syntax
    I dont understand why it showing me that because  I didnt typed that nowhere.
    What i'm doing wrong ?
  • I can't reproduce your error so if you post your cap me and others can try to solve it.

    The only thing I noticed is that you use

    a.Filter = ...[/code:bn3vdkc7]
    by trials and error (and I read about it on the forum) you should use .SetXXXXX to set any value
    Trying to of any help I created a simple cap that creates a 20x20 grid of TiledBackground and then modify the Filter of each one by a random value.
    That's my code:
    -> Start of layout -> script:
    for x in range(20):
    	for y in range(20):
    		System.Create("Cell", 1, x*25, y*25)
    -> Always -> script:
    from random import randint
    def cb(x):
    	if x < 0:
    		return 0;
    	if x > 255:
    		x = 255
    	return x
    for i in range(Cell.Count):
    	cell = Cell[i]
    	color = cell.Filter
    	r = cb(System.getred(color) + randint(-5,5))
    	g = cb(System.getgreen(color) + randint(-5,5))
    	b = cb(System.getblue(color) + randint(-5,5))
    May be this will help you.
  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • [quote:11964ur1]File 'string' line 1061(??)

    def swap values (self,p0,p1,p2,p3)

    syntax error invalid syntax

    If you remove the S plug-in from your project it will eliminate that error.

    Some other fixes:





    Add this event to initialize python at the start of layout:

    + System: Start of layout

    -> System: Run Script ("")

    Construct will crash if python isn't initialized and ~700 objects are created.

    Hope that helps.

  • Thanks Rojo, it helped alot.

    Another problem came out :

    It seems that only one cell at a time can reproduce.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)