Physion

  • Increase font size
  • Default font size
  • Decrease font size
Welcome, Guest
Username Password: Remember me

The Game Of Life
(1 viewing) (1) Guest
  • Page:
  • 1
  • 2

TOPIC: The Game Of Life

The Game Of Life 6 years, 2 months ago #413

  • Nait
  • OFFLINE
  • Senior Boarder
  • Posts: 60
This image is hidden for guests. Please log in or register to see it.

V0.1!

Hi people!
Now i gonna show you my new scene! (maybe the hardest, i ever made )
This The Game Of Life simulator. Yes that great Game Of Life
This is probe version, so field is small (10*10), and no tools - you have to set active/passive cell by yourself
To play the game you need to download this script, rename it into The GOL.script and then, execute it in Physion (Menu - Evalute script - select downloaded script).

Controls:
1. Click the cell, in the property menu look for "Name" property, it looks like "cords0x3"
2. To activate the cell type this code in console
activ(0, 8)

where 0 and 8 are coordinates of cell (look 1 point)
3. To passivate the cell type
passiv(0, 8)

4. Start simulation
5. ?????????
6. PROFIT!!!

As example, make new field (evalute the script again) and type this
activ(0,8); activ(1,8); activ(2,8); activ(2,9); activ(1,10);

Or, draw a figure from first image.
This will make a glider! Figure that moves

V0.1
Field 11*11 (against 10*10 )
Click cells to toggle their state! (thanks to Admin))
Attachments:
Last Edit: 6 years, 2 months ago by Nait.

Re: The Game Of Life 6 years, 2 months ago #416

  • Dimitris
  • OFFLINE
  • Administrator
  • Posts: 218
Well done Nait,

Although I don't know how to play the Game of Life it seems interesting.

If you want to activ() passiv() using the mouse, you can append the following piece of code in your GOL script:
var monitor = new QObject(app);  
monitor.eventFilter = function(object, event) {
 
if(event.type() == QEvent.GraphicsSceneMousePress)
{
var p = graphicsView.mapToScene(graphicsView.mapFromGlobal(QCursor.pos()));
 
var graphicsItem = graphicsView.scene().itemAt(p);
if(graphicsItem)
{
var physicsItem = world.physicsItemFromGraphicsItem(graphicsItem);
if(physicsItem)
{
if(physicsItem.Name.substring(0,5) == "cords")
{
var x = physicsItem.X;
var y = physicsItem.Y;
 
(physicsItem.Brush.color().name() == "#00ff00") ? passiv(x, y) : activ(x, y);
}
}
}
}
 
return false;
}
 
app.installEventFilter(monitor);


By the way, why do you have a .txt extension in your script?
Last Edit: 6 years, 2 months ago by Dimitris.

Re: The Game Of Life 6 years, 2 months ago #418

  • Nait
  • OFFLINE
  • Senior Boarder
  • Posts: 60
admin wrote:
Well cone Nait,

Although I don't know how to play the Game of Life it seems interesting.

Thanks))

GOL has very easy rules - the field of cells, every cell can be active (alive) or inactive (dead). Every cell has 8 neighbors. If cell is dead and has 2 alive neighbors, it will became alive in next generation. If not - it will stay dead. If cell is alive, it should have 2 or 3 alive neighbors to live, in other case it will die.

So, that's all)) Your aim is to make some different combinations and look what will they turn into!

For moar info you can look pediwikia ( ), there are some figures and links to sites and forums.

If you want to activ() passiv() using the mouse, you can append the following piece of code in your GOL script:


By the way, why do you have a .txt extension in your script?

I've renamed file, because forum doesn't support attaching script files

Re: The Game Of Life 6 years, 2 months ago #424

  • Dimitris
  • OFFLINE
  • Administrator
  • Posts: 218
I've renamed file, because forum doesn't support attaching script files

I didn't notice that! Now it's okay. You can upload .script files

Re: The Game Of Life 6 years, 2 months ago #425

  • Nait
  • OFFLINE
  • Senior Boarder
  • Posts: 60
Yeah, i've uploaded V0.1, in which i tried to enlarge field, but... my god! ...update() is so laggy... maybe you have some ideas?

Btw, here's one moar spaceship -
:pinch: Warning: Spoiler!

it will also travel through map, but in horizontal direction.
Attachments:
  • Attachment This image is hidden for guests. Please log in or register to see it.
Last Edit: 6 years, 2 months ago by Nait.

Re: The Game Of Life 6 years, 2 months ago #426

  • Dimitris
  • OFFLINE
  • Administrator
  • Posts: 218
The last one I downloaded (12x12 grid) is running smoothly on my computer.

The best thing to do when you're having such kind of problems is to perform benchmarks in various parts of your code and see which one is causing you troubles.

You can do something like that:
 
var t = new QTime();
t.start();
 
//
// The piece of code that may be causing troubles here
//
 
app.debug(t.elapsed()); // Number of msec that your code took to execute
 
  • Page:
  • 1
  • 2
Moderators: Glenn555
Time to create page: 0.18 seconds