I am currently working on game which requires me to, with a sinlge press, not only change one square but all surrounding squares, however, I have not been able to figure out a way to replace several items in a list at once, ive been using the most common apporach which has been to make a new list with all but one thing changed. however when i try to use a for loop to change multiple things, it doesnt work. here is what ive tried so far.
This version goes back and forth between the two colors:
https://www.desmos.com/calculator/u3cvwyxepg
(I did this in case the game you are thinking of has the goal to change the colors for all the dots)
Can you explain what you did i dont understand how the summation is used?
The function isInList(k,L) checks if k is the list L, to do that we check, for every n, if the value L[n]=k and in that case we add 1 (that’s the role of the sum). So at the end we have the number of occurrences of k in the list L.
With the sign function we convert that number to 1 if it is greater than 0 and to 0 if it is 0.
I think this is in general something i can understand, and it makes sense in concept however i would never have thought to do this. thank you very much.
I have just one other question, for now atleast, however i dont want just the answer becuase i like to learn things on my own. but if i wanted it to recusively “reveal” (change the color) kinda like mineSweeper how it recursively reveals new tiles. how would you recommend going about it? (note: i am trying to make minesweeper for next years art competition, or something simular)
I think there are two possibilities.
1- You actually use recursion. Recursion can be used in desmos and it is very powerful.
2- You could use a time Ticker. When the user clicks a cells, you set a flag to true and the cells start progressively showing until there’s nothing else more to show and the flag goes back to false.
Probably the Ticker is easier.
I know this is very generic … When you face more specific problems I’ll be happy to try to answer. (btw: I took part to the Desmos Competition this year … and I was amongst the winners !! )
If you want to, I would love if youd be willing to teach or try to explain how and what recursion is, and how to use it. if you wouldnt mind, im sure you a busy person though so its okay if you cant or dont want to. thank you for the help!
WOW! you were one of the winners for the Competition?! thats crazy!
Recursion is a vast topic. The basic idea is that you can define a function using itself.
For example, in desmos you can define a function f by writing (on two different lines):
f(0)=1
f(n)= n f(n-1)
and in this way f(n) is the factorial (the multiplication of the integer numbers up to n).
In your case you could define a function F(L, n) that scans the list of cells L and checks if there’s anything to show. The parameter n could be the number of passes still required to end the check, this number could be the number of columns times rows when you call the function (because the number of passes will not exceed the number of columns times rows).
F(L,0) =L
F(L, n) = F( new list from L, n-1)
where the new list shows the cells that are adjacent to a cell with 0 bombs.
i see! thank you very much for spending time in your day to help me, i appreciate it a lot, thank you
Try to implement it … and if you need help you can discuss further the idea.
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.