質問編集履歴
2
関数についての説明を追記。
    
        title	
    CHANGED
    
    | 
            File without changes
         | 
    
        body	
    CHANGED
    
    | @@ -67,4 +67,6 @@ | |
| 67 67 | 
             
                        }  
         | 
| 68 68 | 
             
                }
         | 
| 69 69 | 
             
            }
         | 
| 70 | 
            -
            ```
         | 
| 70 | 
            +
            ```
         | 
| 71 | 
            +
             | 
| 72 | 
            +
            Max()という関数は領域中に振った値のうち最大値をとる点の座標を配列として取得する関数です。
         | 
1
コードを載せました。
    
        title	
    CHANGED
    
    | 
            File without changes
         | 
    
        body	
    CHANGED
    
    | @@ -7,4 +7,64 @@ | |
| 7 7 | 
             
            御助力お願いいたします。
         | 
| 8 8 |  | 
| 9 9 | 
             
            [ソースコード1](https://jsfiddle.net/justmeet0924/9dbaj1kr/1/show)
         | 
| 10 | 
            -
            [ソースコード2](https://jsfiddle.net/justmeet0924/0gxzuc2w/3/show)
         | 
| 10 | 
            +
            [ソースコード2](https://jsfiddle.net/justmeet0924/0gxzuc2w/3/show)
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            ※追記
         | 
| 13 | 
            +
            ```javascript
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            let wall_2 =[];
         | 
| 16 | 
            +
            for(let i=0; i<20; i++){
         | 
| 17 | 
            +
                wall_2[i] = [];
         | 
| 18 | 
            +
                for(let j=0; j<20; j++){
         | 
| 19 | 
            +
                    wall_2[i][j] = 0;
         | 
| 20 | 
            +
                }
         | 
| 21 | 
            +
            }
         | 
| 22 | 
            +
            for(let i=0; i<20; i++){
         | 
| 23 | 
            +
                wall_2[i][5] = 1;
         | 
| 24 | 
            +
            }
         | 
| 25 | 
            +
             | 
| 26 | 
            +
            for(let i=6; i<20; i++){
         | 
| 27 | 
            +
                wall_2[5][i] = 1;
         | 
| 28 | 
            +
            }
         | 
| 29 | 
            +
             | 
| 30 | 
            +
            wall_2[0][0] = 2;
         | 
| 31 | 
            +
            ```
         | 
| 32 | 
            +
             | 
| 33 | 
            +
            ```javascript
         | 
| 34 | 
            +
            function Max(array){
         | 
| 35 | 
            +
                points = []
         | 
| 36 | 
            +
                for(let i=0; i<20; i++){
         | 
| 37 | 
            +
                    for(let j=0; j<20; j++){
         | 
| 38 | 
            +
                        if(array[i][j] === Math.max(...(array.flat()))){
         | 
| 39 | 
            +
                            points.push([i,j])
         | 
| 40 | 
            +
                        }
         | 
| 41 | 
            +
                    }
         | 
| 42 | 
            +
                }
         | 
| 43 | 
            +
                return points;
         | 
| 44 | 
            +
            }
         | 
| 45 | 
            +
             | 
| 46 | 
            +
             | 
| 47 | 
            +
             | 
| 48 | 
            +
            function move_map(array){
         | 
| 49 | 
            +
                number = Math.max(...(array.flat()));
         | 
| 50 | 
            +
                console.log(number);
         | 
| 51 | 
            +
                console.log(Max(array));
         | 
| 52 | 
            +
                for(let i = 0; i < Max(array).length; i++){
         | 
| 53 | 
            +
                    X = Max(array)[i][0];
         | 
| 54 | 
            +
                    Y = Max(array)[i][1];
         | 
| 55 | 
            +
                    console.log([X,Y]);
         | 
| 56 | 
            +
                        if(X+1 <20 && array[X+1][Y] === 0){
         | 
| 57 | 
            +
                            array[X+1][Y] = number + 1;
         | 
| 58 | 
            +
                        }
         | 
| 59 | 
            +
                        if(-1 < X-1 && array[X-1][Y] === 0){
         | 
| 60 | 
            +
                            array[X-1][Y] = number + 1;
         | 
| 61 | 
            +
                        }
         | 
| 62 | 
            +
                        if(Y+1 <20 && array[X][Y+1] === 0){
         | 
| 63 | 
            +
                            array[X][Y+1] = number + 1;
         | 
| 64 | 
            +
                        }
         | 
| 65 | 
            +
                        if(-1 < Y-1 && array[X][Y-1] === 0){
         | 
| 66 | 
            +
                            array[X][Y-1] = number + 1;
         | 
| 67 | 
            +
                        }  
         | 
| 68 | 
            +
                }
         | 
| 69 | 
            +
            }
         | 
| 70 | 
            +
            ```
         | 
