GMLscripts.com

Discuss and collaborate on GML scripts

You are not logged in.

#81 2012-04-24 04:30:38

xot
Registered: 2007-08-18
Posts: 1,201

Re: CHALLENGE: Conway's Game of Life

Here's the simple version of the effect using the entire CA state for its input.

The effect is produced in the second code action of the step event.

You can experiment with different settings using the mouse. Left click on the screen to change the "fade" color (x-axis) and "add" color (y-axis). The effect is cleared each time the colors are set, so be sure to release the button to see the effect properly. Default coloring can be restored by pressing "D", and the effect surface can be cleared by pressing "C".

It's pretty finicky and small changes to the colors display drastic differences. More control would be possible with a more refined effect using more selective inputs. If you want to experiment, I think the "temp" surface contains only the "heads" at the end of the CA sequence. They are very dim and will need to be brightened to be useful.

There is a helper script to perform the fade, surface_fade(), which I've used for readability.

I've also added a very simple surface management system so that surfaces are recycled rather than repeatedly created and freed each step. It improves both speed and stability, but it is not very smart. It expects all surfaces to have the same dimensions, which they do in this case. The scripts are surface_request() and surface_release().

Abusing forum power since 1986.

Offline

#82 2012-04-24 16:14:34

icuurd12b42
Member
Registered: 2008-12-11
Posts: 303

Re: CHALLENGE: Conway's Game of Life

Thanks!!!
It's soo close to what I was thinking except for the tracks removal.

So I tried to remove the tracks by using another surface (notracks). I transfer the surf to it, then subtract the color of the track ($606060 or is it$010101) and use the notracks in the transfer where surf was originally used. I was thinking the only thing left on notracks would be the electron and it's trail, though faded.

However, the whole effect goes transparent, even if I draw black in the subtract, which, in theory, should not have done anything to the notracks surface... confused.

// Fancy Tron-like effect icuurd12b42 wants
{

surface_set_target(notracks);
draw_surface(surf,0,0)
//trouble here
//draw_set_blend_mode(bm_subtract);
//draw_rectangle_color(0,0,room_width,room_height,0,0,0,0,0);//$606060,$606060,$606060,$606060,0);

surface_set_target(effect);

// add the CA state to the surface
draw_set_blend_mode_ext(bm_one,bm_one);
// clean up
draw_set_blend_mode(bm_normal);
surface_reset_target();
}

Last edited by icuurd12b42 (2012-04-24 16:26:05)

Offline

#83 2012-04-24 16:51:19

xot
Registered: 2007-08-18
Posts: 1,201

Re: CHALLENGE: Conway's Game of Life

The reason it goes transparent is because the alpha is being subtracted as well. If you draw the rectangle with zero alpha, it will affect the RGB colors but leave the alpha alone. You still might not get what you want because of the way bm_subtract works. It would multiply each color channel by (1 - ($60/$ff)) which wouldn't remove the track completely. I suggest using the surface_fade() script instead, eg. surface_fade(notracks,$606060). That script performs a true subtraction and will make the surface darker by exactly$606060, or whatever color you provide it.

Abusing forum power since 1986.

Offline

#84 2012-04-24 17:32:08

icuurd12b42
Member
Registered: 2008-12-11
Posts: 303

Re: CHALLENGE: Conway's Game of Life

it's still drawing transparent. even passing 0 in surface_fade

I found an error in the surface fade script where effect was hard coded. and I also added surface_reset in the clean up

//  surface_fade(surface,color)
//      performs true color subtaction from surface
{
var width,height;
width = surface_get_width(argument0);
height = surface_get_height(argument0);
surface_set_target(argument0);
//  invert the surface
draw_set_blend_mode_ext(bm_inv_dest_color,bm_inv_src_color);
draw_rectangle_color(0,0,width,height,c_white,c_white,c_white,c_white,false);
draw_set_blend_mode_ext(bm_one,bm_one);
draw_rectangle_color(0,0,width,height,argument1,argument1,argument1,argument1,false);
//  re-invert the surface
draw_set_blend_mode_ext(bm_inv_dest_color,bm_inv_src_color);
draw_rectangle_color(0,0,width,height,c_white,c_white,c_white,c_white,false);
//  clean up
draw_set_blend_mode(bm_normal);
surface_reset_target();
return 0;
}

    notracks = surface_request(w,h);
