Code DELETING WRONG List

Here is my big chunk of code:

Basically, global solutionMoleculeColor is = (1,1,2,2,3,3 / some random variation with 2 of each number). I am stamping each number of solutionMoleculeColor, and so I do that by deleting the part I already stamped. But I need to access solutionMoleculeColor later on.

So to solve that, I set a temporary variable that is = solutionMoleculeColor, and I will delete the parts I stamped on the temporary variable so I can use solutionMoleculeColor later on. My problem is that it is still deleting solutionMoleculeColor and I have no idea why. I tried various other workarounds but it's like my project is cursed to always delete solutionMoleculeColor

Hopefully this makes sense. I'll insert the whole project download just in case.

TLDR: code is deleting wrong list
Eureka.aia (22.0 KB)

AI2 lists are linked lists, not arrays.

So when you remove an item from a list, all the other items move down to fill the hole.

So if you want to deplete a list as you consume its items, all you ever need is item 1. After you remove item 1, the old items will move down to give you a new item 1.

By the way, I am leery of the idea of using numbers 1,2,3 as dictionary keys. It is worth checking if it will act like a list of lists, if you try removing say item 2 and hope to still find an item 3 of your original 3 items.

(I tested this.)


My fears were unfounded.
I might have been thinking of CloudDB or Firebase.

P.S. I tried the game.
Once I figured out I was supposed to duplicate the top image it worked okay for me.

1 Like

I have no idea what the difference between a linked list / array list (I tried using Bing AI to help me summarize it, it kinda helped).

But anyways, I do remove #1 of the list, except its removing it from multiple lists even though I'm not telling it to.

To be safe, use the COPY LIST block when setting one list to another list, otherwise your operations on one list will affect the other list.

This list experiment will expose the inner secrets of AI2 lists:

That seemed to work! I didn't know that that could be causing that.

Thank you so much!

Glad you got it working.

Your code exceeded my personal complexity limit.

Sometimes you can simplify code by generalizing it to n cases, in this case n towers and m ball height limit.

Do you have a link to the original game's description?

Quick question: What is an n case?

Here is a brief description of the game: Dr. Eureka Board Game | BoardGames.com | Your source for everything to do with Board Games

Basically you mix molecules in test tubes

Mathematicians often use the letter n to denote an unknown whole number.

How would the code look for the case where you did not know ahead of time how many columns were involved, say 7 columns?

Taking that approach drives the design towards using more lists, rather than enumerating the columns and their combinations 1 by 1.

Scan the blocks in this sample app, and look for number blocks that contain anything other than 0,1,-1. Aside from a Fontsize setting, there are none.

1 Like