U E D R , A S I H C RSS

Mine Sweeper/이승한

Mine Sweeper/

Python

데블2005/ 2005/python ToyProblem
만들.
.
~cpp 
def search():
    for i in range(height):
        for j in range(width):
            if M[i][j]=='*':
                if M[i-1][j-1]!= '*' and i-1>=0 and j-1>=0 and i-1<width and j-1<height:
                    M[i-1][j-1]=M[i-1][j-1]+1
                if M[i-1][j]!= '*' and i-1>=0 and j>=0 and i-1<width and j<height:
                    M[i-1][j]=M[i-1][j]+1
                if M[i-1][j+1]!= '*' and i-1>=0 and j+1>=0 and i-1<width and j+1<height:
                    M[i-1][j+1]=M[i][j+1]+1

                if M[i][j-1]!= '*' and i>=0 and j-1>=0 and i<width and j-1<height:
                    M[i][j-1]=M[i][j-1]+1
                if M[i][j+1]!= '*' and i>=0 and j+1>=0 and i<width and j+1<height:
                    M[i][j+1]=M[i][j+1]+1

                if M[i+1][j-1]!= '*' and i+1>=0 and j-1>=0 and i+1<width and j-1<height:
                    M[i+1][j-1]=M[i+1][j-1]+1
                if M[i+1][j]!= '*' and i+1>=0 and j>=0 and i+1<width and j<height:
                    M[i+1][j]=M[i+1][j]+1
                if M[i+1][j+1]!= '*' and i+1>=0 and j+1>=0 and i+1<width and j+1<height:
                    M[i+1][j+1]=M[i+1][j+1]+1

width = 4
height = 4
M=[['*','.','.','.'],['.','.','.','.'],['.','*','.','.'],['.','.','.','.']]

for i in range(height):
    for j in range(width):
        if M[i][j]!='*':
            M[i][j]=int(0)

search()

for i in range(height):
    print M[i]

FLASH

1?? .
들만 만들 본...-_-;; C Array ??;;
는데;; 리~;;

. .



layer ()
~cpp 
function set_val() {

/////////////////////////  는 변 부

	size = 15; 	 // 맵  
	quantityMine=100;//   

/////////////////////////////////////////////////////////////////////////

	i = j = 0;
	set_all_num = 0;
	//size*size  2 를 set_all_num 
	map = new Array();
	for (i=0; i<size; i++) {
		map[i] = new Array();
		for (j=0; j<size; j++) {
			map[i][j] = set_all_num;
		}
	}
	trace("end set all value");
}

//  
function setMine(){
	mine_count = 0;
	while(mine_count<quantityMine){
		for (i=0; i<size; i++) {
			for (j=0; j<size; j++) {
				if( map[i][j]!= -1 && mine_count < quantityMine && !( random(100) % 5 ) ){
					map[i][j]='*';
					trace("뢰 배 " + i + " " + j + "     : " + ++mine_count);
				}else{

				}
			}
		}
	}
}

//  .
function showMineMap(){

	trace(" ");
	trace(" ");
	trace(" ");

	for(i=0; i<size; i++){
			temp = new Array();
			temp = map[i];
			showMap=temp.join(" ");
			trace(showMap);
	}

	trace(" ");
	trace(" ");
	trace(" ");
	
}

//   .
function checkMineMap(){
	minecount = 0;
	for(i=0; i<size; i++){
		for(j=0; j<size; j++){
			if(map[i][j]!='*'){
				if(map[i-1][j-1]=='*')minecount++;
				if(map[i-1][j]=='*')minecount++;
				if(map[i-1][j+1]=='*')minecount++;
				if(map[i][j-1]=='*')minecount++;
				if(map[i][j+1]=='*')minecount++;
				if(map[i+1][j-1]=='*')minecount++;
				if(map[i+1][j]=='*')minecount++;
				if(map[i+1][j+1]=='*')minecount++;
				map[i][j]=minecount;
			}
			minecount=0;
		}
	}
}

blank symbol : 면 변 를 부르는.
~cpp 
onClipEvent(load){
	// 변를 모 
	_root.set_val();

	// 0  
	_root.showMineMap();

	//  
	_root.setMine();

	//  
	_root.showMineMap();

	//   .
	_root.checkMineMap();
	
	//  
	_root.showMineMap();
}

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:23:46
Processing time 0.0116 sec