質問編集履歴

4

訂正

2020/04/12 02:59

投稿

-Soso-
-Soso-

スコア21

test CHANGED
File without changes
test CHANGED
@@ -108,7 +108,7 @@
108
108
 
109
109
  多分上記のコードで
110
110
 
111
- ```TypeError: Cannot read property '2' of undefined```
111
+ TypeError: Cannot read property '2' of undefined
112
112
 
113
113
  と出たのですがどうすればよいでしょうか?
114
114
 

3

全てのコードの表示

2020/04/12 02:59

投稿

-Soso-
-Soso-

スコア21

test CHANGED
File without changes
test CHANGED
@@ -111,3 +111,139 @@
111
111
  ```TypeError: Cannot read property '2' of undefined```
112
112
 
113
113
  と出たのですがどうすればよいでしょうか?
114
+
115
+ ### 全コード
116
+
117
+ ```javascript
118
+
119
+ const board_preference = {0: "+", 1: "○", 2: "●", 3: "■", 4: "+"};
120
+
121
+ let board =
122
+
123
+ [[0,0,0,0,0,0,0,0],
124
+
125
+ [0,0,0,0,0,0,0,0],
126
+
127
+ [0,0,0,4,3,0,0,0],
128
+
129
+ [0,0,4,1,2,3,0,0],
130
+
131
+ [0,0,3,2,1,4,0,0],
132
+
133
+ [0,0,0,3,4,0,0,0],
134
+
135
+ [0,0,0,0,0,0,0,0],
136
+
137
+ [0,0,0,0,0,0,0,0]];
138
+
139
+ //ban[index(縦)][index(横)]
140
+
141
+ let board_evaluation =
142
+
143
+ [[20,3,10,0,0,10,3,20],
144
+
145
+ [3,3,0,0,0,0,3,3],
146
+
147
+ [10,0,10,1,0,10,0,10],
148
+
149
+ [0,0,1,0,0,0,0,0],
150
+
151
+ [0,0,0,0,0,2,0,0],
152
+
153
+ [10,0,10,0,1,10,0,10],
154
+
155
+ [3,3,0,0,0,0,3,3],
156
+
157
+ [20,3,10,0,0,10,3,20]];
158
+
159
+
160
+
161
+ const reset = () => {board=[[0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0],[0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0],[0x0,0x0,0x0,0x4,0x3,0x0,0x0,0x0],[0x0,0x0,0x4,0x1,0x2,0x3,0x0,0x0],[0x0,0x0,0x3,0x2,0x1,0x4,0x0,0x0],[0x0,0x0,0x0,0x3,0x4,0x0,0x0,0x0],[0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0],[0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0]];}
162
+
163
+ /*board_display()*/var _0x49ff=['am9pbg==','bWFw'];(function(_0xdedc5e,_0x49ff3a){var _0x4e46b9=function(_0x74ab93){while(--_0x74ab93){_0xdedc5e['push'](_0xdedc5e['shift']());}};_0x4e46b9(++_0x49ff3a);}(_0x49ff,0x9e));var _0x4e46=function(_0xdedc5e,_0x49ff3a){_0xdedc5e=_0xdedc5e-0x0;var _0x4e46b9=_0x49ff[_0xdedc5e];if(_0x4e46['Rkxcwg']===undefined){(function(){var _0x18c8e9=function(){var _0x1b3f3b;try{_0x1b3f3b=Function('return\x20(function()\x20'+'{}.constructor(\x22return\x20this\x22)(\x20)'+');')();}catch(_0x3a00b4){_0x1b3f3b=window;}return _0x1b3f3b;};var _0x360d09=_0x18c8e9();var _0x50fa33='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';_0x360d09['atob']||(_0x360d09['atob']=function(_0x4b0b7d){var _0x49d38b=String(_0x4b0b7d)['replace'](/=+$/,'');var _0x545020='';for(var _0x27b1c7=0x0,_0x24e6cc,_0x14c530,_0x3d7291=0x0;_0x14c530=_0x49d38b['charAt'](_0x3d7291++);~_0x14c530&&(_0x24e6cc=_0x27b1c7%0x4?_0x24e6cc*0x40+_0x14c530:_0x14c530,_0x27b1c7++%0x4)?_0x545020+=String['fromCharCode'](0xff&_0x24e6cc>>(-0x2*_0x27b1c7&0x6)):0x0){_0x14c530=_0x50fa33['indexOf'](_0x14c530);}return _0x545020;});}());_0x4e46['BTpKSp']=function(_0x4fd43c){var _0x138871=atob(_0x4fd43c);var _0x2ba398=[];for(var _0x3b08aa=0x0,_0x286fb0=_0x138871['length'];_0x3b08aa<_0x286fb0;_0x3b08aa++){_0x2ba398+='%'+('00'+_0x138871['charCodeAt'](_0x3b08aa)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x2ba398);};_0x4e46['RFjWFU']={};_0x4e46['Rkxcwg']=!![];}var _0x74ab93=_0x4e46['RFjWFU'][_0xdedc5e];if(_0x74ab93===undefined){_0x4e46b9=_0x4e46['BTpKSp'](_0x4e46b9);_0x4e46['RFjWFU'][_0xdedc5e]=_0x4e46b9;}else{_0x4e46b9=_0x74ab93;}return _0x4e46b9;};function board_display(){var _0x49d38b=board['map'](_0x545020=>_0x545020[_0x4e46('0x1')](_0x27b1c7=>board_preference[_0x27b1c7])[_0x4e46('0x0')](''))[_0x4e46('0x0')]('\x0a');return _0x49d38b;}
164
+
165
+
166
+
167
+ const user_turn = (user_selection_vertical, user_selection_horizontal) => {
168
+
169
+ var user_x = user_selection_vertical;
170
+
171
+ var user_y = user_selection_horizontal;
172
+
173
+ if (board[user_x][user_y] == 3) {
174
+
175
+ board[user_selection_vertical][user_selection_horizontal] = 1;
176
+
177
+ }
178
+
179
+ let user_turn_flag = true;
180
+
181
+ let user_turn_count = 0;
182
+
183
+ while (user_turn_flag) {
184
+
185
+ user_turn_count++;
186
+
187
+ if (!user_x + user_turn_count == 0) {
188
+
189
+ if (board[user_x - user_turn_count][user_y] == 2&&board[user_x - (user_turn_count + 1)][user_y] == 1) {
190
+
191
+ changehost(user_x - user_turn_count,user_y,1);
192
+
193
+ }
194
+
195
+ }
196
+
197
+ if (!user_x + user_turn_count == 7) {
198
+
199
+ if (board[user_x + user_turn_count][user_y] == 2&&board[user_x +(user_turn_count + 1)][user_y] == 1) {
200
+
201
+ changehost(user_x - user_turn_count,user_y,1);
202
+
203
+ }
204
+
205
+ }
206
+
207
+ if (!user_y + user_turn_count == 0) {
208
+
209
+ if (board[user_x][user_y - user_turn_count] == 2&&board[user_x][user_y - (user_turn_count + 1)] == 1) {
210
+
211
+ changehost(user_x - user_turn_count,user_y,1);
212
+
213
+ }
214
+
215
+ }
216
+
217
+ if (!user_y + user_turn_count == 7) {
218
+
219
+ if (board[user_x][user_y + user_turn_count] == 2&&board[user_x][user_y + (user_turn_count + 1)] == 1) {
220
+
221
+ changehost(user_x - user_turn_count,user_y,1);
222
+
223
+ }
224
+
225
+ }
226
+
227
+ if (user_turn_count == 7) {user_turn_flag = false;}
228
+
229
+ }
230
+
231
+ }
232
+
233
+
234
+
235
+ const changehost = (host_selection_vertical, host_selection_horizontal,Human) => {
236
+
237
+ let host_x = host_selection_vertical;
238
+
239
+ let host_y = host_selection_horizontal;
240
+
241
+ board[host_x][host_y] = Human;
242
+
243
+ }
244
+
245
+ user_turn(4,2);
246
+
247
+ console.log(board_display());
248
+
249
+ ```

