regart Posted November 7, 2021 Share Posted November 7, 2021 Hi there, I'm quite new to vex and try to build a simple loop to implement the set of rules of the "game of life" by Conway. The code seems to work for the first iteration, but then stops working as I would expect. In my example I use a grid with 5 points to be having a attrib value of 1, which is called i@life the others are set to 0. This goes into a point wrangle: int count = chi("count"); int life = i@life; int adj[] = array(); int alive = 0; adj = nearpoints(0, @P, 10, 9); removeindex(adj, 0); i[]@adj = adj; for(int i = 0; i < count; i++){ alive = 0; for(int p = 0; p < len(adj); p++){ int iter = adj[p]; alive += point(0, "life", iter); } if(life == 1){ if(alive < 2 || alive == 8) life = 0; } else if(alive == 3) life = 1; i@life = life; } I would very much apprecciate any help on that! vex_gameOfLife.hiplc Quote Link to comment Share on other sites More sharing options...
flcc Posted November 8, 2021 Share Posted November 8, 2021 (edited) You need to use a solver sop. Houdini don't keep "global" variables overtime. It's why you need a solver. I've put your wrangle in a solver and it's do something but more like an infection. Don't know if it's the behavior you expect. I've also give it a try some time ago, the file is attached. Not perfect and stop working at frame 55. No idea why. A very good explanation of the solver sop here. https://www.tokeru.com/cgwiki/index.php?title=The_solver_sop If you're new to houdini this site is a must see. It as also a simple game of life example. https://www.tokeru.com/cgwiki/index.php?title=HoudiniVex#Solver_sop_and_wrangles_for_simulation vex_gameOfLife + solver.hiplc GameOfLife_F.hiplc Edited November 8, 2021 by flcc Quote Link to comment Share on other sites More sharing options...
regart Posted November 8, 2021 Author Share Posted November 8, 2021 (edited) Thank you Fred! within a sop solver it works fine! I don't get though, why it wouldn't work without it just with the loop. And thank you for the links, they are very useful! Edited November 8, 2021 by regart Quote Link to comment Share on other sites More sharing options...
mestela Posted November 8, 2021 Share Posted November 8, 2021 Read the first bit on that solver sop page, it explains it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.