質問編集履歴

1

追記

2019/01/22 08:15

投稿

fm86
fm86

スコア12

test CHANGED
File without changes
test CHANGED
@@ -33,3 +33,261 @@
33
33
 
34
34
 
35
35
  なにか方法があれば、教えていただければと思います。
36
+
37
+
38
+
39
+ ```Unity
40
+
41
+ /* この上部でテクスチャの宣言 */
42
+
43
+ void Update()
44
+
45
+ {
46
+
47
+     if (Input.GetKeyDown(KeyCode.Space))
48
+
49
+ {
50
+
51
+ StartCoroutine("WaitCoordinateLeft");
52
+
53
+ }
54
+
55
+ }
56
+
57
+
58
+
59
+ IEnumerator WaitCoordinateLeft()
60
+
61
+ {
62
+
63
+ int e, c, p, s;
64
+
65
+ string str1 = "error";
66
+
67
+ string str2 = "error";
68
+
69
+
70
+
71
+ for (int count = 0; count < 10; count++)
72
+
73
+ {
74
+
75
+
76
+
77
+ /* フラグの確認 */
78
+
79
+ while (true)
80
+
81
+ {
82
+
83
+ //string f = Application.dataPath + "/StreamingAssets/flag_coordinate.csv";
84
+
85
+ string f = Application.dataPath + "../../../csv/flag_coordinate.csv";
86
+
87
+ StreamReader sr = new StreamReader(f, Encoding.GetEncoding("Shift_JIS"));
88
+
89
+ str1 = sr.ReadToEnd();
90
+
91
+
92
+
93
+ int sets = int.Parse(str1);
94
+
95
+
96
+
97
+ Debug.Log(str1 + " : " + sets);
98
+
99
+ sr.Close();
100
+
101
+ if (sets == count)
102
+
103
+ {
104
+
105
+ break;
106
+
107
+ }
108
+
109
+ else
110
+
111
+ {
112
+
113
+ Debug.Log("now loading...");
114
+
115
+ break;
116
+
117
+ };
118
+
119
+ }
120
+
121
+
122
+
123
+ //Debug.Log("コーディネートの読み込み " + count);
124
+
125
+
126
+
127
+ /* コーディネートの読み込み */
128
+
129
+ //string f2 = Application.dataPath + "/StreamingAssets/coordinate.csv";
130
+
131
+ string f2 = Application.dataPath + "../../../csv/coordinate.csv";
132
+
133
+ StreamReader sr2 = new StreamReader(f2, Encoding.GetEncoding("Shift_JIS"));
134
+
135
+ str2 = sr2.ReadToEnd();
136
+
137
+
138
+
139
+ sr2.Close();
140
+
141
+
142
+
143
+ var csvDatas = str2.Split(new[] { ',', '\n' }, StringSplitOptions.RemoveEmptyEntries);
144
+
145
+
146
+
147
+ e = int.Parse(csvDatas[1]);
148
+
149
+ c = int.Parse(csvDatas[2]);
150
+
151
+ p = int.Parse(csvDatas[3]);
152
+
153
+ s = int.Parse(csvDatas[4]);
154
+
155
+
156
+
157
+       /* コーディネートの設定 */
158
+
159
+ SetEye(e);
160
+
161
+ SetCloth(c);
162
+
163
+ SetPattern(p);
164
+
165
+ SetShoes(s);
166
+
167
+
168
+
169
+ Debug.Log("コーディネートの設定" + (count + 1));
170
+
171
+ Debug.Log("Left Coordinate " + count + " is " + e + " " + c + " " + p + " " + s);
172
+
173
+
174
+
175
+ Flag.CatchFlag(count);
176
+
177
+ //string f3 = Application.dataPath + "/../../csv/flag_coordinateSets.csv";
178
+
179
+ //StreamWriter sw = new StreamWriter(f3, false, Encoding.GetEncoding("Shift_JIS"));
180
+
181
+ //sw.WriteLine(count);
182
+
183
+ //sw.Close();
184
+
185
+
186
+
187
+ yield return new WaitForSeconds(12);
188
+
189
+ }
190
+
191
+ }
192
+
193
+ ```
194
+
195
+ ```C
196
+
197
+ int main(){
198
+
199
+ int c; //現対戦数
200
+
201
+ if (GetAsyncKeyState(VK_SPACE)){ //スペースキー入力により開始
202
+
203
+
204
+
205
+ /* 各対戦 */
206
+
207
+ for (c = 0; c < NUMBER - 1; c++){
208
+
209
+ printf("%d対戦目\n", c + 1);
210
+
211
+
212
+
213
+ select_individual(); //対戦する個体の選択
214
+
215
+ OutputChoiceIndividual(); //対戦する個体をunityに渡す
216
+
217
+ printf("%d対戦個体:%d vs %d\n", c + 1, D.indivi[0], D.indivi[1]);
218
+
219
+
220
+
221
+ Check_coordinatie(c); //コーディネートを出力しましたよ
222
+
223
+
224
+
225
+ EyeTrack(); //視線情報の取得
226
+
227
+ OutputGazeposi(); //視線位置の出力
228
+
229
+
230
+
231
+ judgement_game(); //勝敗判定
232
+
233
+ calclation_fitness(); //評価値計算
234
+
235
+ }
236
+
237
+ }
238
+
239
+
240
+
241
+ return 0;
242
+
243
+ }
244
+
245
+
246
+
247
+ void OutputChoiceIndividual(){
248
+
249
+ FILE *fci;
250
+
251
+
252
+
253
+ sprintf(F.nIndividual, "..\..\..\csv\coordinate.csv", C.NumG);
254
+
255
+ //sprintf(F.nIndividual, "..\..\..\DisplayCoordinate\Assets\StreamingAssets\coordinate.csv", C.NumG);
256
+
257
+
258
+
259
+ /* ファイルオープン */
260
+
261
+ if ((fci = fopen(F.nIndividual, "w")) == NULL){
262
+
263
+ printf("Individualファイルオープン失敗\n");
264
+
265
+ exit(-1);
266
+
267
+ }
268
+
269
+
270
+
271
+ for (int i = 0; i < 2; i++){
272
+
273
+ for (int j = 0; j < 5; j++){
274
+
275
+ fprintf(fci, "%d, ", CG[D.indivi[i]].decimal[j]);
276
+
277
+ printf("%d, ", CG[D.indivi[i]].decimal[j]);
278
+
279
+ }
280
+
281
+ fprintf(fci, "\n");
282
+
283
+ printf("\n");
284
+
285
+ }
286
+
287
+
288
+
289
+ fclose(fci);
290
+
291
+ }
292
+
293
+ ```