surface_set_target(notracks);
draw_clear(c_black);
surface_reset_target();

and the step, setup to work like the original, until I add the fade on notracks

// Fancy Tron-like effect icuurd12b42 wants
{

surface_set_target(notracks);
//draw_set_blend_mode_ext(bm_one,bm_one);
draw_surface(surf,0,0)
//surface_fade(notracks,$010101,0); // add the CA state to the surface surface_set_target(effect); draw_set_blend_mode_ext(bm_one,bm_one); //draw_surface_ext(surf,0,0,1,1,0,colorAdd,1); draw_surface_ext(notracks,0,0,1,1,0,colorAdd,1); //draw_set_blend_mode(bm_normal); //draw_surface(notracks,0,0) //draw_surface_ext(notracks,0,0,1,1,0,colorAdd,1); // clean up //draw_set_blend_mode(bm_normal); surface_reset_target(); } it makes a whitewash on the screen... ~tilt~ Offline #87 2012-04-25 03:20:34 xot Administrator Registered: 2007-08-18 Posts: 1,201 Re: CHALLENGE: Conway's Game of Life You probably already figured it out, but the problem is you need to reset the blending mode back to bm_normal at the end. Uncomment the second to last line. You'll also want to adjust "colorFade" and "colorAdd" as well. Colors $070707 and \$A7A7A7, respectively, look nice.

Abusing forum power since 1986.

Offline

#88 2012-04-25 03:27:52

icuurd12b42
Member
Registered: 2008-12-11
Posts: 303

Re: CHALLENGE: Conway's Game of Life

WTH... How did that... I'm an idiot.  THANK YOU SO MUCH

Offline

#89 2012-05-07 11:21:45

xot
Registered: 2007-08-18
Posts: 1,201

Re: CHALLENGE: Conway's Game of Life

There is an interesting article in the latest issue of Game Developer Magazine about utilizing CA for zombie AI. It is meant to model both infection and pursuit of the uninfected using flocking behavior. Unfortunately, the article is technically (and vitally) flawed because of careless editing. With some Google sleuthing I found the original paper the article entirely based upon. The main differences are merely grammatical:

http://www.scs-europe.net/conf/ecms2011 … S_0044.pdf

I'm not sure this CA can be adapted to blend operations because it uses random cell selection. Similar behavior might be efficiently accomplished using a carefully designed set of randomly selected and tiled pixel masks. Additionally (and unusually) the algorithm does not apply its rules in parallel, which is the primary reason to use the GPU in the first place. It is not made entirely clear why random cell selection and asynchronous rule application are necessary. I think the issue is that the population needs to remain constant and individual cells need to be perceived as moving from point to point. The state changing rules may be a bit too complex to be handled by simple image processing.

Nevertheless, the AI sounds pretty cool and it is claimed to be fairly efficient and intelligent-looking. I haven't yet implemented the AI in any form because of the flaws introduced by the GDmag article. They broke the algorithm by splitting final step into two and incorrectly branching to the second half of it instead of simply ending the iteration. Since the original paper is not referenced in the article, I expect many people will never succeed in reproducing the AI.

Abusing forum power since 1986.

Offline

#90 2012-05-08 01:08:54

icuurd12b42
Member
Registered: 2008-12-11
Posts: 303

Re: CHALLENGE: Conway's Game of Life

I just love it when I have an idea and some smart guy already did the work

Offline

#91 2012-05-12 11:54:48

xot
Registered: 2007-08-18
Posts: 1,201

Re: CHALLENGE: Conway's Game of Life

Here's a fascinating video about the late, great Martin Gardner. As I noted earlier in this topic, Gardner is the man responsible for popularizing cellular automata through the pages of his "Mathematical Recreations" column in Scientific American. This episode of "The Nature of Things" with David Suzuki features interviews with many people who have crossed paths with Gardner as well as the man himself. Among the interviewees are John Conway, the inventor of The Game of Life, and Bill Gosper, the creator of the first "glider gun".

The breadth of Martin Gardner's influence is astonishing and encompasses mathematics, magic, games, puzzles, art, philosophy, and beyond. His writings have shaped my mind and guided long-term interests in inestimable ways.

Abusing forum power since 1986.

Offline

#92 2012-05-12 12:04:17

xot
Registered: 2007-08-18
Posts: 1,201

Re: CHALLENGE: Conway's Game of Life

I also just came across this lecture by Stephen Wolfram who is at the very forefront of cellular automata research and is the man behind Mathematica and Wolfram Alpha. The lecture covers the concepts he develops in his massive book A New Kind of Science. The thrust of his conjecture is that cellular automation can be applied as practical models of the natural world in every imaginable way across every scientific discipline. The book is a remarkable read, if occasionally marred by a possibly inflated sense of profundity and a general lack of citations to the earlier work of other researchers. By my estimation, it is a truly profound work, but his writing has certainly bristled other commentators. It's a lengthy lecture but well worth your time if you find this stuff interesting. Very inexpensive used copies of the book are abundant and even new copies are now fairly cheap.

Abusing forum power since 1986.

Offline

#93 2012-05-13 13:35:59

icuurd12b42
Member
Registered: 2008-12-11
Posts: 303

Good ones.

Offline

#94 2012-09-08 17:44:58

xot
Registered: 2007-08-18
Posts: 1,201

Re: CHALLENGE: Conway's Game of Life

This is pretty neat. Nate Yourchuck has made a game of the Game of Life. It's short puzzle game that plays out in the form of a flower garden with generational population goals achieved through the planting of seeds. It should run in any HTML5 browser. Check it out.

http://nimblegorilla.com/ultimate_plant/

Abusing forum power since 1986.

Offline

#95 2012-10-10 15:24:13

xot
Registered: 2007-08-18
Posts: 1,201

Re: CHALLENGE: Conway's Game of Life

Ooooo, been wondering about this sort of thing for a while. It's a CA variant with continuous states called "SmoothLife" discovered by Stephan Rafler. It resembles reaction diffusion but with some extra birth/survival rules tacked on that mimic Conway's Life. It's pretty rad. This video shows a rule set call SmoothLifeL. I'll quote the video description from YouTube below.

SmoothLife is a family of rules created by Stephan Rafler. It was designed as a continuous version of Conway's Game of Life - using floating point values instead of integers. This rule is SmoothLifeL which supports many interesting phenomena such as gliders that can travel in any direction, rotating pairs of gliders, wickstretchers and the appearance of elastic tension in the 'cords' that join the blobs.

http://sourceforge.net/projects/smoothlife/

Slides showing how the rule works:

Paper describing SmoothLife and SmoothLifeL: http://arxiv.org/abs/1111.1567

More videos:

Details:
Birth range: 0.257 - 0.336
Survival range: 0.365 - 0.549
Alpha_n (outer sigmoid width): 0.028
Alpha_m (inner sigmoid width): 0.147
Timestep: 0.05 (Euler integration)
Frames: 10819 (saving 1 image per 8 timesteps)
Total time units elapsed: 4327.6
World size: 512x512, with toroidal wrap-around.
Color representation: linear mapping of [0,1] onto [black,white]
OpenCL source code: http://reaction-diffusion.googlecode.co … moothlife_...
Computation time: 74 minutes on an nVidia GeForce GTX 460

Computation time seems a bit excessive, but we are dealing with pretty huge neighborhoods and 8 time steps per frame.

Abusing forum power since 1986.

Offline

#96 2012-10-12 19:03:41

icuurd12b42
Member
Registered: 2008-12-11
Posts: 303

That is freaky

Offline

#97 2012-10-20 14:17:20

xot
Registered: 2007-08-18
Posts: 1,201

Re: CHALLENGE: Conway's Game of Life

It may not be Minecraft in Minecraft, but it is Life in Life. In Wolfram's book he describes and demonstrates a universal CA computer of one dimension built using CA. Brice Due has taking things into the next dimension with a Life-based computer that can play Life.

Quoting from the original story where I found this:

Harry Fairhead @ I Programmer wrote:

Some years ago, around 2006, Brice Due created a metapixel - a unit cell that can be customized to behave like any cell in a Life like cellular automata. The metapixel needs 2048x2048 Life cells and yes it is that big. The metapixel has two states just like a basic Life cell that corresponds to the majority of the cells in the middle being on or off. It takes an amazing 35,328 generations to go from on to off. The rule that the cell implements is encoded into two columns of nine "eaters" which correspond to survival and birth rules.

Like Harry Fairhead says in his I Programmer post linked above, I don't know how this one slipped by unnoticed for so long.

Check out this video Phillip Bradbury recently posted of a "powers-of-ten" style zoom out the CA in action. It's pretty meta. Warning: loud and annoying audio

!

It should be possible to program any two-dimensional, two-state, Moore neighborhood CA with the OTCAmetapixel. I don't know why would you want to, but how you get your jollies is none of my business.

Some information about it and acknowledgements can be found on the discoverer's site here:
http://otcametapixel.blogspot.com/

More information and a link to the Golly pattern can be found on the LifeWiki site here:
http://www.conwaylife.com/wiki/OTCA_metapixel

!

Abusing forum power since 1986.

Offline

#98 2012-10-23 18:53:05

xot
Registered: 2007-08-18
Posts: 1,201

Re: CHALLENGE: Conway's Game of Life

Christer Kaitila just tweeted about an article that describes using CA to construct cave-like levels for a game. The rule sets are similar to the Vote CA I posted about last year, which I also suggested could be used for cave generation. These rule sets are more of a median filter and not especially dynamic. The author uses a combination of iteration and scaling get the caves to a useful resolution.

The Cellular Automaton Method for Cave Generation
http://jeremykun.wordpress.com/2012/07/ … eneration/

The article includes an interactive Javascript demonstration that is good for a look. Too bad you can't adjust the rules without diving into the code.

Abusing forum power since 1986.

Offline

#99 2012-11-27 18:42:02

joeben123
Member
From: Raleigh NC
Registered: 2012-11-27
Posts: 1

Re: CHALLENGE: Conway's Game of Life

Hey, this is my first post on the forums . So I was looking at a video someone had made explaining how to use Conway's Game of Life for logic gates, and I decided to try making an emulator for it in Gamemaker. I ran into a problem involving the edges of the grid and so I posted in the Q&A section of the GMC forum. icuurd12b42 happened to find my post and solved my problem for me. He also gave me the link to this thread. I found the thread and the entire website intriguing so now I have registered . You can check out my CA herehttps://dl.dropbox.com/u/69395067/LIFE/index.html (html5 browsers only). You have to hit enter when it opens because of a bug that I am to lazy to fix. After that left click turns on cells, and right turns them off. Holding down enter will continuously update the cells and hitting space will reset the grid. It run's perfectly at any speed I set it to, but then again I have a beast of a PC. So thanks for pointing me here icuurd12b42 (Is 12b42 a reference of some sort of just random numbers? ) and a question for you xot. I see that this is the latest challenge and I already know I will thoroughly enjoy the other two, but are you planning to continue with these challenges? They seem like a great way for people to exercise their GML.

Offline

#100 2013-01-18 07:16:15

xot
Registered: 2007-08-18
Posts: 1,201

Re: CHALLENGE: Conway's Game of Life

Hi Joe, welcome to the forums! Sorry for not welcoming you sooner. My internet availability has been spotty for a few months.

I'd like to do more challenges, but I've been distracted with other things and haven't been able to devote as much time to the forums and GameMaker as I'd like. So far all of the challenges I've posted started from things I was working on already. Not using GameMaker has limited my inspiration.

For a while, paul23 was posting challenge topics on the GMC forums. It would be great if they could make a return there. They can get a lot more exposure than here, and there was a lot of interest in them continuing.

Abusing forum power since 1986.

Offline