public override bool[,,] PossibleMove(Piece[,,] positions) { var r = new bool[8, 3, 8]; Piece c; int i, j, k; for (j = (int)position.y - 1; j <= (int)position.y + 1 && j < 3; j++) { for (i = (int)position.x - 1; i <= (int)position.x + 1 && i < 8; i++) { for (k = (int)position.z - 1; k <= (int)position.z + 1 && k < 8; k++) { if (j == -1 || i == -1 || k == -1) { continue; } c = BoardManagerReworked.Instance.Pieces[i, j, k]; if (c == null) { r[i, j, k] = true; } else if (c.isWhite != isWhite) { r[i, j, k] = true; } } } } ShowCastleMove(ref r); return(r); }
public static void Initialize(Game g) { board = new Piece[8, 8, 3]; board[0, 0, 0] = new Piece(Type.Root, true); board[1, 0, 0] = new Piece(Type.Knight, true); board[2, 0, 0] = new Piece(Type.Bishop, true); board[3, 0, 0] = new Piece(Type.Queen, true); board[4, 0, 0] = new Piece(Type.King, true); board[5, 0, 0] = new Piece(Type.Bishop, true); board[6, 0, 0] = new Piece(Type.Knight, true); board[7, 0, 0] = new Piece(Type.Root, true); for (int i = 0; i < 8; i++) board[i, 1, 0] = new Piece(Type.Pawn, true); board = new Piece[8, 8, 3]; board[0, 7, 2] = new Piece(Type.Root, false); board[1, 7, 2] = new Piece(Type.Knight, false); board[2, 7, 2] = new Piece(Type.Bishop, false); board[3, 7, 2] = new Piece(Type.Queen, false); board[4, 7, 2] = new Piece(Type.King, false); board[5, 7, 2] = new Piece(Type.Bishop, false); board[6, 7, 2] = new Piece(Type.Knight, false); board[7, 7, 2] = new Piece(Type.Root, false); for (int i = 0; i < 8; i++) board[i, 6, 2] = new Piece(Type.Pawn, false); XBase = new int[3]; YBase = new int[3]; XBase[0] = 500; XBase[1] = 500; XBase[2] = 500; YBase[0] = 0; YBase[1] = 205; YBase[2] = 410; game = g; }
protected Piece[,,] virtualMovePiece(Vector3 oldPos, Vector3 newPos, Vector3 removePos, Piece[,,] array) { if (!ValidPos(oldPos) && !ValidPos(newPos) && !ValidPos(removePos)) { Debug.Log("Wrong positions!"); return(array); } Piece[,,] arrayCopy = array; int oldX, oldY, oldZ; int newX, newY, newZ; int remX, remY, remZ; oldX = (int)oldPos.x; oldY = (int)oldPos.y; oldZ = (int)oldPos.z; newX = (int)newPos.x; newY = (int)newPos.y; newZ = (int)newPos.z; remX = (int)removePos.x; remY = (int)removePos.y; remZ = (int)removePos.z; Piece oldPiece = arrayCopy[oldX, oldY, oldZ]; //Debug.Log(new Vector3(newX,newY,newZ)); arrayCopy[newX, newY, newZ] = oldPiece; arrayCopy[remX, remY, remZ] = null; arrayCopy[oldX, oldY, oldZ] = null; return(arrayCopy); }
public void Init() { pieces = new Piece[x + 2, y + 2, z + 2]; plates = new Transform[x + 2, y + 2, z + 2]; PlatePut(); PiecePut(); }
public Snapshot(Piece[,,] data) { this.data = data; this.Pieces = data.Cast <Piece>() .Distinct() // we have empty spaces in the array .Where(p => p != null) .ToList(); this.labels = getLabels(Pieces).ToArray(); this.IsSeparable = zSeparable() || ySeparable() || xSeparable(); }
public void Render(Piece[,,] pieces) { RemovePieces(); // TODO Don't re-create pieces every update. Replace already existed pieces. Also add rotate animation. for (var x = 0; x < pieces.GetLength(0); x++) { for (var y = 0; y < pieces.GetLength(1); y++) { for (var z = 0; z < pieces.GetLength(2); z++) { InstantiatePiece(x, y, z, pieces[x, y, z].Stickers); } } } Debug.Log("Rendered"); }
//Helper function checks if place is valid and puts it in the array public void KnightMove(int nX, int nY, int nZ, Vector3 oldPos, ref bool[,,] r, Piece[,,] positions) { Vector3 newPos = new Vector3(nX, nY, nZ); if (ValidPos(newPos)) { Piece c = BoardManagerReworked.Instance.Pieces[nX, nY, nZ]; if (c == null) { r[nX, nY, nZ] = true; } else if (isWhite != c.isWhite) { r[nX, nY, nZ] = true; } } }
// コマを置ける場所のリストを返す // 置ける場所のPieceクラスの情報がリストで入っている List <Piece> getPutableList(Piece[, ,] pieceArrayNow) { List <Piece> putableList = new List <Piece> (); for (int z = 0; z < 4; z++) { for (int x = 0; x < 4; x++) { for (int y = 0; y < 4; y++) { if (pieceArrayNow [x, y, z].pieceType == PieceType.None) { // 何も置かれていない場合は置ける場所のリストに加える putableList.Add(pieceArrayNow[x, y, z]); break; } } } } return(putableList); }
public override bool[,,] PossibleMove(Piece[,,] positions) { var r = new bool[8, 3, 8]; Piece c; int i, j; //Forward Left i = (int)position.x; j = (int)position.z; while (true) { i--; j++; if (i < 0 || j == 8) { break; } c = BoardManagerReworked.Instance.Pieces[i, (int)position.y, j]; if (c == null) { r[i, (int)position.y, j] = true; } else { if (isWhite != c.isWhite) { r[i, (int)position.y, j] = true; } break; } } //Forward Right i = (int)position.x; j = (int)position.z; while (true) { i++; j++; if (i == 8 || j == 8) { break; } c = BoardManagerReworked.Instance.Pieces[i, (int)position.y, j]; if (c == null) { r[i, (int)position.y, j] = true; } else { if (isWhite != c.isWhite) { r[i, (int)position.y, j] = true; } break; } } //Backward Left i = (int)position.x; j = (int)position.z; while (true) { i--; j--; if (i == -1 || j == -1) { break; } c = BoardManagerReworked.Instance.Pieces[i, (int)position.y, j]; if (c == null) { r[i, (int)position.y, j] = true; } else { if (isWhite != c.isWhite) { r[i, (int)position.y, j] = true; } break; } } //Backward Right i = (int)position.x; j = (int)position.z; while (true) { i++; j--; if (i == 8 || j == -1) { break; } c = BoardManagerReworked.Instance.Pieces[i, (int)position.y, j]; if (c == null) { r[i, (int)position.y, j] = true; } else { if (isWhite != c.isWhite) { r[i, (int)position.y, j] = true; } break; } } int k; //Forward Left Up i = (int)position.x; j = (int)position.z; k = (int)position.y; while (true) { i--; j++; k++; if (i < 0 || j == 8 || k == 3) { break; } c = BoardManagerReworked.Instance.Pieces[i, k, j]; if (c == null) { r[i, k, j] = true; } else { if (isWhite != c.isWhite) { r[i, k, j] = true; } break; } } //Forward Right Up i = (int)position.x; j = (int)position.z; k = (int)position.y; while (true) { i++; j++; k++; if (i == 8 || j == 8 || k == 3) { break; } c = BoardManagerReworked.Instance.Pieces[i, k, j]; if (c == null) { r[i, k, j] = true; } else { if (isWhite != c.isWhite) { r[i, k, j] = true; } break; } } //Backward Left Up i = (int)position.x; j = (int)position.z; k = (int)position.y; while (true) { i--; j--; k++; if (i < 0 || j < 0 || k == 3) { break; } c = BoardManagerReworked.Instance.Pieces[i, k, j]; if (c == null) { r[i, k, j] = true; } else { if (isWhite != c.isWhite) { r[i, k, j] = true; } break; } } //Backward Right Up i = (int)position.x; j = (int)position.z; k = (int)position.y; while (true) { i++; j--; k++; if (i == 8 || j < 0 || k == 3) { break; } c = BoardManagerReworked.Instance.Pieces[i, k, j]; if (c == null) { r[i, k, j] = true; } else { if (isWhite != c.isWhite) { r[i, k, j] = true; } break; } } //Forward Left Down i = (int)position.x; j = (int)position.z; k = (int)position.y; while (true) { i--; j++; k--; if (i < 0 || j == 8 || k < 0) { break; } c = BoardManagerReworked.Instance.Pieces[i, k, j]; if (c == null) { r[i, k, j] = true; } else { if (isWhite != c.isWhite) { r[i, k, j] = true; } break; } } //Forward Right Down i = (int)position.x; j = (int)position.z; k = (int)position.y; while (true) { i++; j++; k--; if (i == 8 || j == 8 || k < 0) { break; } c = BoardManagerReworked.Instance.Pieces[i, k, j]; if (c == null) { r[i, k, j] = true; } else { if (isWhite != c.isWhite) { r[i, k, j] = true; } break; } } //Backward Left Down i = (int)position.x; j = (int)position.z; k = (int)position.y; while (true) { i--; j--; k--; if (i < 0 || j < 0 || k < 0) { break; } c = BoardManagerReworked.Instance.Pieces[i, k, j]; if (c == null) { r[i, k, j] = true; } else { if (isWhite != c.isWhite) { r[i, k, j] = true; } break; } } //Backward Right down i = (int)position.x; j = (int)position.z; k = (int)position.y; while (true) { i++; j--; k--; if (i == 8 || j < 0 || k < 0) { break; } c = BoardManagerReworked.Instance.Pieces[i, k, j]; if (c == null) { r[i, k, j] = true; } else { if (isWhite != c.isWhite) { r[i, k, j] = true; } break; } } return(r); }
public override bool[,,] PossibleMove(Piece[,,] positions) { var r = new bool[8, 3, 8]; for (int i = 0; i < 7; i++) { for (int j = 0; j < 7; j++) { for (int k = 0; k < 3; k++) { r[i, k, j] = false; } } } Piece c; int forward; if (isWhite) { forward = 1; } else { forward = -1; } int oX, oY, oZ, x, y, z; oX = (int)position.x; oY = (int)position.y; oZ = (int)position.z; if (roundMoved == 0) { x = oX; y = oY; z = oZ + forward * 2; if (BoardManagerReworked.Instance.IsValidCoordinate(new Vector3(x, y, z))) { if (BoardManagerReworked.Instance.Pieces[x, y, z] == null) { r[x, y, z] = true; } } x = oX; y = oY + forward * 2; z = oZ + forward * 2; if (BoardManagerReworked.Instance.IsValidCoordinate(new Vector3(x, y, z))) { if (BoardManagerReworked.Instance.Pieces[x, y, z] == null) { r[x, y, z] = true; } } } for (int i = -1; i <= 1; i++) { //Check forward left x = oX - 1; y = oY + i; z = oZ + forward; if (BoardManagerReworked.Instance.IsValidCoordinate(new Vector3(x, y, z))) { if (BoardManagerReworked.Instance.Pieces[x, y, z] != null && BoardManagerReworked.Instance.Pieces[x, y, z].isWhite != isWhite) { Debug.Log(new Vector3(x, y, z)); r[x, y, z] = true; } } //Check forward x = oX; y = oY + i; z = oZ + forward; if (BoardManagerReworked.Instance.IsValidCoordinate(new Vector3(x, y, z))) { if (BoardManagerReworked.Instance.Pieces[x, y, z] == null) { Debug.Log(new Vector3(x, y, z)); r[x, y, z] = true; } } //Check forward right x = oX + 1; y = oY + i; z = oZ + forward; if (BoardManagerReworked.Instance.IsValidCoordinate(new Vector3(x, y, z))) { if (BoardManagerReworked.Instance.Pieces[x, y, z] != null && BoardManagerReworked.Instance.Pieces[x, y, z].isWhite != isWhite) { Debug.Log(new Vector3(x, y, z)); r[x, y, z] = true; } } //Check up and down if (i != 0) { x = oX; y = oY + i; z = oZ; if (BoardManagerReworked.Instance.IsValidCoordinate(new Vector3(x, y, z))) { if (BoardManagerReworked.Instance.Pieces[x, y, z] == null) { Debug.Log(new Vector3(x, y, z)); r[x, y, z] = true; } } } } //En passant x = oX - 1; y = oY; z = oZ; if (BoardManagerReworked.Instance.IsValidCoordinate(new Vector3(x, y, z))) { if (BoardManagerReworked.Instance.Pieces[x, y, z] != null) { if (isWhite) { if (BoardManagerReworked.Instance.Pieces[x, y, z].GETPieceCode() == 'p') { if (((Pawn)BoardManagerReworked.Instance.Pieces[x, y, z]).doubleMoved && BoardManagerReworked.Instance.Pieces[x, y, z].roundMoved == BoardManagerReworked.Instance.roundNumber - 1 && BoardManagerReworked.Instance.Pieces[x, y, z + forward] == null) { Debug.Log("asd"); r[x, y, z + forward] = true; } } } else { if (BoardManagerReworked.Instance.Pieces[x, y, z].GETPieceCode() == 'P') { if (((Pawn)BoardManagerReworked.Instance.Pieces[x, y, z]).doubleMoved && BoardManagerReworked.Instance.Pieces[x, y, z].roundMoved == BoardManagerReworked.Instance.roundNumber - 1 && BoardManagerReworked.Instance.Pieces[x, y, z + forward] == null) { Debug.Log("asd"); r[x, y, z + forward] = true; } } } } } x = oX + 1; y = oY; z = oZ; if (BoardManagerReworked.Instance.IsValidCoordinate(new Vector3(x, y, z))) { if (BoardManagerReworked.Instance.Pieces[x, y, z] != null) { if (isWhite) { if (BoardManagerReworked.Instance.Pieces[x, y, z].GETPieceCode() == 'p') { Debug.Log(((Pawn)BoardManagerReworked.Instance.Pieces[x, y, z]).doubleMoved); Debug.Log(BoardManagerReworked.Instance.Pieces[x, y, z].roundMoved == BoardManagerReworked.Instance.roundNumber - 1); Debug.Log(BoardManagerReworked.Instance.Pieces[x, y, z + forward] == null); Debug.Log(BoardManagerReworked.Instance.Pieces[x, y, z].roundMoved - 1); if (((Pawn)BoardManagerReworked.Instance.Pieces[x, y, z]).doubleMoved && BoardManagerReworked.Instance.Pieces[x, y, z].roundMoved == BoardManagerReworked.Instance.roundNumber - 1 && BoardManagerReworked.Instance.Pieces[x, y, z + forward] == null) { r[x, y, z + forward] = true; } } } else { if (BoardManagerReworked.Instance.Pieces[x, y, z].GETPieceCode() == 'P') { Debug.Log("asd"); if (((Pawn)BoardManagerReworked.Instance.Pieces[x, y, z]).doubleMoved && BoardManagerReworked.Instance.Pieces[x, y, z].roundMoved == BoardManagerReworked.Instance.roundNumber - 1 && BoardManagerReworked.Instance.Pieces[x, y, z + forward] == null) { Debug.Log("asd"); r[x, y, z + forward] = true; } } } } } /* * //White team moves * if (isWhite) * { * //Diagonal Left (Piece not on the left of the board and not in the end) * if ((int) position.x != 0 && (int) position.z != 7) * { * c = BoardManagerReworked.Instance.Pieces[(int) position.x - 1, (int) position.y, (int) position.z + 1]; * * //Diagonal left same board * if (c != null && !c.isWhite) r[(int) position.x - 1, (int) position.y, (int) position.z + 1] = true; * * //Diagonal left lower board * if ((int) position.y != 0) * { * c = BoardManagerReworked.Instance.Pieces[(int) position.x - 1, (int) position.y - 1, * (int) position.z + 1]; * if (c != null && !c.isWhite) * r[(int) position.x - 1, (int) position.y - 1, (int) position.z + 1] = true; * } * * //Diagonal left higher board * if ((int) position.y != 2) * { * c = BoardManagerReworked.Instance.Pieces[(int) position.x - 1, (int) position.y + 1, * (int) position.z + 1]; * if (c != null && !c.isWhite) * r[(int) position.x - 1, (int) position.y + 1, (int) position.z + 1] = true; * } * } * * //Diagonal Right * if ((int) position.x != 7 && (int) position.z != 7) * { * c = BoardManagerReworked.Instance.Pieces[(int) position.x + 1, (int) position.y, (int) position.z + 1]; * * //Diagonal right same board * if (c != null && !c.isWhite) r[(int) position.x + 1, (int) position.y, (int) position.z + 1] = true; * * //Diagonal right lower board * if ((int) position.y != 0) * { * c = BoardManagerReworked.Instance.Pieces[(int) position.x + 1, (int) position.y - 1, * (int) position.z + 1]; * if (c != null && !c.isWhite) * r[(int) position.x + 1, (int) position.y - 1, (int) position.z + 1] = true; * } * * //Diagonal right higher board * if ((int) position.y != 2) * { * c = BoardManagerReworked.Instance.Pieces[(int) position.x + 1, (int) position.y + 1, * (int) position.z + 1]; * if (c != null && !c.isWhite) * r[(int) position.x + 1, (int) position.y + 1, (int) position.z + 1] = true; * } * } * * //Middle * if ((int) position.z != 7) * { * c = BoardManagerReworked.Instance.Pieces[(int) position.x, (int) position.y, (int) position.z + 1]; * if (c == null) r[(int) position.x, (int) position.y, (int) position.z + 1] = true; * * if ((int) position.y != 0) * { * c = BoardManagerReworked.Instance.Pieces[(int) position.x, (int) position.y - 1, * (int) position.z + 1]; * if (c == null) r[(int) position.x, (int) position.y - 1, (int) position.z + 1] = true; * * c = BoardManagerReworked.Instance.Pieces[(int) position.x, (int) position.y - 1, (int) position.z]; * if (c == null) r[(int) position.x, (int) position.y - 1, (int) position.z] = true; * } * * if ((int) position.y != 2) * { * c = BoardManagerReworked.Instance.Pieces[(int) position.x, (int) position.y + 1, * (int) position.z + 1]; * if (c == null) r[(int) position.x, (int) position.y + 1, (int) position.z + 1] = true; * c = BoardManagerReworked.Instance.Pieces[(int) position.x, (int) position.y + 1, (int) position.z]; * if (c == null) r[(int) position.x, (int) position.y + 1, (int) position.z] = true; * } * } * * //Middle on first move * if ((int) position.z == 1) * { * r[(int) position.x, (int) position.y, (int) position.z + 2] = true; * r[(int) position.x, 2, (int) position.z] = true; * r[(int) position.x, 2, (int) position.z + 2] = true; * } * * //Check left and right * //c = BoardManagerReworked.Instance.Pieces[(int) position.x + 1, (int) position.y, (int) position.z]; * int x, y, z; * x = (int) position.x; * y = (int) position.y; * z = (int) position.z; * x += 1; * if (BoardManagerReworked.Instance.IsValidCoordinate(new Vector3(x,y,z))) * { * * c = BoardManagerReworked.Instance.Pieces[x,y,z]; * if (c != null && !c.isWhite && c.GETPieceCode() == 'p') * { * Pawn temp = (Pawn) BoardManagerReworked.Instance.Pieces[x, y, z]; * if ( temp.roundMoved -1 == BoardManagerReworked.Instance.roundNumber && temp.doubleMoved) * { * r[x, y, z + 1] = true; * } * * } * } * x = (int) position.x; * y = (int) position.y; * z = (int) position.z; * x -= 1; * if (BoardManagerReworked.Instance.IsValidCoordinate(new Vector3(x,y,z))) * { * * c = BoardManagerReworked.Instance.Pieces[x,y,z]; * if (c != null && !c.isWhite && c.GETPieceCode() == 'p') * { * Pawn temp = (Pawn) BoardManagerReworked.Instance.Pieces[x, y, z]; * if ( temp.roundMoved -1 == BoardManagerReworked.Instance.roundNumber && temp.doubleMoved) * { * r[x, y, z + 1] = true; * } * * } * } * * * * } * else //Black team moves * { * //Diagonal Left (Piece not on the left of the board and not in the end) * if ((int) position.x != 0 && (int) position.z != 0) * { * c = BoardManagerReworked.Instance.Pieces[(int) position.x - 1, (int) position.y, (int) position.z - 1]; * * //Diagonal left same board * if (c != null && c.isWhite) r[(int) position.x - 1, (int) position.y, (int) position.z - 1] = true; * //Diagonal left lower board * if ((int) position.y != 0) * { * c = BoardManagerReworked.Instance.Pieces[(int) position.x - 1, (int) position.y - 1, * (int) position.z - 1]; * if (c != null && c.isWhite) * r[(int) position.x - 1, (int) position.y - 1, (int) position.z - 1] = true; * } * * //Diagonal left higher board * if ((int) position.y != 2) * { * c = BoardManagerReworked.Instance.Pieces[(int) position.x - 1, (int) position.y + 1, * (int) position.z - 1]; * if (c != null && c.isWhite) * r[(int) position.x - 1, (int) position.y + 1, (int) position.z - 1] = true; * } * } * * //Diagonal Right * if ((int) position.x != 7 && (int) position.z != 0) * { * c = BoardManagerReworked.Instance.Pieces[(int) position.x + 1, (int) position.y, (int) position.z - 1]; * //Diagonal right same board * if (c != null && c.isWhite) r[(int) position.x + 1, (int) position.y, (int) position.z - 1] = true; * //Diagonal right lower board * if ((int) position.y != 0) * { * c = BoardManagerReworked.Instance.Pieces[(int) position.x + 1, (int) position.y - 1, * (int) position.z - 1]; * if (c != null && c.isWhite) * r[(int) position.x + 1, (int) position.y - 1, (int) position.z - 1] = true; * } * * //Diagonal right higher board * if ((int) position.y != 2) * { * c = BoardManagerReworked.Instance.Pieces[(int) position.x + 1, (int) position.y + 1, * (int) position.z - 1]; * if (c != null && c.isWhite) * r[(int) position.x + 1, (int) position.y + 1, (int) position.z - 1] = true; * } * } * * //Middle * if ((int) position.z != 0) * { * c = BoardManagerReworked.Instance.Pieces[(int) position.x, (int) position.y, (int) position.z - 1]; * if (c == null) r[(int) position.x, (int) position.y, (int) position.z - 1] = true; * * if ((int) position.y != 0) * { * c = BoardManagerReworked.Instance.Pieces[(int) position.x, (int) position.y - 1, * (int) position.z - 1]; * if (c == null) r[(int) position.x, (int) position.y - 1, (int) position.z - 1] = true; * * c = BoardManagerReworked.Instance.Pieces[(int) position.x, (int) position.y - 1, (int) position.z]; * if (c == null) r[(int) position.x, (int) position.y - 1, (int) position.z] = true; * } * * if ((int) position.y != 2) * { * c = BoardManagerReworked.Instance.Pieces[(int) position.x, (int) position.y + 1, * (int) position.z - 1]; * if (c == null) r[(int) position.x, (int) position.y + 1, (int) position.z - 1] = true; * c = BoardManagerReworked.Instance.Pieces[(int) position.x, (int) position.y + 1, (int) position.z]; * if (c == null) r[(int) position.x, (int) position.y + 1, (int) position.z] = true; * } * } * * //Middle on first move * if ((int) position.z == 6) * { * r[(int) position.x, (int) position.y, (int) position.z - 2] = true; * r[(int) position.x, 0, (int) position.z] = true; * r[(int) position.x, 0, (int) position.z - 2] = true; * } * * int x, y, z; * x = (int) position.x; * y = (int) position.y; * z = (int) position.z; * x += 1; * if (BoardManagerReworked.Instance.IsValidCoordinate(new Vector3(x,y,z))) * { * c = BoardManagerReworked.Instance.Pieces[x,y,z]; * if (c != null && c.isWhite && c.GETPieceCode() == 'P') * { * Debug.Log("asd2"); * Pawn temp = (Pawn) BoardManagerReworked.Instance.Pieces[x, y, z]; * if ( temp.roundMoved -1 == BoardManagerReworked.Instance.roundNumber && temp.doubleMoved) * { * r[x, y, z - 1] = true; * } * * } * } * x = (int) position.x; * y = (int) position.y; * z = (int) position.z; * x -= 1; * if (BoardManagerReworked.Instance.IsValidCoordinate(new Vector3(x,y,z))) * { * Debug.Log("asd1"); * c = BoardManagerReworked.Instance.Pieces[x,y,z]; * if (c != null && c.isWhite && c.GETPieceCode() == 'P') * { * Pawn temp = (Pawn) BoardManagerReworked.Instance.Pieces[x, y, z]; * if ( temp.roundMoved -1 == BoardManagerReworked.Instance.roundNumber && temp.doubleMoved) * { * r[x, y, z - 1] = true; * } * * } * } * } */ return(r); }
// 0 = NONE / 1 = 揃っている / 2 = 未実装 / 3 = 置く場所がなく引き分け を返す public int GameCheck(Piece[, ,] pieceArrayCheck) { PieceType checkPieceType = PieceType.Initial; int checkPieceCount = 0; // 置ける場所が残っているかチェック List <Piece> putableListCheck = new List <Piece> (); for (int z = 0; z < 4; z++) { for (int x = 0; x < 4; x++) { for (int y = 0; y < 4; y++) { if (pieceArray [x, y, z].pieceType == PieceType.None) { // 何も置かれていない場合は置ける場所のリストに加える putableListCheck.Add(pieceArray[x, y, z]); break; } } } } // 置ける場所が残っていない場合、引き分け if (putableListCheck.Count == 0) { return(3); } // 縦のチェック for (int x = 0; x < 4; x++) { for (int y = 0; y < 4; y++) { for (int z = 0; z < 4; z++) { if (z == 0) { checkPieceType = pieceArrayCheck [x, y, z].pieceType; checkPieceCount = 0; if (checkPieceType == PieceType.None) { break; } } else { if (checkPieceType == pieceArrayCheck [x, y, z].pieceType) { checkPieceCount++; if (checkPieceType == pieceArrayCheck [x, y, z].pieceType && checkPieceCount == 3) { return(1); } } else { break; } } } } } // 横のチェック for (int z = 0; z < 4; z++) { for (int y = 0; y < 4; y++) { for (int x = 0; x < 4; x++) { if (x == 0) { checkPieceType = pieceArrayCheck [x, y, z].pieceType; checkPieceCount = 0; if (checkPieceType == PieceType.None) { break; } } else { if (checkPieceType == pieceArrayCheck [x, y, z].pieceType) { checkPieceCount++; if (checkPieceType == pieceArrayCheck [x, y, z].pieceType && checkPieceCount == 3) { return(1); } } else { break; } } } } } // 高さのチェック for (int x = 0; x < 4; x++) { for (int z = 0; z < 4; z++) { for (int y = 0; y < 4; y++) { if (y == 0) { checkPieceType = pieceArrayCheck [x, y, z].pieceType; checkPieceCount = 1; if (checkPieceType == PieceType.None) { break; } } else { if (checkPieceType == pieceArrayCheck [x, y, z].pieceType) { checkPieceCount++; if (checkPieceType == pieceArrayCheck [x, y, z].pieceType && checkPieceCount == 3) { return(1); } } else { break; } } } } } // 左下から右上に斜め。Z(奥行をずらしていく) for (int z = 0; z < 4; z++) { checkPieceType = pieceArrayCheck [0, 0, z].pieceType; if (checkPieceType == PieceType.None) { continue; } if (checkPieceType == pieceArrayCheck [1, 1, z].pieceType && checkPieceType == pieceArrayCheck [2, 2, z].pieceType && checkPieceType == pieceArrayCheck [3, 3, z].pieceType) { return(1); } } // 右下から左上に斜め。Z(奥行をずらしていく) for (int z = 0; z < 4; z++) { checkPieceType = pieceArrayCheck [3, 0, z].pieceType; if (checkPieceType == PieceType.None) { continue; } if (checkPieceType == pieceArrayCheck [2, 1, z].pieceType && checkPieceType == pieceArrayCheck [1, 2, z].pieceType && checkPieceType == pieceArrayCheck [0, 3, z].pieceType) { return(1); } } // 左下手前から左奥に斜め。X(横方向をずらしていく) for (int x = 0; x < 4; x++) { checkPieceType = pieceArrayCheck [x, 0, 0].pieceType; if (checkPieceType == PieceType.None) { continue; } if (checkPieceType == pieceArrayCheck [x, 1, 1].pieceType && checkPieceType == pieceArrayCheck [x, 2, 2].pieceType && checkPieceType == pieceArrayCheck [x, 3, 3].pieceType) { return(1); } } // 左下奥から左手前に斜め。X(横方向をずらしていく) for (int x = 0; x < 4; x++) { checkPieceType = pieceArrayCheck [x, 0, 3].pieceType; if (checkPieceType == PieceType.None) { continue; } if (checkPieceType == pieceArrayCheck [x, 1, 2].pieceType && checkPieceType == pieceArrayCheck [x, 2, 1].pieceType && checkPieceType == pieceArrayCheck [x, 3, 0].pieceType) { return(1); } } // 左下からクロス。Y(高さをずらしていく) for (int y = 0; y < 4; y++) { checkPieceType = pieceArrayCheck [0, y, 0].pieceType; if (checkPieceType == PieceType.None) { continue; } if (checkPieceType == pieceArrayCheck [1, y, 1].pieceType && checkPieceType == pieceArrayCheck [2, y, 2].pieceType && checkPieceType == pieceArrayCheck [3, y, 3].pieceType) { return(1); } } // 右下からクロス。Y(高さをずらしていく) for (int y = 0; y < 4; y++) { checkPieceType = pieceArrayCheck [3, y, 0].pieceType; if (checkPieceType == PieceType.None) { continue; } if (checkPieceType == pieceArrayCheck [2, y, 1].pieceType && checkPieceType == pieceArrayCheck [1, y, 2].pieceType && checkPieceType == pieceArrayCheck [0, y, 3].pieceType) { return(1); } } // 左手前下から右奥上に斜めクロス checkPieceType = pieceArrayCheck [0, 0, 0].pieceType; if (checkPieceType != PieceType.None) { if (checkPieceType == pieceArrayCheck [1, 1, 1].pieceType && checkPieceType == pieceArrayCheck [2, 2, 2].pieceType && checkPieceType == pieceArrayCheck [3, 3, 3].pieceType) { return(1); } } // 右手前下から左奥上に斜めクロス checkPieceType = pieceArrayCheck [3, 0, 0].pieceType; if (checkPieceType != PieceType.None) { if (checkPieceType == pieceArrayCheck [2, 1, 1].pieceType && checkPieceType == pieceArrayCheck [1, 2, 2].pieceType && checkPieceType == pieceArrayCheck [0, 3, 3].pieceType) { return(1); } } // 左奥下から右手前上に斜めクロス checkPieceType = pieceArray [0, 0, 3].pieceType; if (checkPieceType != PieceType.None) { if (checkPieceType == pieceArrayCheck [1, 1, 2].pieceType && checkPieceType == pieceArrayCheck [2, 2, 1].pieceType && checkPieceType == pieceArrayCheck [3, 3, 0].pieceType) { return(1); } } // 右奥下から左手前上に斜めクロス checkPieceType = pieceArrayCheck [3, 0, 3].pieceType; if (checkPieceType != PieceType.None) { if (checkPieceType == pieceArrayCheck [2, 1, 2].pieceType && checkPieceType == pieceArrayCheck [1, 2, 1].pieceType && checkPieceType == pieceArrayCheck [0, 3, 0].pieceType) { return(1); } } return(0); }
public override bool[,,] PossibleMove(Piece[,,] positions) { var r = new bool[8, 3, 8]; int oX, oY, oZ; oX = (int)position.x; oY = (int)position.y; oZ = (int)position.z; Piece c; int i; //Move right i = (int)position.x; while (true) { i++; if (i >= 8) { break; } c = BoardManagerReworked.Instance.Pieces[i, (int)position.y, (int)position.z]; if (c == null) { r[i, (int)position.y, (int)position.z] = true; } else { if (c.isWhite != isWhite) { r[i, (int)position.y, (int)position.z] = true; } break; } } //Move left i = (int)position.x; while (true) { i--; if (i == -1) { break; } c = BoardManagerReworked.Instance.Pieces[i, (int)position.y, (int)position.z]; if (c == null) { r[i, (int)position.y, (int)position.z] = true; } else { if (c.isWhite != isWhite) { r[i, (int)position.y, (int)position.z] = true; } break; } } //Move forward i = (int)position.z; while (true) { i++; if (i == 8) { break; } c = BoardManagerReworked.Instance.Pieces[(int)position.x, (int)position.y, i]; if (c == null) { r[(int)position.x, (int)position.y, i] = true; } else { if (c.isWhite != isWhite) { r[(int)position.x, (int)position.y, i] = true; } break; } } //Move backward i = (int)position.z; while (true) { i--; if (i == -1) { break; } c = BoardManagerReworked.Instance.Pieces[(int)position.x, (int)position.y, i]; if (c == null) { r[(int)position.x, (int)position.y, i] = true; } else { if (c.isWhite != isWhite) { r[(int)position.x, (int)position.y, i] = true; } break; } } //Move up i = (int)position.y; while (true) { i++; if (i == 3) { break; } c = BoardManagerReworked.Instance.Pieces[(int)position.x, i, (int)position.z]; if (c == null) { r[(int)position.x, i, (int)position.z] = true; } else { if (c.isWhite != isWhite) { r[(int)position.x, i, (int)position.z] = true; } break; } } //Move down i = (int)position.y; while (true) { i--; if (i == -1) { break; } c = BoardManagerReworked.Instance.Pieces[(int)position.x, i, (int)position.z]; if (c == null) { r[(int)position.x, i, (int)position.z] = true; } else { if (c.isWhite != isWhite) { r[(int)position.x, i, (int)position.z] = true; } break; } } //Move in diagonal1 up RookMove((int)position.x + 1, (int)position.y + 1, (int)position.z, ref r); RookMove((int)position.x - 1, (int)position.y + 1, (int)position.z, ref r); RookMove((int)position.x, (int)position.y + 1, (int)position.z + 1, ref r); RookMove((int)position.x, (int)position.y + 1, (int)position.z - 1, ref r); //Move in diagonal2 up RookMove((int)position.x + 2, (int)position.y + 2, (int)position.z, ref r); RookMove((int)position.x - 2, (int)position.y + 2, (int)position.z, ref r); RookMove((int)position.x, (int)position.y + 2, (int)position.z + 2, ref r); RookMove((int)position.x, (int)position.y + 2, (int)position.z - 2, ref r); //Move in diagonal1 down RookMove((int)position.x + 1, (int)position.y - 1, (int)position.z, ref r); RookMove((int)position.x - 1, (int)position.y - 1, (int)position.z, ref r); RookMove((int)position.x, (int)position.y - 1, (int)position.z + 1, ref r); RookMove((int)position.x, (int)position.y - 1, (int)position.z - 1, ref r); //Move in diagonal2 down RookMove((int)position.x + 2, (int)position.y - 2, (int)position.z, ref r); RookMove((int)position.x - 2, (int)position.y - 2, (int)position.z, ref r); RookMove((int)position.x, (int)position.y - 2, (int)position.z + 2, ref r); RookMove((int)position.x, (int)position.y - 2, (int)position.z - 2, ref r); return(r); }
//Returns an array of possible moves public virtual bool[,,] PossibleMove(Piece[,,] positions) { return(new bool[8, 3, 8]); }
public CubeChangedEventArgs(Piece[,,] pieces) { Pieces = pieces; }
public override bool[,,] PossibleMove(Piece[,,] positions) { var r = new bool[8, 3, 8]; //ForwardLeft KnightMove((int)position.x - 1, (int)position.y, (int)position.z + 2, position, ref r, positions); //ForwardRight KnightMove((int)position.x + 1, (int)position.y, (int)position.z + 2, position, ref r, positions); //LeftForward KnightMove((int)position.x - 2, (int)position.y, (int)position.z + 1, position, ref r, positions); //LeftBackward KnightMove((int)position.x - 2, (int)position.y, (int)position.z - 1, position, ref r, positions); //BackwardLeft KnightMove((int)position.x - 1, (int)position.y, (int)position.z - 2, position, ref r, positions); //BackwardRight KnightMove((int)position.x + 1, (int)position.y, (int)position.z - 2, position, ref r, positions); //RightForward KnightMove((int)position.x + 2, (int)position.y, (int)position.z + 1, position, ref r, positions); //RightBackward KnightMove((int)position.x + 2, (int)position.y, (int)position.z - 1, position, ref r, positions); //ForwardUp KnightMove((int)position.x, (int)position.y + 1, (int)position.z + 2, position, ref r, positions); //RightUp KnightMove((int)position.x + 2, (int)position.y + 1, (int)position.z, position, ref r, positions); //LeftUp KnightMove((int)position.x - 2, (int)position.y + 1, (int)position.z, position, ref r, positions); //BackwardUp KnightMove((int)position.x, (int)position.y + 1, (int)position.z - 2, position, ref r, positions); //ForwardDown KnightMove((int)position.x, (int)position.y - 1, (int)position.z + 2, position, ref r, positions); //RightDown KnightMove((int)position.x + 2, (int)position.y - 1, (int)position.z, position, ref r, positions); //LeftDown KnightMove((int)position.x - 2, (int)position.y - 1, (int)position.z, position, ref r, positions); //BackwardDown KnightMove((int)position.x, (int)position.y - 1, (int)position.z - 2, position, ref r, positions); //ForwardUp2 KnightMove((int)position.x, (int)position.y + 2, (int)position.z + 1, position, ref r, positions); //RightUp2 KnightMove((int)position.x + 1, (int)position.y + 2, (int)position.z, position, ref r, positions); //LeftUp2 KnightMove((int)position.x - 1, (int)position.y + 2, (int)position.z, position, ref r, positions); //BackwardUp2 KnightMove((int)position.x, (int)position.y + 2, (int)position.z - 1, position, ref r, positions); //ForwardDown2 KnightMove((int)position.x, (int)position.y - 2, (int)position.z + 1, position, ref r, positions); //RightDown2 KnightMove((int)position.x + 1, (int)position.y - 2, (int)position.z, position, ref r, positions); //LeftDown2 KnightMove((int)position.x - 1, (int)position.y - 2, (int)position.z, position, ref r, positions); //BackwardDown2 KnightMove((int)position.x, (int)position.y - 2, (int)position.z - 1, position, ref r, positions); return(r); }
//Basically a crtl + c of bishop and rooks move public override bool[,,] PossibleMove(Piece[,,] positions) { var r = new bool[8, 3, 8]; Piece c; int i; //Move right i = (int)position.x; while (true) { i++; if (i >= 8) { break; } c = BoardManagerReworked.Instance.Pieces[i, (int)position.y, (int)position.z]; if (c == null) { r[i, (int)position.y, (int)position.z] = true; } else { if (c.isWhite != isWhite) { r[i, (int)position.y, (int)position.z] = true; } break; } } //Move left i = (int)position.x; while (true) { i--; if (i == -1) { break; } c = BoardManagerReworked.Instance.Pieces[i, (int)position.y, (int)position.z]; if (c == null) { r[i, (int)position.y, (int)position.z] = true; } else { if (c.isWhite != isWhite) { r[i, (int)position.y, (int)position.z] = true; } break; } } //Move forward i = (int)position.z; while (true) { i++; if (i == 8) { break; } c = BoardManagerReworked.Instance.Pieces[(int)position.x, (int)position.y, i]; if (c == null) { r[(int)position.x, (int)position.y, i] = true; } else { if (c.isWhite != isWhite) { r[(int)position.x, (int)position.y, i] = true; } break; } } //Move backward i = (int)position.z; while (true) { i--; if (i == -1) { break; } c = BoardManagerReworked.Instance.Pieces[(int)position.x, (int)position.y, i]; if (c == null) { r[(int)position.x, (int)position.y, i] = true; } else { if (c.isWhite != isWhite) { r[(int)position.x, (int)position.y, i] = true; } break; } } //Move up i = (int)position.y; while (true) { i++; if (i == 3) { break; } c = BoardManagerReworked.Instance.Pieces[(int)position.x, i, (int)position.z]; if (c == null) { r[(int)position.x, i, (int)position.z] = true; } else { if (c.isWhite != isWhite) { r[(int)position.x, i, (int)position.z] = true; } break; } } //Move down i = (int)position.y; while (true) { i--; if (i == -1) { break; } c = BoardManagerReworked.Instance.Pieces[(int)position.x, i, (int)position.z]; if (c == null) { r[(int)position.x, i, (int)position.z] = true; } else { if (c.isWhite != isWhite) { r[(int)position.x, i, (int)position.z] = true; } break; } } //Move in diagonal1 up RookMove((int)position.x + 1, (int)position.y + 1, (int)position.z, ref r); RookMove((int)position.x - 1, (int)position.y + 1, (int)position.z, ref r); RookMove((int)position.x, (int)position.y + 1, (int)position.z + 1, ref r); RookMove((int)position.x, (int)position.y + 1, (int)position.z - 1, ref r); //Move in diagonal2 up RookMove((int)position.x + 2, (int)position.y + 2, (int)position.z, ref r); RookMove((int)position.x - 2, (int)position.y + 2, (int)position.z, ref r); RookMove((int)position.x, (int)position.y + 2, (int)position.z + 2, ref r); RookMove((int)position.x, (int)position.y + 2, (int)position.z - 2, ref r); //Move in diagonal1 down RookMove((int)position.x + 1, (int)position.y - 1, (int)position.z, ref r); RookMove((int)position.x - 1, (int)position.y - 1, (int)position.z, ref r); RookMove((int)position.x, (int)position.y - 1, (int)position.z + 1, ref r); RookMove((int)position.x, (int)position.y - 1, (int)position.z - 1, ref r); //Move in diagonal2 down RookMove((int)position.x + 2, (int)position.y - 2, (int)position.z, ref r); RookMove((int)position.x - 2, (int)position.y - 2, (int)position.z, ref r); RookMove((int)position.x, (int)position.y - 2, (int)position.z + 2, ref r); RookMove((int)position.x, (int)position.y - 2, (int)position.z - 2, ref r); int j; //Forward Left i = (int)position.x; j = (int)position.z; while (true) { i--; j++; if (i < 0 || j == 8) { break; } c = BoardManagerReworked.Instance.Pieces[i, (int)position.y, j]; if (c == null) { r[i, (int)position.y, j] = true; } else { if (isWhite != c.isWhite) { r[i, (int)position.y, j] = true; } break; } } //Forward Right i = (int)position.x; j = (int)position.z; while (true) { i++; j++; if (i == 8 || j == 8) { break; } c = BoardManagerReworked.Instance.Pieces[i, (int)position.y, j]; if (c == null) { r[i, (int)position.y, j] = true; } else { if (isWhite != c.isWhite) { r[i, (int)position.y, j] = true; } break; } } //Backward Left i = (int)position.x; j = (int)position.z; while (true) { i--; j--; if (i == -1 || j == -1) { break; } c = BoardManagerReworked.Instance.Pieces[i, (int)position.y, j]; if (c == null) { r[i, (int)position.y, j] = true; } else { if (isWhite != c.isWhite) { r[i, (int)position.y, j] = true; } break; } } //Backward Right i = (int)position.x; j = (int)position.z; while (true) { i++; j--; if (i == 8 || j == -1) { break; } c = BoardManagerReworked.Instance.Pieces[i, (int)position.y, j]; if (c == null) { r[i, (int)position.y, j] = true; } else { if (isWhite != c.isWhite) { r[i, (int)position.y, j] = true; } break; } } int k; //Forward Left Up i = (int)position.x; j = (int)position.z; k = (int)position.y; while (true) { i--; j++; k++; if (i < 0 || j == 8 || k == 3) { break; } c = BoardManagerReworked.Instance.Pieces[i, k, j]; if (c == null) { r[i, k, j] = true; } else { if (isWhite != c.isWhite) { r[i, k, j] = true; } break; } } //Forward Right Up i = (int)position.x; j = (int)position.z; k = (int)position.y; while (true) { i++; j++; k++; if (i == 8 || j == 8 || k == 3) { break; } c = BoardManagerReworked.Instance.Pieces[i, k, j]; if (c == null) { r[i, k, j] = true; } else { if (isWhite != c.isWhite) { r[i, k, j] = true; } break; } } //Backward Left Up i = (int)position.x; j = (int)position.z; k = (int)position.y; while (true) { i--; j--; k++; if (i < 0 || j < 0 || k == 3) { break; } c = BoardManagerReworked.Instance.Pieces[i, k, j]; if (c == null) { r[i, k, j] = true; } else { if (isWhite != c.isWhite) { r[i, k, j] = true; } break; } } //Backward Right Up i = (int)position.x; j = (int)position.z; k = (int)position.y; while (true) { i++; j--; k++; if (i == 8 || j < 0 || k == 3) { break; } c = BoardManagerReworked.Instance.Pieces[i, k, j]; if (c == null) { r[i, k, j] = true; } else { if (isWhite != c.isWhite) { r[i, k, j] = true; } break; } } //Forward Left Down i = (int)position.x; j = (int)position.z; k = (int)position.y; while (true) { i--; j++; k--; if (i < 0 || j == 8 || k < 0) { break; } c = BoardManagerReworked.Instance.Pieces[i, k, j]; if (c == null) { r[i, k, j] = true; } else { if (isWhite != c.isWhite) { r[i, k, j] = true; } break; } } //Forward Right Down i = (int)position.x; j = (int)position.z; k = (int)position.y; while (true) { i++; j++; k--; if (i == 8 || j == 8 || k < 0) { break; } c = BoardManagerReworked.Instance.Pieces[i, k, j]; if (c == null) { r[i, k, j] = true; } else { if (isWhite != c.isWhite) { r[i, k, j] = true; } break; } } //Backward Left Down i = (int)position.x; j = (int)position.z; k = (int)position.y; while (true) { i--; j--; k--; if (i < 0 || j < 0 || k < 0) { break; } c = BoardManagerReworked.Instance.Pieces[i, k, j]; if (c == null) { r[i, k, j] = true; } else { if (isWhite != c.isWhite) { r[i, k, j] = true; } break; } } //Backward Right down i = (int)position.x; j = (int)position.z; k = (int)position.y; while (true) { i++; j--; k--; if (i == 8 || j < 0 || k < 0) { break; } c = BoardManagerReworked.Instance.Pieces[i, k, j]; if (c == null) { r[i, k, j] = true; } else { if (isWhite != c.isWhite) { r[i, k, j] = true; } break; } } return(r); }
public void CpuLogic() { // 現在の状況をコピーする pieceArrayNow = new Piece[GameController.pieceXCount, GameController.pieceYCount, GameController.pieceZCount]; Array.Copy(gameController.pieceArray, pieceArrayNow, gameController.pieceArray.Length); //piecePointsを全て0にする for (int x = 0; x < 4; x++) { for (int y = 0; y < 4; y++) { for (int z = 0; z < 4; z++) { piecePointsArray [x, y, z].cpuPiecePoints = 0; } } } // 最初、CPUのPieceTypeを取得し、シミュレーションで手番を入れ替える変数 pieceTypeForCpuLogic = gameController.order; // 次の一手を置ける場所を取得(実際に置く場所の候補) // ※ここ間違えてる List <Piece> firstPutableList = getPutableList(pieceArrayNow); // for (int z = 0; z < 4; z++) { // for (int x = 0; x < 4; x++) { // for (int y = 0; y < 4; y++) { // Debug.Log (x +"/"+ y +"/"+ z +"="+ pieceArrayNow [x, y, z].pieceType); // } // } // } // デバッグ // for (int test = 0; test < firstPutableList.Count; test++) { // Debug.Log (firstPutableList [test].xIndex +"/"+ firstPutableList [test].yIndex +"/"+ firstPutableList [test].zIndex); // } // もし置けるところがなかった場合、終了(ゲームが終了しているはずなので基本的にはないはず) if (firstPutableList.Count == 0) { return; } // リストから抽出して1つ目の位置を順番に処理していく(最大16箇所) for (int i = 0; i < firstPutableList.Count; i++) { // PieceArrayをPieceArrayNowにコピーして、現在の状況と一致させる Array.Copy(gameController.pieceArray, pieceArrayNow, gameController.pieceArray.Length); Piece firstPutablePiece = firstPutableList [i]; // PieceArrayNowから1つ目に置くコマを選択 pieceArrayNow[firstPutablePiece.xIndex, firstPutablePiece.yIndex, firstPutablePiece.zIndex].SetPieceType(pieceTypeForCpuLogic); // 4つ揃っているか判定して揃ってた場合、piecePointsに+1する // 0 = NONE / 1 = 揃っている if (gameController.GameCheck(pieceArrayNow) == 1) { piecePointsArray [firstPutablePiece.xIndex, firstPutablePiece.yIndex, firstPutablePiece.zIndex].cpuPiecePoints++; continue; } // ターンを変更する if (pieceTypeForCpuLogic == PieceType.Black) { pieceTypeForCpuLogic = PieceType.White; } else if (pieceTypeForCpuLogic == PieceType.White) { pieceTypeForCpuLogic = PieceType.Black; } // 2個目以降はランダム // CpuSimulationはPlayerターンからスタートする // CpuSimulation戻り値いるくね? CpuSimulation(firstPutablePiece.xIndex, firstPutablePiece.yIndex, firstPutablePiece.zIndex); } // 勝率が100%のところがあった場合、CPUレベルに関係なく置いて関数を抜ける for (int x = 0; x < 4; x++) { for (int y = 0; y < 4; y++) { for (int z = 0; z < 4; z++) { if (piecePointsArray [x, y, z].cpuPiecePoints == cpuThoughtNumber) { putPiece(cpuPieceType, x, y, z); return; } } } } // Listを作ってListに入れ、ソート List <PiecePoints> piecePointsList = new List <PiecePoints> (); for (int z = 0; z < 4; z++) { for (int x = 0; x < 4; x++) { for (int y = 0; y < 4; y++) { piecePointsList.Add(piecePointsArray[x, y, z]); } } } piecePointsList.Sort((a, b) => b.cpuPiecePoints - a.cpuPiecePoints); // CPUのレベルに応じて置く場所を決定 switch (cpuLevel) { case 1: putPiece(cpuPieceType, piecePointsList[2].pointXindex, piecePointsList[2].pointYindex, piecePointsList[2].pointZindex); break; case 2: putPiece(cpuPieceType, piecePointsList[1].pointXindex, piecePointsList[1].pointYindex, piecePointsList[1].pointZindex); break; case 3: putPiece(cpuPieceType, piecePointsList[0].pointXindex, piecePointsList[0].pointYindex, piecePointsList[0].pointZindex); break; default: Debug.Log("エラー:" + cpuLevel); break; } // 実際に置く // ここよくわからん // PieceController controll = pieceObjArray [putablePiece.xIndex, putablePiece.yIndex, putablePiece.zIndex].GetComponent<PieceController>(); // controll.gameObject.SetActive(true); // controll.ShowPiece (); // controll.ChangeMaterial (pieceTypeForCpuLogic); }