Computer Science Canada
Turing tetris removing and adding arrays
|Author:||axianna [ Sun Jan 20, 2019 10:27 am ]|
|Post subject:||Turing tetris removing and adding arrays|
What is it you are trying to achieve?
Add and remove an array element into a flexible 2d array
Describe what you have tried to solve this problem
I'm tried to make a new flexible array and then add the elements from the original array into the new array skipping over the rows that are full, but now I have a problem in adding empty values on top
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Please specify what version of Turing you are using
|Author:||Insectoid [ Sun Jan 20, 2019 11:05 am ]|
|Post subject:||RE:Turing tetris removing and adding arrays|
You're taken an interesting approach to solving this problem. Unfortunately it's also the slowest and most complicated. Flexible arrays are extremely slow- every time you call new, the entire array gets copied to a new one, and the old one gets deleted. On top of that, multi-dimensional flexible arrays were never fully implemented in Turing so some things that should work, don't. Surely your Tetris game board doesn't change size during the game, so why not just use regular arrays preset to the max size?
Anyway, this line is a problem: gridcopy(i):=grid(i)
Your full rows *are* being skipped, but your non-full rows are being copied to the same position in the new array, instead of being moved to the bottom.
What is the value of toprow after the first for loop runs?
In the line gridcopy(toprow+i), what does tomorrow+i resolve to? Your empty rows are being added to the array, but where are they?
If you were not using flexible arrays, Turing would have given you an error that would have helped you solve this. Instead of trying to delete the data structure itself, try just deleting the contents of the data structure. Your algorithm is a bit like rebuilding an entire house just to change the wallpaper.
|Author:||axianna [ Sun Jan 20, 2019 12:50 pm ]|
|Post subject:||Re: Turing tetris removing and adding arrays|
ok thank you so much for the advice! I'll go test some new stuff now ty ty