#Need help with personal project...

16 messages · Page 1 of 1 (latest)

autumn blade
#

I'm making a minesweeper minigame, and I'm having some issues with recursion. What I'm trying to do is reveal all cells that have a value of 0 and aren't mines, as well as reveal all of the cells immediately around that clump that also aren't mines.

crystal zephyr
#

@autumn blade do u want to go from a middle block and then go further from each side?

#

if u want to reveal all cells which arent mine then just loop make 2d array of cells

autumn blade
#

What I want to happen is to reveal cells that have a value of 0 and are touching each other. Kind of like a fill command.

#

This is what I'm trying to do.

crystal zephyr
# autumn blade What I want to happen is to reveal cells that have a value of 0 and are touching...

first make a method which accepts a set of points and a mid point then call the method in other code or main thread with the mid point as what the user is in then inside the method { it will get 4 points first one will be up so int x = midpoint.getx int y = midpoint.gety point firstpoint = (x,y+1) like that four points one (x +1,y) then down one then right one then left one then atlast call loop through the set and call the function againwith the point as the midpoint and add a closing so that it doesnt recursive forveer add if the length of the set is same as before adding then dont loop to the adding points}

#
    static void aroundcolorps(Set<colorp> colorpss,colorp m,int maxx,int maxy,int beforesize,Color[][] colors){
        colorp[] colorps = new colorp[8];
        int mx = m.x;
        int my = m.y;
        
        double num = 0.8;
        if(!(my-1<0))
            if(similarity(colors[mx][my-1],color)>=num)
                colorps[1]= (new colorp(mx,my-1));//2
        
        
        if((mx+1<maxx))
            if(similarity(colors[mx+1][my],color)>=num)
                colorps[3]= (new colorp(mx+1,my));//4
        
        
        if((my+1<maxy))
            if(similarity(colors[mx][my+1],color)>=num)
                colorps[5]= (new colorp(mx,my+1));//6
        
        
        if(!(mx-1<0))
            if(similarity(colors[mx-1][my],color)>=num)
                colorps[7]= (new colorp(mx-1,my));//8
        
        long time = System.currentTimeMillis();
        for(int i = 0;i<8;i++) {
            if(colorps[i]!=null)if(colorpss.contains(colorps[i])) colorps[i] = null;
        }
        Utils.time+= System.currentTimeMillis()-time;


        for(colorp colorp:colorps) {
            //if(!colorpss.contains(colorp))
            if(colorp!=null)
            colorpss.add(colorp);
        }
        
        int currentsize = colorpss.size();
        if(beforesize == currentsize) {
            return;
        }
        
        for(colorp colorp:colorps) {
            if(colorp!=null)
            aroundcolorps(colorpss, colorp, maxx, maxy, currentsize,colors);
        }
    }
#

this is my code

#

u can change the classes

#

int maxy and maxy are the max value it can go the bounds

#

this i used for my paint app

#

it can fill