28-java - 배열로 윷놀이 만들기

jin·2022년 7월 2일
0

이차원배열을 진도를 나가다가 갑자기 선생님이 자~ 여러분~ 팀 배열 공모전을 할거에요~ 이차원배열을 이용해 팀별로 뭔가 만들어오세용~
...네?

아무래도 메인에서 다 처리해야하다보니 팀 주제 선정하다가 합치기 좋게 각 팀원별로 게임을 하나씩 만들기로 했다.
주제 고민을 하다가 윷놀이가 무난해보여서 선정을 했는데... 나는 윷놀이를 주제로 했다하니 선생님이 괜찮겠어? 너무 어려운데? 진실된 조언을 해주셨다. 이때 귀담아 들었어야했는데...

이제 판을 만들어야하는데 1과 0을 가지고 판(맵)을 출력하는건 많이 해봤으니 빈배열로 판을 만들어보자!에 기인해서 반복문에서 윷 판에 대한 조건들을 지정하기로 했다.
그런데 판부터 난관 봉착 어떻게 접근해야하는지 감조차 안와서 count로 윷판 베이스가 될 수를 출력했었다.

그리고 윷판에 필요한 수들을 체크해줬다.

네모 - 분기점 / 동그라미 - 진행을 넣고 고민을 한참했었다.
7 * 7 배열이다 보니 중간 없어야하는 부분은 어떻게 해야할까 고민도 많이 했고 지금이라도 늦지 않았으니 배열로 윷판을 그릴까 고민도 했는데 어찌저찌 조건문으로 윷판을 완성시켰다.

윷판을 완성했으니 윷을 던져야하는데 yut 배열만큼 난수 0,1를 받아 1이면 윷이 뒤집힌걸로 판단해 갯수를 카운트해 진행, 안뒤집히면 모로 조건을 지정해뒀다.
게임답게 바로 콘솔 출력되는것보다 스캐너로 임의의 수를 입력받으며 한번씩 출력하는게 좋다고 생각되었고, player와 cpu, 두 명이 게임한다는걸 가정으로 코드를 작성했다.

아래는 기간 내에 작성한 코드 실행 결과다.

1이 하나이므로 도(1)만큼 플레이어가 나아갔다.


cpu의 턴으로 전부 1인 윷이 나와 중간 공백을 건너뛰고 윷(4)만큼 진행한걸 콘솔로 확인할 수 있다.


잡았을때 상대를 시작지점으로 보내기, 모나 윷일때 턴 유지 등의 윷놀이 기능을 구현했다.
아쉬운점은 윷놀이는 4명이서도 가능하고, 말도 더 있고 말도 업을 수 있어야하는데 이틀이란 시간내에는 벅찼다. 그리고 메소드 파트를 아직 진행하지 않아 중복코드가 많았기도 했다.
문제점도 많았는데 윷판이야 두 말할 것도 없고 윷판의 말들이 갑자기 증발하고, 순간이동을하고, 사라지고, 분기점 이동을 안하고 등등 별별 문제가 있었는데 콘솔에 값을 출력해보며 문제점을 수정했다. 덕분에 콘솔로 문제점 찾아보는 능력이 올라 소소하게 득을 봤다.

지금 코드의 문제가 아예 없는건 아니고 아쉬움도 있지만 나중에 또 뭔가를 만들어오세요~ 했을때 이걸 토대로 완성판을 만들어도 좋지 않을까

