Search the Community
Showing results for tags 'algorithm'.
-
I need some help to optimize algorithm. I have a matrix of sprites and I am highlighting a part of it. It can be rectangle or square it doesn't matter. I need to hide all sprites of this matrix that do not belong to the given area. I have this function which is highly non-optimized i.e 4 nested "for" cycles: hideMatrixArea: function(slotTwoDimArray, row, col, numRows, numCols) { var i = 0, j = 0, k = 0, t = 0, matrixWidth = slotTwoDimArray.length, matrixHeigth = slotTwoDimArray[0].length; for (i = 0; i < matrixWidth; i += 1, k += 1) { for (j = 0; j < matrixHeigth; j += 1, t += 1) { for (k = row; k < row + numRows; k += 1) { for (t = col; t < col + numCols; t += 1) { if (!(k === i && t === j)) { console.log("hello"); this.hideSlot(slotTwoDimArray, i, j); } } } } } return slotTwoDimArray; }, It prints "hello" 15600 times which is a lot. How can I hide slots that are not in the space (row, col) -> (row + numRows, col + numCols) i.e the inverse without using nested "for" loops? Any ideas?
-
Hello everybody, I need little help I am trying to make games like 'matching three object' in (9x9) grid but I dont know what is the algorithm and how to implement the algorithm. please give me some resource, code, algorithms anything that can help me. Thanks.
-
I wrote this game a long time ago in visual basic and have recently ported it over HTML5 / javascript (using SVG for graphics). Just written for fun so no ads, or signup. http://dotsandboxes.org It is the old pencil and paper classic. Try to capture more boxes than the computer. I'm open to suggestions on how to improve so please let me know what you think, especially whether the user interface is clear and if it's playable on android devices (only tested on iPhone).