Roses are red
Here’s something new
Clones know color
What’s next? Kung-Fú?
Apologies for the horrible intro. But it works. This code thing works. You can create a bunch of clones, and have a target clone’s data (variables and index) written to some global variables (variables created under the iPad section), meaning that for example, a collision-of-clones event (or any other) will compare the colliding clone to the target clone, creating seemingly impossible effects. To compare color, set a variable to the number of a color, then set the color to that variable. And boom. Please let me know if this has been already discovered, but right now I’m really hyped.
Thanks for reading!
A reply would be greatly appreciated…
Roses are red
I see what you did there
This is very smart great job
I’ve always wanted to do something like this for a Game Of Life cellular automata but fast in Hopscotch. I haven’t figured out how to do it though
I wish there was an easy way to call a clone at index x
Oooh, very interesting!
That’s quite hard to manipulate in Tynker too!
Edit: Now, come to think of it, Tynker might not have that certain ability. But even if there was, it would be a lot harder to code it in Tynker than Hopscotch.
That’s really cool! There will be many uses for this!
That is really interesting and it could be used in several types of projects. Great job!
The concept you’ve described has generally been call “advertising”. This is an advanced concept that sophisticated Hopscotch users utilize since there is no mechanism to directly reference traits of a specific clone. Whether or not it’s a new idea isn’t relevant. You have discovered this for yourself and that’s great!
I think you’ll find this to be very useful. Almost all of my big projects/games use this concept!
Now, the only problem with “advertising” is that only one clone can advertise it’s value at a time, since subsequent advertisements would overwrite the first. This means if you have 60 clones all advertising their values to each other, it would take 1 second (at 60 fps). 600 clones would take 10 seconds. So this limits the type of projects that can use the technique.
@JonnyGamer mentioned the Game of Life. This is a good example where many clones all need to reference the traits of other clones. Advertising can be used but the number of cells (clones) is limited or the lag becomes too great for each calculation.
Just recently, I realized that it is possible for all clones to simultaneously advertise a state value. This requires encoding the binary values of each clone into a global value. This is a simple binary to decimal conversion, where each clone can encode it’s value in 1 step. The first limitation is that only 53 binary values can be encoded into one 16 digit decimal value. The next problem is that decoding an individual value requires up to 53 steps. What I realized is that nested custom rules can be utilized to accomplish the 50+ decoding steps in 1 frame. Additionally, multiple global advertising values can be used to allow more than 53 clones (although this adds significant complexity).
Here is an example I have been working on to demonstrate the methodology (Warning: it’s very complicated) using the Game of Life. The example also demonstrates the downside. The game has close to 1000 cells, but each cell needs 50 nested custom rules to decode the advertised cell states. That means the project has over 50,000 When rules. Which in turn makes the fps very low. So even though the calculation occurs every frame, it still calculates slowly (but still faster than with any other method). If there were fewer cells it would calculate/evolve very quickly, but I wanted to demonstrate that it is possible to have almost 1000 cells & still have a reasonable calculation time.
How to tell another clones state?
This app is magnificent. It’s amazing how you figured it out
I was looking through the code and it’s definitely very complex. This code reminds me of the keyboard string saving code where the letters (and in this case cells) value are stored in one large number that describes what is being displayed
This is absolutely incredible
Great observation. You are absolutely correct! I use this “trick” a lot to extend the functionality of Hopscotch (i.e., to work around some of the limitations).
There are, however, 2 significant differences.
The “keyboard string saving code” encodes base 37 (26 letters, 10 numbers, and a “space”) as base 10. The Game of Life project encodes base 2 (binary 1s or 0s) as base 10. Simply speaking, base 10 are “normal numbers” that Hopscotch variables can save. The base 37 encoding can only encode 10 values (the encoded base 10 value has to be 16 digits or less). Whereas the base 2 encoding can save 53 values.
The “keyboard string saving code” just compares the encoded base 10 “word value” to known/coded values to determine what word was typed. The Game of Life code has to decode the saved base 10 value back to base 2, and it was to do that every frame for every clone (cell). <-- This is the super unique coding I’m demonstrating with the Game of Life. The algorithm to convert a base 10 (decimal) number to a binary number of N digits takes N iterations. Normally that would require N frames. Here there are 50 encoded binary values per global variable, so I’ve sped up the calculation so that instead of needing 50 frames, it only needs 1. That’s a nice “little” improvement
And it all starts with the concept of “advertising” that @XAMANION explained in the original post of this topic
Thank you! Yeah that’s what I was guessing it was. 2^(28*38) That’s super large. Wow! This really is impressive code!
I need to study how you checked when a cell has # of alive neighbors. That would seem to be the hardest part, but there must be some formula that you used to extract which cells were alive.
(It looks like this similar approach works with Coan’s minesweep game)
Then you can also save pixel art drawings (however adding color and more pixels would greatly increase the numbers being worked with.)