int[][] map = new int[7][7];
int leftSpace = 2; // 감소 후 증가 인덱스
int rightSpcace = 4; // 증가 후 감소
int input = -1;
int select = 0;
int cpuSelect = -1;
int playerPoint = 48; // 분기점 판별 포인트
int cpuPoint= 48;
int playerMove = 0; // 몇칸 이동인가 분기점 판별 칸수
int cpuMove = 0;
int playerChangePoint = playerPoint; // 칸수 판별 포인트
int cpuChangePoint = 48;
boolean playerSpace = false; // 공백 건너뛸 판별 변수
boolean cpuSpace = false; 
int clear = 1;
int cpuClear = 1;
boolean over = false;
int turn = 0;
while (true) {
	leftSpace = 2; // 감소 후 증가 인덱스
	rightSpcace = 4; // 증가 후 감소
	
	int[] yut = new int[4];
	int yutCount = 0;
	for (int i = 0; i < yut.length; i++) { // 윷 던지기
		int r = ran.nextInt(2);
		yut[i] = r;
		if (r == 1) {
			yutCount++;
		}
	}
	if (yutCount == 0) { // 모
		yutCount = 5;
	}
	
	int count = 0; // 배열위치 비교 변수
	int tempCount = 0;
	boolean insert = false;
	boolean delete = false;
	//배열에 넣어고 지우기 ==> 둘 다 true면 break;
	// player
	int k = 0;
	while (true) {
		if (k == 7) {
			k = 0;
		}
		if (insert == true && delete == true) {
			break;
		}
		for (int j = 0; j < map[k].length;j++) {
			if (map[k][j] == 1) {
				map[k][j] = 0;
				delete = true;
			}
			if (count == playerChangePoint) {
				map[k][j] = 1;
				insert = true;
			}
			count++;
		}
		if (count == 49) {
			delete = true;
		}
		k++;
	}
	// cpu
	insert = false;
	delete = false;
	k = 0;
	count = 0;
	while (true) {
		if (k == 7) {
			k = 0;
		}
		if (insert == true && delete == true) {
			break;
		}
		
		for (int j = 0; j < map[k].length;j++) {
			if (map[k][j] == 2) {
				map[k][j] = 0;
				delete = true;
			}
			if (count == cpuChangePoint) {
				map[k][j] = 2;
				insert = true;
			}
			if (map[k][j] == 1 && cpuChangePoint == playerChangePoint) {
				map[k][j] = 0;
				playerChangePoint = 48;
			}
			count++;
		}
		if (count == 49) {
			delete = true;
			insert = true;
		}
		k++;
	}
	//============================================================
	// 출력
	for (int i = 0; i < map.length; i++) {
		for (int j = 0; j < map[i].length; j++) {
			if ( j == 3 && i != 3) {
				System.out.printf("     ");
			} else if (i == 3 && j != 3) {
				System.out.printf("     ");
			} else if (i != 0 && i != 6 && (leftSpace == j || rightSpcace == j)  ) { 
					System.out.printf("     ");
			} else if (map[i][j] == 1)  {
				System.out.printf("[● ] ");
			} else if (map[i][j] == 2) {
				System.out.printf("[▲ ] ");
			} else {
				System.out.printf("[  ] ");
			}
		}
		if (i == 3) {
			leftSpace--;
			rightSpcace ++;
		}
		if (i != 0 && i != 6 && i != 3) {
			if (leftSpace == 1) {
				leftSpace++;
			} else {
				leftSpace--;
			}
			if (rightSpcace == 5) {
				rightSpcace--;
			} else {
				rightSpcace++;
			}
		}
		System.out.println("\n");
	}
	System.out.println("\n");
	if (map[6][6] != 0 && over == true) {
		if (map[6][6] == 1) {
			System.err.println("player 승");
			break;
		} else {
			System.err.println("cpu 승");
			break;
		}
	}
	//============================================================
	if (turn % 2 == 0) { // 플레이어
		// 배열에 넣어주는 위치 구하기 따로 / 배열에 넣기 따로 / 출력 따로 / 배열에 넣어줄 위치 구하기
		if (playerMove/5 == clear) { 
			playerSpace = false;
			clear++;
		}
		if (playerChangePoint == 6) { // 각 분기점
			playerPoint = 6;
			System.out.println("player [1]왼쪽진행 [2]대각진행");
			select = scan.nextInt();
			if (select == 2) {
				playerMove = 100;
			}
		} else if (playerChangePoint == 24) {
			System.out.println("player [3]왼쪽진행 [4]오른쪽진행");
			select = scan.nextInt();
		} else if (playerChangePoint == 0) {
			System.out.println("player [5]대각진행 [6]아래쪽진행");
			select = scan.nextInt();
			if (select == 5) {
				playerMove = 10;
			}
		} else if (playerChangePoint == 42) {
			System.out.println("player [8]오른쪽진행");
			select = 8;
		}
		System.out.println("player의 윷 던지기 ");
		input = scan.nextInt();
		System.out.println(Arrays.toString(yut));
		System.out.println(yutCount);
		if (yutCount == 4 || yutCount == 5) {
			if (yutCount == 5) {
				System.err.println("모! \n한번더 던지기!");
			} else {
				System.err.println("윷! \n한번더 던지기!");
			}
			turn++;
		}
		turn++;
		if (playerPoint == 48) { // 처음시작 포인트 구하기 ==> 매 분기구간마다 space false 리셋
			playerMove += yutCount; 
			tempCount = yutCount * 7;
			if (playerSpace == false) {//중간 공백 건너뛸 조건
				if (playerMove > 2) {
					playerChangePoint -= 7;
					playerSpace = true;
				}
			}
			playerChangePoint -= tempCount;
			if (playerChangePoint == cpuChangePoint) { // 매번 변할때 넣어야함
				System.out.println("컴퓨터 잡힘! \n잡힌 말은 시작지점으로 돌아갑니다");
				cpuPoint = 48;
				cpuChangePoint = 48;
				cpuMove = 0;
				cpuSpace = false;
				cpuSelect = -1;
				cpuClear = 1;
			}
			if (playerChangePoint < 6) {
				playerPoint = 6;
				playerChangePoint = 6;
				select = 1;
				tempCount = playerMove - 5;
				playerChangePoint -= tempCount;
				if (playerChangePoint == cpuChangePoint) { // 매번 변할때 넣어야함
					System.out.println("컴퓨터 잡힘! \n잡힌 말은 시작지점으로 돌아갑니다");
					cpuPoint = 48;
					cpuChangePoint = 48;
					cpuMove = 0;
					cpuSpace = false;
					cpuSelect = -1;
					cpuClear = 1;
				}
				if (playerMove >= 8) {
					playerChangePoint -= 1;
					playerSpace = true;
				}
				continue;
			}
		} if (select == 1) { // 6분기점==========================================
			playerMove += yutCount;
			tempCount = yutCount * 1;
			if (playerSpace == false) {
				if (playerMove >= 8) {
					playerChangePoint -= 1;
					playerSpace = true;
				}
			}
			playerChangePoint -= tempCount;
			if (playerChangePoint == cpuChangePoint) { // 매번 변할때 넣어야함
				System.out.println("컴퓨터 잡힘! \n잡힌 말은 시작지점으로 돌아갑니다");
				cpuPoint = 48;
				cpuChangePoint = 48;
				cpuMove = 0;
				cpuSpace = false;
				cpuSelect = -1;
				cpuClear = 1;
			}
			if (playerChangePoint < 0) {
				playerPoint = 0;
				playerChangePoint = 0;
				tempCount = (playerMove - 10) * 7;
				playerChangePoint += tempCount;
				if (playerChangePoint == cpuChangePoint) { // 매번 변할때 넣어야함
					System.out.println("컴퓨터 잡힘! \n잡힌 말은 시작지점으로 돌아갑니다");
					cpuPoint = 48;
					cpuChangePoint = 48;
					cpuMove = 0;
					cpuSpace = false;
					cpuSelect = -1;
					cpuClear = 1;
				}
				select = 6;
				continue;
			}
		} else  if (select == 2) { // 첫번째 대각
			playerMove += yutCount; 
			tempCount = yutCount * 6;
			playerChangePoint += tempCount;
			if (playerChangePoint == cpuChangePoint) { // 매번 변할때 넣어야함
				System.out.println("컴퓨터 잡힘! \n잡힌 말은 시작지점으로 돌아갑니다");
				cpuPoint = 48;
				cpuChangePoint = 48;
				cpuMove = 0;
				cpuSpace = false;
				cpuSelect = -1;
				cpuClear = 1;
			}
			if (playerChangePoint >= 42) {
				tempCount = playerMove-106; // 대각무브 - 100
				System.out.println("player tempCount : "+tempCount);
				playerPoint = 42;
				playerChangePoint = 42;
				playerMove = 15;
				clear = 3;
				select = 8; // 여기부터 수정
				
				playerChangePoint += tempCount;
				if (playerChangePoint == cpuChangePoint) { // 매번 변할때 넣어야함
					System.out.println("컴퓨터 잡힘! \n잡힌 말은 시작지점으로 돌아갑니다");
					cpuPoint = 48;
					cpuChangePoint = 48;
					cpuMove = 0;
					cpuSpace = false;
					cpuSelect = -1;
					cpuClear = 1;
				}
				if (playerChangePoint >= 45) {
					playerChangePoint += 1;
					playerSpace = true;
				}
				continue;
			}
		} else if (select == 4) { // 24에서 오른대각방향
			playerMove += yutCount; 
			tempCount = yutCount * 8;
			playerChangePoint += tempCount;
			if (playerChangePoint == cpuChangePoint) { // 매번 변할때 넣어야함
				System.out.println("컴퓨터 잡힘! \n잡힌 말은 시작지점으로 돌아갑니다");
				cpuPoint = 48;
				cpuChangePoint = 48;
				cpuMove = 0;
				cpuSpace = false;
				cpuSelect = -1;
				cpuClear = 1;
			}
			if (playerChangePoint >= 48) {
				System.err.println("플레이어 승리");
				playerChangePoint = 48;
				over = true;
				continue;
			}
		} else if (select == 3) {
			playerMove += yutCount; 
			tempCount = yutCount * 6;
			playerChangePoint += tempCount;
			if (playerChangePoint == cpuChangePoint) { // 매번 변할때 넣어야함
				System.out.println("컴퓨터 잡힘! \n잡힌 말은 시작지점으로 돌아갑니다");
				cpuPoint = 48;
				cpuChangePoint = 48;
				cpuMove = 0;
				cpuSpace = false;
				cpuSelect = -1;
				cpuClear = 1;
			}
			if (playerMove >= 106) {
				tempCount = playerMove-106; // 대각무브 - 100
				System.out.println("player tempCount : "+tempCount);
				playerPoint = 42;
				playerChangePoint = 42;
				playerMove = 15;
				clear = 3;
				select = 8; 
				
				playerChangePoint += tempCount;
				if (playerChangePoint == cpuChangePoint) { // 매번 변할때 넣어야함
					System.out.println("컴퓨터 잡힘! \n잡힌 말은 시작지점으로 돌아갑니다");
					cpuPoint = 48;
					cpuChangePoint = 48;
					cpuMove = 0;
					cpuSpace = false;
					cpuSelect = -1;
					cpuClear = 1;
				}
				if (playerChangePoint >= 45) {
					playerChangePoint += 1;
					playerSpace = true;
				}
				continue;
			} else if (select == 5) { // 0기준 대각진행
				playerMove += yutCount; 
				tempCount = yutCount * 8;
				playerChangePoint += tempCount;
				if (playerChangePoint == cpuChangePoint) { // 매번 변할때 넣어야함
					System.out.println("컴퓨터 잡힘! \n잡힌 말은 시작지점으로 돌아갑니다");
					cpuPoint = 48;
					cpuChangePoint = 48;
					cpuMove = 0;
					cpuSpace = false;
					cpuSelect = -1;
					cpuClear = 1;
				}
				if (playerChangePoint >= 48) {
					System.err.println("플레이어 승리");
					playerChangePoint = 48;
					over = true;
					continue;
				}
			} 
			
			} else  if (select == 6) { // 0기준 아래 진행
				playerMove += yutCount; 
				tempCount = yutCount * 7;
				System.out.println("tempCount : "+tempCount);
				if (playerSpace == false) {
					if (playerMove >= 13) {
						playerChangePoint += 7;
						playerSpace = true;
					}
				}
				playerChangePoint += tempCount;
				if (playerChangePoint == cpuChangePoint) { // 매번 변할때 넣어야함
					System.out.println("컴퓨터 잡힘! \n잡힌 말은 시작지점으로 돌아갑니다");
					cpuPoint = 48;
					cpuChangePoint = 48;
					cpuMove = 0;
					cpuSpace = false;
					cpuSelect = -1;
					cpuClear = 1;
				}
				if (playerChangePoint >= 42) {
					playerPoint = 42;
					playerChangePoint = 42;
					select = 8;
					count = playerMove - 15;
					playerChangePoint += tempCount;
					if (playerChangePoint == cpuChangePoint) { // 매번 변할때 넣어야함
						System.out.println("컴퓨터 잡힘! \n잡힌 말은 시작지점으로 돌아갑니다");
						cpuPoint = 48;
						cpuChangePoint = 48;
						cpuMove = 0;
						cpuSpace = false;
						cpuSelect = -1;
						cpuClear = 1;
					}
					if (playerMove >= 18) {
						playerChangePoint += 1;
						playerSpace = true;
					}
					continue;
				}
			} else if (select == 8 || select == 10) {
				playerMove += yutCount; 
				tempCount = yutCount * 1;
//								System.out.println("tempCount : "+tempCount);
				if (playerSpace == false) {
					if (playerMove >= 18) {
						playerChangePoint += 1;
						playerSpace = true;
					}
				}
				playerChangePoint += tempCount;
				if (playerChangePoint == cpuChangePoint) { // 매번 변할때 넣어야함
					System.out.println("컴퓨터 잡힘! \n잡힌 말은 시작지점으로 돌아갑니다");
					cpuPoint = 48;
					cpuChangePoint = 48;
					cpuMove = 0;
					cpuSpace = false;
					cpuSelect = -1;
					cpuClear = 1;
				}
				if (playerChangePoint >= 48) {
					System.err.println("플레이어 승리");
					playerChangePoint = 48;
					over = true;
					continue;
				}
			}
		//============================================================
	} else { // cpu
		if (cpuMove/5 == cpuClear) {
			cpuSpace = false;
			cpuClear++;
		}
		if (cpuChangePoint == 6) { // 각 분기점
			cpuPoint = 6;
			System.out.println("cpu  [1]왼쪽진행 [2]대각진행");
			cpuSelect = scan.nextInt();
			if (cpuSelect == 2) {
				cpuMove = 100;
			}
		} else if (cpuChangePoint == 24) {
			System.out.println("cpu  [3]왼쪽진행 [4]오른쪽진행");
			cpuSelect = scan.nextInt();
		} else if (cpuChangePoint == 0 ) {
			System.out.println("cpu  [5]대각진행 [6]아래쪽진행");
			cpuSelect = scan.nextInt();
			if (cpuSelect == 5) {
				cpuMove = 100;
			}
		} else if (cpuChangePoint == 42) {
			System.out.println("cpu [8]오른쪽진행");
			cpuSelect = scan.nextInt();
		}
		System.out.println();
		System.out.println("cpu의 윷 던지기 ");
		input = scan.nextInt();
		System.out.println(Arrays.toString(yut));
		System.out.println(yutCount);
		if (yutCount == 4 || yutCount == 5) {
			if (yutCount == 5) {
				System.err.println("모! \n한번 더 던지기!");
			} else {
				System.err.println("윷! \n한번 더 던지기!");
			}
			turn++;
		}
		turn++;
		if (cpuPoint == 48) { // 처음시작 포인트 구하기 ==> 매 분기구간마다 space false 리셋
			cpuMove += yutCount; // 이부분 수정 => move값은 변함
			tempCount = yutCount * 7;
			if (cpuSpace == false) {//중간 공백 건너뛸 조건 음,,,
				if (cpuMove > 2) {
					cpuChangePoint -= 7;
					cpuSpace = true;
				}
			}
			cpuChangePoint -= tempCount;
			if (cpuChangePoint == playerChangePoint) { // 매번 변할때 넣어야함
				System.out.println("플레이어 잡힘! \n잡힌 말은 시작지점으로 돌아갑니다");
				playerPoint = 48;
				playerChangePoint = 48;
				playerMove = 0;
				playerSpace = false;
				select = -1;
				clear = 1;
			}
			if (cpuChangePoint < 6) {
				cpuPoint = 6;
				cpuChangePoint = 6;
				cpuSelect = 1;
				tempCount = cpuMove - 5;
				cpuChangePoint -= tempCount;
				if (cpuChangePoint == playerChangePoint) { // 매번 변할때 넣어야함
					System.out.println("플레이어 잡힘! \n잡힌 말은 시작지점으로 돌아갑니다");
					playerPoint = 48;
					playerChangePoint = 48;
					playerMove = 0;
					playerSpace = false;
					select = -1;
					clear = 1;
				}
				if (cpuMove >= 8) {
					cpuChangePoint -= 1;
					cpuSpace = true;
				}
				continue;
			}
		} if (cpuSelect == 1) { // 6분기점 왼이동
			cpuMove += yutCount;
			tempCount = yutCount * 1;
			if (cpuSpace == false) {
				if (cpuMove >= 8) {
					cpuChangePoint -= 1;
					cpuSpace = true;
				}
			}
			cpuChangePoint -= tempCount;
			if (cpuChangePoint == playerChangePoint) { // 매번 변할때 넣어야함
				System.out.println("플레이어 잡힘! \n잡힌 말은 시작지점으로 돌아갑니다");
				playerPoint = 48;
				playerChangePoint = 48;
				playerMove = 0;
				playerSpace = false;
				select = -1;
				clear = 1;
			}
			if (cpuChangePoint < 0) {
				cpuPoint = 0;
				cpuChangePoint = 0;
				cpuSelect = 6;
				tempCount = (cpuMove - 10) * 7;
				cpuChangePoint += tempCount;
				if (cpuChangePoint == playerChangePoint) { // 매번 변할때 넣어야함
					System.out.println("플레이어 잡힘! \n잡힌 말은 시작지점으로 돌아갑니다");
					playerPoint = 48;
					playerChangePoint = 48;
					playerMove = 0;
					playerSpace = false;
					select = -1;
					clear = 1;
				}
				continue;
			}
		}else  if (cpuSelect == 2) { // 첫번째 대각
			cpuMove += yutCount; 
			tempCount = yutCount * 6;
			cpuChangePoint += tempCount;
			if (playerChangePoint == cpuChangePoint) { // 매번 변할때 넣어야함
				System.out.println("컴퓨터 잡힘! \n잡힌 말은 시작지점으로 돌아갑니다");
				playerPoint = 48;
				playerChangePoint = 48;
				playerMove = 0;
				playerSpace = false;
				select = -1;
				clear = 1;
			}
			if (cpuMove >= 106) {
				tempCount = cpuMove-106; // 6 - 대각포인트
				System.out.println("cpu tempCount : "+tempCount);
				cpuPoint = 42;
				cpuChangePoint = 42;
				cpuMove = 15;
				cpuClear = 3;
				cpuSelect = 8; // 여기부터 수정
				
				cpuChangePoint += tempCount;
				if (cpuChangePoint == playerChangePoint) { // 매번 변할때 넣어야함
					System.out.println("플레이어 잡힘! \n잡힌 말은 시작지점으로 돌아갑니다");
					playerPoint = 48;
					playerChangePoint = 48;
					playerMove = 0;
					playerSpace = false;
					select = -1;
					clear = 1;
				}
				if (cpuChangePoint >= 45) {
					cpuChangePoint += 1;
					cpuSpace = true;
				}
				continue;
			}
		} else if (cpuSelect == 4) {
			cpuMove += yutCount; 
			tempCount = yutCount * 8;
			cpuChangePoint += tempCount;
			if (playerChangePoint == cpuChangePoint) { // 매번 변할때 넣어야함
				System.out.println("컴퓨터 잡힘! \n잡힌 말은 시작지점으로 돌아갑니다");
				cpuPoint = 48;
				cpuChangePoint = 48;
				cpuMove = 0;
				cpuSpace = false;
				cpuSelect = -1;
				cpuClear = 1;
			}
			if (cpuChangePoint >= 48) {
				cpuChangePoint = 48;
				over = true;
				continue;
			}
		} else if (cpuSelect == 3) {
			cpuMove += yutCount; 
			tempCount = yutCount * 6;
			cpuChangePoint += tempCount;
			if (playerChangePoint == cpuChangePoint) { // 매번 변할때 넣어야함
				System.out.println("컴퓨터 잡힘! \n잡힌 말은 시작지점으로 돌아갑니다");
				playerPoint = 48;
				playerChangePoint = 48;
				playerMove = 0;
				playerSpace = false;
				select = -1;
				clear = 1;
			}
			if (cpuMove >= 106) {
				tempCount = cpuMove-106; 
				System.out.println("cpu tempCount : "+tempCount);
				cpuPoint = 42;
				cpuChangePoint = 42;
				cpuMove = 15;
				cpuClear = 3;
				cpuSelect = 8; 
				
				cpuChangePoint += tempCount;
				if (cpuChangePoint == playerChangePoint) { // 매번 변할때 넣어야함
					System.out.println("플레이어 잡힘! \n잡힌 말은 시작지점으로 돌아갑니다");
					playerPoint = 48;
					playerChangePoint = 48;
					playerMove = 0;
					playerSpace = false;
					select = -1;
					clear = 1;
				}
				if (cpuChangePoint >= 45) {
					cpuChangePoint += 1;
					cpuSpace = true;
				}
				continue;
			}
		} else if (cpuSelect == 5) { // 0기준 대각진행
			cpuMove += yutCount; 
			tempCount = yutCount * 8;
			cpuChangePoint += tempCount;
			if (playerChangePoint == cpuChangePoint) { // 매번 변할때 넣어야함
				System.out.println("컴퓨터 잡힘! \n잡힌 말은 시작지점으로 돌아갑니다");
				cpuPoint = 48;
				cpuChangePoint = 48;
				cpuMove = 0;
				cpuSpace = false;
				cpuSelect = -1;
				cpuClear = 1;
			}
			if (cpuChangePoint >= 48) {
				cpuChangePoint = 48;
				over = true;
				continue;
			}
		} else if (cpuSelect == 6) { // 0기준 아래진행
			cpuMove += yutCount; 
			tempCount = yutCount * 7;
			if (cpuSpace == false) {
				if (cpuMove >= 13) {
					cpuChangePoint += 7;
					cpuSpace = true;
				}
			}
			cpuChangePoint += tempCount;
			if (cpuChangePoint == playerChangePoint) { // 매번 변할때 넣어야함
				System.out.println("플레이어 잡힘! \n잡힌 말은 시작지점으로 돌아갑니다");
				playerPoint = 48;
				playerChangePoint = 48;
				playerMove = 0;
				playerSpace = false;
				select = -1;
				clear = 1;
			}
			if (cpuChangePoint >= 42) {
				cpuPoint = 42;
				cpuChangePoint = 42;
				cpuSelect = 8;
				tempCount = cpuMove - 15;
				cpuChangePoint += tempCount;
				if (cpuChangePoint == playerChangePoint) { // 매번 변할때 넣어야함
					System.out.println("플레이어 잡힘! \n잡힌 말은 시작지점으로 돌아갑니다");
					playerPoint = 48;
					playerChangePoint = 48;
					playerMove = 0;
					playerSpace = false;
					select = -1;
					clear = 1;
				}
				if (cpuMove >= 18) {
					cpuChangePoint += 1;
					cpuSpace = true;
				}
				continue;
			}
		} else if (cpuSelect == 8 || cpuSelect == 10) {
			cpuMove += yutCount; 
			tempCount = yutCount * 1;
//							System.out.println("tempCount : "+tempCount);
			if (cpuSpace == false) {
				if (cpuMove >= 18) {
					cpuChangePoint += 1;
					cpuSpace = true;
				}
			}
			cpuChangePoint += tempCount;
			if (playerChangePoint == cpuChangePoint) { // 매번 변할때 넣어야함
				System.out.println("컴퓨터 잡힘! \n잡힌 말은 시작지점으로 돌아갑니다");
				playerPoint = 48;
				playerChangePoint = 48;
				playerMove = 0;
				playerSpace = false;
				select = -1;
				clear = 1;
			}
			if (cpuChangePoint >= 48) {
				System.err.println("플레이어 승리");
				cpuChangePoint = 48;
				over = true;
				continue;
			}
		}
	} 
}

0개의 댓글