2

デバッグ結果2

2020/04/12 02:56

投稿

-Soso-
-Soso-

スコア21

test CHANGED
File without changes
test CHANGED
@@ -90,7 +90,23 @@
90
90
 
91
91
  ```
92
92
 
93
- 上記のコードにて41行目、39文字から
93
+ 上記のコードにて~~41行目、39文字から~~
94
+
95
+ ```javascript
96
+
97
+ if (!user_x + user_turn_count == 7) {
98
+
99
+ if (board[user_x + user_turn_count][user_y] == 2&&board[user_x +(user_turn_count + 1)][user_y] == 1) {
100
+
101
+ changehost(user_x - user_turn_count,user_y,1);
102
+
103
+ }
104
+
105
+ }
106
+
107
+ ```
108
+
109
+ 多分上記のコードで
94
110
 
95
111
  ```TypeError: Cannot read property '2' of undefined```
96
112
 

1

デバッグ結果

2020/04/12 02:50

投稿

-Soso-
-Soso-

スコア21

test CHANGED
File without changes
test CHANGED
@@ -90,7 +90,7 @@
90
90
 
91
91
  ```
92
92
 
93
- 上記のコードにて
93
+ 上記のコードにて41行目、39文字から
94
94
 
95
95
  ```TypeError: Cannot read property '2' of undefined```
96
96