Showing
4 changed files
with
1678 additions
and
0 deletions
player.js
0 → 100644
1 | +var dusan_hitter = [ | ||
2 | + ['선수명', 'AVG', 'H', '2B', '3B', 'HR'], | ||
3 | + ['김재환',0.268,48,4,1,13], | ||
4 | + ['박건우',0.340,52,10,0,2], | ||
5 | + ['페르난데스',0.333,66,7,0,8], | ||
6 | + ['허경민',0.330,63,9,0,4], | ||
7 | + ['양석환',0.269,52,10,0,12], | ||
8 | + ['김인태',0.267,36,5,1,4], | ||
9 | + ['안재석',0.316,25,4,2,0], | ||
10 | + ['최용제',0.311,14,3,0,0], | ||
11 | + ['조수행',0.277,13,1,1,0], | ||
12 | + ['장승현',0.248,27,3,0,2], | ||
13 | + ['김재호',0.262,28,5,0,1], | ||
14 | + ['박계범',0.266,21,5,0,2], | ||
15 | + ['강승호',0.247,19,2,1,2], | ||
16 | + ['정수빈',0.226,14,2,1,0], | ||
17 | + ['박세혁',0.182,6,0,0,0], | ||
18 | + ['오재원',0.175,11,2,0,0], | ||
19 | +] | ||
20 | + | ||
21 | +var dusan_pitcher = [ | ||
22 | + ['선수명', '볼넷%', '피안타율'], | ||
23 | + ['로켓', 7.4, 0.251], | ||
24 | + ['미란다', 12.5, 0.243], | ||
25 | + ['최원준', 5.6, 0.237], | ||
26 | + ['박정수', 10.2, 0.302], | ||
27 | + ['곽빈', 16.7, 0.256], | ||
28 | + ['유희관', 7.6, 0.409], | ||
29 | + ['조제영', 16.7, 0.367], | ||
30 | + ['이영하', 16.0, 0.393], | ||
31 | +] | ||
32 | + | ||
33 | +var hanhwa_hitter = [ | ||
34 | + ['선수명', 'AVG', 'H', '2B', '3B', 'HR'], | ||
35 | + ['정은원',0.284,54,10,4,1], | ||
36 | + ['노시환',0.266,49,8,0,11], | ||
37 | + ['하주석',0.283,53,10,1,4], | ||
38 | + ['조한민',0.308,8,1,2,2], | ||
39 | + ['최재훈',0.216,27,3,0,2], | ||
40 | + ['김민하',0.240,18,4,0,1], | ||
41 | + ['장운호',0.273,35,8,0,0], | ||
42 | + ['노수광',0.217,15,1,0,1], | ||
43 | + ['강상원',0.167,3,0,0,0], | ||
44 | + ['강경학',0.136,3,0,0,0], | ||
45 | + ['이해창',0.231,9,3,0,0], | ||
46 | + ['허관회',0.161,5,0,0,0], | ||
47 | + ['이성열',0.203,16,4,0,1], | ||
48 | + ['힐리',0.258,46,8,1,4], | ||
49 | + ['정진호',0.216,16,3,0,0], | ||
50 | + ['박정현',0.196,21,4,0,0], | ||
51 | + ['유장혁',0.143,14,5,0,1], | ||
52 | + ['임종찬',0.155,16,5,0,1], | ||
53 | +] | ||
54 | + | ||
55 | +var hanhwa_pitcher = [ | ||
56 | + ['선수명', '볼넷%', '피안타율'], | ||
57 | + ['킹험', 6.4, 0.211], | ||
58 | + ['카펜터', 11.7, 0.209], | ||
59 | + ['김민우', 11.2, 0.208], | ||
60 | + ['김범수', 13.9, 0.284], | ||
61 | + ['장시환', 15.8, 0.306], | ||
62 | + ['윤대경', 15.0, 0.208], | ||
63 | + ['김기중', 5.6, 0.353], | ||
64 | + ['김이환', 16.7, 0.283], | ||
65 | + ['박주홍', 50.0, 0.250], | ||
66 | + ['이승관', 39.1, 0.538], | ||
67 | + ['배동현', 15.4, 0.252], | ||
68 | +] | ||
69 | + | ||
70 | +var kia_hitter = [ | ||
71 | + ['선수명', 'AVG', 'H', '2B', '3B', 'HR'], | ||
72 | + ['최원준',0.324,71,5,5,1], | ||
73 | + ['김민식',0.247,22,3,0,2], | ||
74 | + ['김선빈',0.281,52,10,0,0], | ||
75 | + ['이정훈',0.298,25,5,0,2], | ||
76 | + ['김태진',0.336,41,3,1,0], | ||
77 | + ['터커',0.269,56,11,1,3], | ||
78 | + ['이진영',0.188,6,2,0,2], | ||
79 | + ['한승택',0.238,19,3,0,0], | ||
80 | + ['김호령',0.163,7,2,0,1], | ||
81 | + ['류지혁',0.259,21,3,0,0], | ||
82 | + ['김규성',0.133,2,1,0,0], | ||
83 | + ['이창진',0.218,22,5,0,0], | ||
84 | + ['나지완',0.184,9,1,0,0], | ||
85 | + ['박찬호',0.241,42,6,2,0], | ||
86 | + ['이우성',0.194,6,1,0,0], | ||
87 | + ['유민상',0.143,3,1,0,0], | ||
88 | + ['최형우',0.195,22,1,0,5], | ||
89 | + ['황대인',0.259,15,2,0,2], | ||
90 | + ['나주환',0.172,5,0,0,0], | ||
91 | +] | ||
92 | + | ||
93 | +var kia_pitcher = [ | ||
94 | + ['선수명', '볼넷%', '피안타율'], | ||
95 | + ['브룩스', 5.3, 0.307], | ||
96 | + ['멩덴', 10, 0.243], | ||
97 | + ['이의리', 14, 0.223], | ||
98 | + ['임기영', 7.1, 0.254], | ||
99 | + ['김현수', 14.5, 0.243], | ||
100 | + ['이민우', 7.9, 0.346], | ||
101 | + ['남재현', 27.8, 0.208], | ||
102 | + ['김유신', 16.2, 0.269], | ||
103 | + ['차명진', 8.0, 0.273], | ||
104 | +] | ||
105 | + | ||
106 | +var kiwoom_hitter = [ | ||
107 | + ['선수명', 'AVG', 'H', '2B', '3B', 'HR'], | ||
108 | + ['이정후',0.346,71,21,4,1], | ||
109 | + ['박동원',0.281,34,7,0,9], | ||
110 | + ['김혜성',0.283,62,8,1,3], | ||
111 | + ['서건창',0.266,49,9,0,1], | ||
112 | + ['김웅빈',0.250,39,10,0,4], | ||
113 | + ['이용규',0.256,42,4,4,0], | ||
114 | + ['송우현',0.280,46,11,1,1], | ||
115 | + ['박병호',0.219,35,8,0,8], | ||
116 | + ['전병우',0.196,22,6,0,3], | ||
117 | + ['박준태',0.048,1,1,0,0], | ||
118 | + ['프레이타스',0.285,35,10,0,2], | ||
119 | + ['김수환',0.220,9,2,0,2], | ||
120 | + ['허정협',0.179,5,0,0,0], | ||
121 | + ['박주홍',0.143,4,2,0,0], | ||
122 | + ['이지영',0.253,22,2,1,0], | ||
123 | + ['변상권',0.105,2,0,0,0], | ||
124 | +] | ||
125 | + | ||
126 | +var kiwoom_pitcher = [ | ||
127 | + ['선수명', '볼넷%', '피안타율'], | ||
128 | + ['요키시', 6.8, 0.252], | ||
129 | + ['한현희', 8.8, 0.261], | ||
130 | + ['최원태', 7.7, 0.276], | ||
131 | + ['안우진', 10.4, 0.269], | ||
132 | + ['브리검', 13.3, 0.243], | ||
133 | + ['이승호', 18, 0.263], | ||
134 | + ['스미스', 11.6, 0.237], | ||
135 | + ['장재영', 26.5, 0.217], | ||
136 | + ['김정인', 12.5, 0.246], | ||
137 | +] | ||
138 | + | ||
139 | +var kt_hitter = [ | ||
140 | + ['선수명', 'AVG', 'H', '2B', '3B', 'HR'], | ||
141 | + ['강백호',0.407,81,12,1,7], | ||
142 | + ['배정대',0.295,57,13,0,3], | ||
143 | + ['심우준',0.306,49,11,1,3], | ||
144 | + ['김병희',0.300,12,3,0,3], | ||
145 | + ['황재균',0.316,31,3,1,1], | ||
146 | + ['조용호',0.281,47,7,0,0], | ||
147 | + ['장성우',0.234,36,6,0,6], | ||
148 | + ['알몬테',0.296,58,9,0,5], | ||
149 | + ['김민혁',0.302,19,0,2,0], | ||
150 | + ['유한준',0.280,30,6,0,1], | ||
151 | + ['권동진',0.182,6,3,0,0], | ||
152 | + ['송민섭',0.080,2,0,0,0], | ||
153 | + ['문상철',0.222,16,6,0,2], | ||
154 | + ['신본기',0.400,18,4,0,0], | ||
155 | + ['박경수',0.185,22,6,0,5], | ||
156 | + ['이홍구',0.178,8,0,0,1], | ||
157 | +] | ||
158 | + | ||
159 | +var kt_pitcher = [ | ||
160 | + ['선수명', '볼넷%', '피안타율'], | ||
161 | + ['데스파이네', 11.3, 0.213], | ||
162 | + ['고영표', 3.9, 0.243], | ||
163 | + ['배제성', 13.8, 0.226], | ||
164 | + ['소형준', 12.3, 0.269], | ||
165 | + ['김민수', 11.8, 0.299], | ||
166 | + ['쿠에바스', 12.0, 0.306], | ||
167 | + ['이정현', 12.0, 0.318], | ||
168 | +] | ||
169 | + | ||
170 | +var lg_hitter = [ | ||
171 | + ['선수명', 'AVG', 'H', '2B', '3B', 'HR'], | ||
172 | + ['홍창기', 0.316, 60, 8, 1, 3], | ||
173 | + ['김현수', 0.317, 59, 9, 0, 8], | ||
174 | + ['채은성', 0.303, 47, 11, 0, 7], | ||
175 | + ['문보경', 0.275, 19, 7, 0, 2], | ||
176 | + ['유강남', 0.241, 40, 6, 0, 5], | ||
177 | + ['오지환', 0.231, 37, 9, 1, 2], | ||
178 | + ['이형종', 0.222, 22, 6, 0, 4], | ||
179 | + ['한석현', 0.286, 6, 2, 1, 0], | ||
180 | + ['라모스', 0.243, 45, 7, 1, 8], | ||
181 | + ['김재성', 0.188, 6, 1, 1, 1], | ||
182 | + ['신민재', 0.167, 3, 0, 0, 0], | ||
183 | + ['정주현', 0.222, 30, 6, 1, 2], | ||
184 | + ['구본혁', 0.150, 3, 2, 0, 0], | ||
185 | + ['김민성', 0.207, 34, 9, 0, 3], | ||
186 | + ['이천웅', 0.211, 27, 6, 0, 2], | ||
187 | +] | ||
188 | + | ||
189 | +var lg_pitcher = [ | ||
190 | + ['선수명', '볼넷%', '피안타율'], | ||
191 | + ['수아레즈', 9.6, 0.208], | ||
192 | + ['정찬헌', 5.6, 0.271], | ||
193 | + ['켈리', 9.6, 0.228], | ||
194 | + ['이민호', 11.5, 0.234], | ||
195 | + ['이우찬', 10.2, 0.264] | ||
196 | + ['배재준', 6.2, 0.356], | ||
197 | + ['차우찬', 9.5, 0.211], | ||
198 | + ['함덕주', 17.2, 0.224], | ||
199 | + ['김윤식', 12.7, 0.254], | ||
200 | + ['임찬규', 25.8, 0.476], | ||
201 | + ['이상영', 11.1, 0.257], | ||
202 | +] | ||
203 | + | ||
204 | +var lotte_hitter = [ | ||
205 | + ['선수명', 'AVG', 'H', '2B', '3B', 'HR'], | ||
206 | + ['전준우', 0.325, 65, 12, 0, 2], | ||
207 | + ['정훈', 0.305, 57, 13, 0, 6], | ||
208 | + ['마차도', 0.272, 43, 9, 0, 4], | ||
209 | + ['안치홍', 0.310, 54, 11, 2, 3], | ||
210 | + ['이대호', 0.328, 44, 3, 0, 8], | ||
211 | + ['한동희', 0.241, 41, 8, 0, 7], | ||
212 | + ['추재현', 0.318, 28, 6, 0, 3], | ||
213 | + ['김준태', 0.221, 23, 5, 0, 4], | ||
214 | + ['김재유', 0.290, 9, 2, 0, 0], | ||
215 | + ['배성근', 0.270, 10, 1, 0, 0], | ||
216 | + ['이병규', 0.235, 8, 0, 0, 0], | ||
217 | + ['지시완', 0.237, 14, 2, 0, 2], | ||
218 | + ['오윤석', 0.245, 13, 7, 0, 1], | ||
219 | + ['장두성', 0.214, 6, 2, 0, 0], | ||
220 | + ['나승엽', 0.268, 11, 1, 0, 0], | ||
221 | + ['김민수', 0.232, 16, 5, 0, 1], | ||
222 | + ['강태율', 0.100, 2, 1, 0, 1], | ||
223 | + ['손아섭', 0.271, 57, 6, 0, 0], | ||
224 | +] | ||
225 | + | ||
226 | +var lotte_pitcher = [ | ||
227 | + ['선수명', '볼넷%', '피안타율'], | ||
228 | + ['스트레일리', 9.3, 0.268], | ||
229 | + ['박세웅', 8.3, 0.230], | ||
230 | + ['나균안', 9.4, 0.274], | ||
231 | + ['프랑코', 11.0, 0.234], | ||
232 | + ['김진욱', 20.0, 0.261], | ||
233 | + ['서준원', 13.9, 0.299], | ||
234 | + ['이승헌', 19.6, 0.325], | ||
235 | + ['노경은', 10.7, 0.344], | ||
236 | +] | ||
237 | + | ||
238 | +var nc_hitter = [ | ||
239 | + ['선수명', 'AVG', 'H', '2B', '3B', 'HR'], | ||
240 | + ['양의지', 0.349, 60, 11, 1, 11], | ||
241 | + ['알테어', 0.303, 56, 10, 0, 14], | ||
242 | + ['박석민', 0.299, 35, 8, 0, 10], | ||
243 | + ['나성범', 0.280, 60, 12, 1, 13,] | ||
244 | + ['노진혁', 0.296, 45, 5, 0, 5], | ||
245 | + ['이명기', 0.296, 47, 10, 0, 2], | ||
246 | + ['박민우', 0.287, 41, 5, 1, 1], | ||
247 | + ['권희동', 0.237, 22, 3, 0, 6], | ||
248 | + ['김태군', 0.248, 26, 5, 0, 3], | ||
249 | + ['윤형준', 0.400, 10, 0, 0, 3], | ||
250 | + ['박준영', 0.238, 24, 2, 1, 5], | ||
251 | + ['김찬형', 0.364, 8, 1, 0, 0], | ||
252 | + ['정진기', 0.333, 7, 3, 0, 0], | ||
253 | + ['전민수', 0.318, 7, 0, 0, 0], | ||
254 | + ['강진성', 0.234, 26, 7, 0, 1], | ||
255 | + ['지석훈', 0.147, 5, 1, 0, 0], | ||
256 | + ['최정원', 0.158, 3, 0, 0, 0], | ||
257 | + ['도태훈', 0.067, 2, 0, 0, 0], | ||
258 | + ['이원재', 0.226, 14, 2, 0, 0], | ||
259 | +] | ||
260 | + | ||
261 | +var nc_pitcher = [ | ||
262 | + ['선수명', '볼넷%', '피안타율'], | ||
263 | + ['루친스키', 9.0, 0.235], | ||
264 | + ['파슨스', 11.9, 0.219], | ||
265 | + ['송명기', 7.2, 0.348], | ||
266 | + ['신민혁', 7.8, 0.245], | ||
267 | + ['강동연', 9.0, 0.271], | ||
268 | + ['김진호', 42.9, 0.500], | ||
269 | + ['김영규', 11.9, 0.312], | ||
270 | + ['이재학', 24.4, 0.290], | ||
271 | +] | ||
272 | + | ||
273 | +var samsung_hitter = [ | ||
274 | + ['선수명', 'AVG', 'H', '2B', '3B', 'HR'], | ||
275 | + ['피렐라',0.347,77,10,1,13], | ||
276 | + ['강민호',0.351,54,8,0,6], | ||
277 | + ['박해민',0.292,52,8,0,3], | ||
278 | + ['구자욱',0.287,58,10,4,6], | ||
279 | + ['오재일',0.295,36,8,0,8], | ||
280 | + ['김헌곤',0.310,31,2,0,3], | ||
281 | + ['김민수',0.313,15,4,0,2], | ||
282 | + ['이원석',0.241,33,8,0,3], | ||
283 | + ['김지찬',0.259,30,5,0,1], | ||
284 | + ['이학주',0.220,18,6,0,2], | ||
285 | + ['김호재',0.222,8,1,0,0], | ||
286 | + ['송준석',0.235,12,2,0,2], | ||
287 | + ['강한울',0.231,24,3,0,0], | ||
288 | + ['김상수',0.206,37,4,1,0], | ||
289 | + ['김동엽',0.157,8,1,0,0], | ||
290 | +] | ||
291 | + | ||
292 | +var samsung_pitcher = [ | ||
293 | + ['선수명', '볼넷%', '피안타율'], | ||
294 | + ['뷰캐넌', 8.5, 0.228], | ||
295 | + ['원태인', 8.6, 0.246], | ||
296 | + ['라이블리', 9.3, 0.190], | ||
297 | + ['백정현', 10.5, 0.250], | ||
298 | + ['최채흥', 9.7, 0.346], | ||
299 | + ['이승민', 10.2, 0.294], | ||
300 | + ['김윤수', 19.3, 0.348], | ||
301 | + ['김대우', 8.3, 0.275], | ||
302 | + ['구준범', 25.0, 0.250], | ||
303 | +] | ||
304 | + | ||
305 | +var ssg_hitter = [ | ||
306 | + ['선수명', 'AVG', 'H', '2B', '3B', 'HR'], | ||
307 | + ['최정',0.293,49,8,0,13], | ||
308 | + ['추신수',0.263,44,4,1,8], | ||
309 | + ['로맥',0.253,46,6,0,13], | ||
310 | + ['박성한',0.297,38,8,0,1], | ||
311 | + ['최주환',0.304,35,7,0,4], | ||
312 | + ['최지훈',0.237,32,4,1,3], | ||
313 | + ['김성현',0.278,27,4,0,2], | ||
314 | + ['한유섬',0.250,41,9,0,6], | ||
315 | + ['이흥련',0.281,16,1,0,0], | ||
316 | + ['이재원',0.258,34,9,0,2], | ||
317 | + ['정현',0.190,4,2,0,0], | ||
318 | + ['김강민',0.242,22,5,1,3], | ||
319 | + ['김찬형',0.174,4,1,0,0], | ||
320 | + ['오태곤',0.232,19,2,0,4], | ||
321 | + ['오준혁',0.207,6,1,0,1], | ||
322 | + ['정의윤',0.224,22,0,0,5], | ||
323 | + ['고종욱',0.250,13,0,0,0], | ||
324 | +] | ||
325 | + | ||
326 | +var ssg_pitcher = [ | ||
327 | + ['선수명', '볼넷%', '피안타율'], | ||
328 | + ['폰트', 7.1, 0.206], | ||
329 | + ['박종훈', 7.2, 0.205], | ||
330 | + ['문승원', 8.5, 0.220], | ||
331 | + ['오원석', 13.6, 0.251], | ||
332 | + ['르위키', 3.6, 0.278], | ||
333 | + ['조영우', 9.5, 0.321], | ||
334 | + ['양선률', 30.0, 0.500], | ||
335 | + ['정수민', 17.3, 0.284], | ||
336 | + ['김정빈', 19.4, 0.304], | ||
337 | + ['이건욱', 26.4, 0.333], | ||
338 | +] | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
predict.js
0 → 100644
1 | +function add_predict(){ | ||
2 | + var s=""; | ||
3 | + s+=("<option value="+10+">"+10+"</option>"); | ||
4 | + s+=("<option value="+20+">"+20+"</option>"); | ||
5 | + s+=("<option value="+50+">"+50+"</option>"); | ||
6 | + s+=("<option value="+70+">"+70+"</option>"); | ||
7 | + s+=("<option value="+100+">"+100+"</option>"); | ||
8 | + s+=("<option value="+500+">"+500+"</option>"); | ||
9 | + s+=("<option value="+1000+">"+1000+"</option>"); | ||
10 | + s+=("<option value="+5000+">"+5000+"</option>"); | ||
11 | + s+=("<option value="+10000+">"+10000+"</option>"); | ||
12 | + s+=("<option value="+50000+">"+50000+"</option>"); | ||
13 | + s+=("<option value="+100000+">"+100000+"</option>"); | ||
14 | + document.getElementById('pr').innerHTML=s; | ||
15 | +} | ||
16 | + | ||
17 | +function predict(value, hitter_list1, hitter_list2, pitcher1, pitcher2){ | ||
18 | + var score=[0,0]; | ||
19 | + var w=0; | ||
20 | + var h=0; | ||
21 | + var d=0; | ||
22 | + for(var i=0; i<value; i++){ | ||
23 | + score=algorithms(hitter_list1, hitter_list2, pitcher1, pitcher2); | ||
24 | + if(score[0]>score[1]){ | ||
25 | + w++; | ||
26 | + }else if(score[0]<score[1]){ | ||
27 | + h++; | ||
28 | + }else{ | ||
29 | + d++; | ||
30 | + } | ||
31 | + } | ||
32 | + document.getElementById('jstest').innerHTML="예측 결과"+"<br\>"+"TEST "+value+"번"+"<br\><br\>"+"원정팀 승리 횟수 : "+w+"<br\>" | ||
33 | + +"홈팀 승리 횟수 : "+h+"<br\>"+"무승부 횟수 : "+d+"<br\><br\>"+"원정팀 승리 확률 : "+w*100/value+"%"+"<br\>"+"홈팀 승리 확률 : "+h*100/value+"%"+"<br\>"; | ||
34 | +} | ||
35 | + | ||
36 | +function algorithms(hitter_list1, hitter_list2, pitcher1, pitcher2){ | ||
37 | + var base1 = 0; var base2 = 0; var base3 = 0; //1이면 주자 있고 0이면 비어있는것 | ||
38 | + var out = 0; var ining = 1; var home_away = 1;//아웃카운트, 이닝, home이면 1이고 away이면 2. | ||
39 | + var score1 = 0; var score2 = 0; | ||
40 | + var hitter_num1 = 1; var hitter_num2 = 1; | ||
41 | + var hit=false; | ||
42 | + while(true){ | ||
43 | + if(ining == 9 && home_away == 2 && score1 < score2){//9회 초 후 home팀이 이기고 있을 때! | ||
44 | + break; | ||
45 | + } | ||
46 | + else if(ining==10 && home_away==1 && score1>score2 && hit==false){//9회 말 후 home팀이 이기고 있을 때! | ||
47 | + break; | ||
48 | + } | ||
49 | + else if(ining>9 && score1 < score2){//9회 말 후 home팀이 이기고 있을 때! | ||
50 | + break; | ||
51 | + } | ||
52 | + else if(ining>=11 && home_away==1 && hit==false && score1>score2){//연장 이후 원정팀이 이기고 있을 때! | ||
53 | + break; | ||
54 | + } | ||
55 | + else if(ining>=10 && home_away==2 && hit==true && score1<score2){//끝내기 | ||
56 | + break; | ||
57 | + } | ||
58 | + else if(ining==13 && score1==score2){//무승부 | ||
59 | + break; | ||
60 | + } | ||
61 | + | ||
62 | + if(home_away == 1){ | ||
63 | + var hitter = hitter_list1[hitter_num1]; //hitter = hitter_list1[hitter_number1%9] | ||
64 | + var pitcher = pitcher2; //pitcher = pitcher1 | ||
65 | + | ||
66 | + } | ||
67 | + else if(home_away == 2){ | ||
68 | + var hitter = hitter_list2[hitter_num2]; //hitter = hitter_list2[hitter_number2%9] | ||
69 | + var pitcher = pitcher1; //pitcher = pitcher2 | ||
70 | + | ||
71 | + } | ||
72 | + | ||
73 | + var num = Math.random(); | ||
74 | + //hitter_number1 = hitter_number(kia); hitter_number2 = hitter_number(dusan); | ||
75 | + var one = 0; var two = 0; var three = 0; var homerun = 0; | ||
76 | + one = pitcher[2] * (hitter[2] - hitter[3] - hitter[4] - hitter[5])/hitter[2]; | ||
77 | + two = pitcher[2] * hitter[3]/hitter[2]; | ||
78 | + three = pitcher[2] * hitter[4]/hitter[2]; | ||
79 | + homerun = pitcher[2] * hitter[5]/hitter[2]; | ||
80 | + hit=true; | ||
81 | + if(num <= one){ //안타 | ||
82 | + var num1 = Math.random(); | ||
83 | + if(num1 <= 0.5){ | ||
84 | + switch(home_away){ | ||
85 | + case 1: | ||
86 | + score1 = score1 + base3; | ||
87 | + break; | ||
88 | + case 2: | ||
89 | + score2 = score2 + base3; | ||
90 | + break; | ||
91 | + } | ||
92 | + base3 = base2; | ||
93 | + base2 = base1; | ||
94 | + base1 = 1; | ||
95 | + | ||
96 | + } | ||
97 | + else{ | ||
98 | + switch(home_away){ | ||
99 | + case 1: | ||
100 | + score1 = score1 + base3 + base2; | ||
101 | + break; | ||
102 | + case 2: | ||
103 | + score2 = score2 + base3 + base2; | ||
104 | + break; | ||
105 | + } | ||
106 | + base3 = base1; | ||
107 | + base2 = 0; | ||
108 | + base1 = 1; | ||
109 | + | ||
110 | + } | ||
111 | + | ||
112 | + } | ||
113 | + else if((one < num) && (num <= one + two)){//2루타 | ||
114 | + var num2 = Math.random(); | ||
115 | + if(num2 <= 0.4){ | ||
116 | + switch(home_away){ | ||
117 | + case 1: | ||
118 | + score1 = score1 + base3 + base2; | ||
119 | + break; | ||
120 | + case 2: | ||
121 | + score2 = score2 + base3 + base2; | ||
122 | + break; | ||
123 | + } | ||
124 | + base3 = base1; | ||
125 | + base2 = 1; | ||
126 | + base1 = 0; | ||
127 | + | ||
128 | + } | ||
129 | + else if(0.4 < num2 && num2 <=0.7){ | ||
130 | + switch(home_away){ | ||
131 | + case 1: | ||
132 | + score1 = score1 + base3 + base2 + base1; | ||
133 | + break; | ||
134 | + case 2: | ||
135 | + score2 = score2 + base3 + base2 + base1; | ||
136 | + break; | ||
137 | + } | ||
138 | + base3 = 0; | ||
139 | + base2 = 1; | ||
140 | + base1 = 0; | ||
141 | + | ||
142 | + } | ||
143 | + else{ | ||
144 | + switch(home_away){ | ||
145 | + case 1: | ||
146 | + score1 = score1 + base3 + base2; | ||
147 | + break; | ||
148 | + case 2: | ||
149 | + score2 = score2 + base3 + base2; | ||
150 | + break; | ||
151 | + } | ||
152 | + base3 = 0; | ||
153 | + base2 = 1; | ||
154 | + base1 = 0; | ||
155 | + | ||
156 | + } | ||
157 | + | ||
158 | + } | ||
159 | + else if((one + two < num) && (num <= one + two + three)){//3루타 | ||
160 | + switch(home_away){ | ||
161 | + case 1: | ||
162 | + score1 = score1 + base3 + base2 + base1; | ||
163 | + break; | ||
164 | + case 2: | ||
165 | + score2 = score2 + base3 + base2 + base1; | ||
166 | + break; | ||
167 | + } | ||
168 | + base3 = 1; | ||
169 | + base2 = 0; | ||
170 | + base1 = 0; | ||
171 | + | ||
172 | + } | ||
173 | + else if(one + two + three < num && num <= one + two + three + homerun){//홈런 | ||
174 | + switch(home_away){ | ||
175 | + case 1: | ||
176 | + score1 = score1 + base3 + base2 + base1 + 1; | ||
177 | + break; | ||
178 | + case 2: | ||
179 | + score2 = score2 + base3 + base2 + base1 + 1; | ||
180 | + break; | ||
181 | + } | ||
182 | + base3 = 0; | ||
183 | + base2 = 0; | ||
184 | + base1 = 0; | ||
185 | + | ||
186 | + } | ||
187 | + | ||
188 | + | ||
189 | + else if( pitcher[2] < num && (num <= pitcher[2] +pitcher[1]*0.01)){//볼넷 | ||
190 | + if(base1==1 && base2==1 && base3==1){//만루 밀어내기 득점 -> 스코어 ++ | ||
191 | + if(home_away==1){ | ||
192 | + score1++; | ||
193 | + } | ||
194 | + else{ | ||
195 | + score2++; | ||
196 | + } | ||
197 | + } | ||
198 | + else{//스코어 추가되지 않는 경우 | ||
199 | + if((base2==1 && base1==0 )||(base3==1 && base1==0)||(base2==1&&base3==1&&base1==0)){//2루만 채워져있거나 3루만 채워져있거나 2,3루만 채워져있거나 | ||
200 | + base1=1; | ||
201 | + } | ||
202 | + else if(base1==1 && base3==1 && base2==0){//1루 3루 채워져있고 2루 비워져있거나 | ||
203 | + base2=base1; | ||
204 | + base1=1; | ||
205 | + } | ||
206 | + else{ | ||
207 | + base3 = base2; | ||
208 | + base2 = base1; | ||
209 | + base1 = 1; | ||
210 | + } | ||
211 | + } | ||
212 | + | ||
213 | + } | ||
214 | + | ||
215 | + else{//아웃 | ||
216 | + out++; | ||
217 | + | ||
218 | + } | ||
219 | + | ||
220 | + if(out >= 3){ | ||
221 | + switch(home_away){ | ||
222 | + case 1: | ||
223 | + home_away = 2; | ||
224 | + hit=false; | ||
225 | + break; | ||
226 | + case 2: | ||
227 | + home_away = 1; | ||
228 | + ining++; | ||
229 | + hit=false; | ||
230 | + break; | ||
231 | + } | ||
232 | + out=0; | ||
233 | + base1=0; base2=0; base3=0; | ||
234 | + } | ||
235 | + else{ | ||
236 | + if(home_away == 1){ | ||
237 | + hitter_num1++; | ||
238 | + if(hitter_num1>=10){ | ||
239 | + hitter_num1=1; | ||
240 | + } | ||
241 | + } | ||
242 | + else if(home_away == 2){ | ||
243 | + hitter_num2++; | ||
244 | + if(hitter_num2>=10){ | ||
245 | + hitter_num2=1; | ||
246 | + } | ||
247 | + } | ||
248 | + } | ||
249 | + | ||
250 | + } | ||
251 | + var score = [score1, score2]; | ||
252 | + return score; | ||
253 | +} |
simulation.js
0 → 100644
1 | +var wonjung=8; | ||
2 | +var home=6; | ||
3 | +var hitter_list1=[ | ||
4 | + ['선수명', 'AVG', 'H', '2B', '3B', 'HR'], | ||
5 | + ['', 0, 0, 0, 0, 0], | ||
6 | + ['', 0, 0, 0, 0, 0], | ||
7 | + ['', 0, 0, 0, 0, 0], | ||
8 | + ['', 0, 0, 0, 0, 0], | ||
9 | + ['', 0, 0, 0, 0, 0], | ||
10 | + ['', 0, 0, 0, 0, 0], | ||
11 | + ['', 0, 0, 0, 0, 0], | ||
12 | + ['', 0, 0, 0, 0, 0], | ||
13 | + ['', 0, 0, 0, 0, 0], | ||
14 | +]; | ||
15 | +var hitter_list2=[ | ||
16 | + ['선수명', 'AVG', 'H', '2B', '3B', 'HR'], | ||
17 | + ['', 0, 0, 0, 0, 0], | ||
18 | + ['', 0, 0, 0, 0, 0], | ||
19 | + ['', 0, 0, 0, 0, 0], | ||
20 | + ['', 0, 0, 0, 0, 0], | ||
21 | + ['', 0, 0, 0, 0, 0], | ||
22 | + ['', 0, 0, 0, 0, 0], | ||
23 | + ['', 0, 0, 0, 0, 0], | ||
24 | + ['', 0, 0, 0, 0, 0], | ||
25 | + ['', 0, 0, 0, 0, 0], | ||
26 | +]; | ||
27 | +var pitcher1=['',0,0]; | ||
28 | +var pitcher2=['',0,0]; | ||
29 | + | ||
30 | +function imgchange1(a){ | ||
31 | + var img=document.getElementById("wonjung"); | ||
32 | + if(a==1){ | ||
33 | + wonjung=1; | ||
34 | + img.setAttribute("src","pngs/samsung.png"); | ||
35 | + } | ||
36 | + else if(a==2){ | ||
37 | + wonjung=2; | ||
38 | + img.setAttribute("src","pngs/nc.png"); | ||
39 | + } | ||
40 | + else if(a==3){ | ||
41 | + wonjung=3; | ||
42 | + img.setAttribute("src","pngs/LG.png"); | ||
43 | + } | ||
44 | + else if(a==4){ | ||
45 | + wonjung=4; | ||
46 | + img.setAttribute("src","pngs/kt.png"); | ||
47 | + } | ||
48 | + else if(a==5){ | ||
49 | + wonjung=5; | ||
50 | + img.setAttribute("src","pngs/ssg.png"); | ||
51 | + } | ||
52 | + else if(a==6){ | ||
53 | + wonjung=6; | ||
54 | + img.setAttribute("src","pngs/dusan.png"); | ||
55 | + } | ||
56 | + else if(a==7){ | ||
57 | + wonjung=7; | ||
58 | + img.setAttribute("src","pngs/kiwoom.png"); | ||
59 | + } | ||
60 | + else if(a==8){ | ||
61 | + wonjung=8; | ||
62 | + img.setAttribute("src","pngs/kia.png"); | ||
63 | + } | ||
64 | + else if(a==9){ | ||
65 | + wonjung=9; | ||
66 | + img.setAttribute("src","pngs/hanhwa.png"); | ||
67 | + } | ||
68 | + else if(a==10){ | ||
69 | + wonjung=10; | ||
70 | + img.setAttribute("src","pngs/Lotte.png"); | ||
71 | + } | ||
72 | + hitter1_option(wonjung); | ||
73 | + pitcher1_option(wonjung); | ||
74 | +} | ||
75 | + | ||
76 | +function imgchange2(a){ | ||
77 | + var img=document.getElementById("home"); | ||
78 | + if(a==1){ | ||
79 | + home=1; | ||
80 | + img.setAttribute("src","pngs/samsung.png"); | ||
81 | + } | ||
82 | + else if(a==2){ | ||
83 | + home=2; | ||
84 | + img.setAttribute("src","pngs/nc.png"); | ||
85 | + } | ||
86 | + else if(a==3){ | ||
87 | + home=3; | ||
88 | + img.setAttribute("src","pngs/LG.png"); | ||
89 | + } | ||
90 | + else if(a==4){ | ||
91 | + home=4; | ||
92 | + img.setAttribute("src","pngs/kt.png"); | ||
93 | + } | ||
94 | + else if(a==5){ | ||
95 | + home=5; | ||
96 | + img.setAttribute("src","pngs/ssg.png"); | ||
97 | + } | ||
98 | + else if(a==6){ | ||
99 | + home=6; | ||
100 | + img.setAttribute("src","pngs/dusan.png"); | ||
101 | + } | ||
102 | + else if(a==7){ | ||
103 | + home=7; | ||
104 | + img.setAttribute("src","pngs/kiwoom.png"); | ||
105 | + } | ||
106 | + else if(a==8){ | ||
107 | + home=8; | ||
108 | + img.setAttribute("src","pngs/kia.png"); | ||
109 | + } | ||
110 | + else if(a==9){ | ||
111 | + home=9; | ||
112 | + img.setAttribute("src","pngs/hanhwa.png"); | ||
113 | + } | ||
114 | + else if(a==10){ | ||
115 | + home=10; | ||
116 | + img.setAttribute("src","pngs/Lotte.png"); | ||
117 | + } | ||
118 | + hitter2_option(home); | ||
119 | + pitcher2_option(home); | ||
120 | +} | ||
121 | + | ||
122 | +function hitter1_option(wonjung){ | ||
123 | + var s=""; | ||
124 | + if(wonjung==1){ | ||
125 | + for(var j=1; j<samsung_hitter.length; j++){ | ||
126 | + s+=("<option value="+samsung_hitter[j][0]+">"+samsung_hitter[j][0]+"</option>"); | ||
127 | + } | ||
128 | + } | ||
129 | + else if(wonjung==2){ | ||
130 | + for(var j=1; j<nc_hitter.length; j++){ | ||
131 | + s+=("<option value="+nc_hitter[j][0]+">"+nc_hitter[j][0]+"</option>"); | ||
132 | + } | ||
133 | + } | ||
134 | + else if(wonjung==3){ | ||
135 | + for(var j=1; j<lg_hitter.length; j++){ | ||
136 | + s+=("<option value="+lg_hitter[j][0]+">"+lg_hitter[j][0]+"</option>"); | ||
137 | + } | ||
138 | + } | ||
139 | + else if(wonjung==4){ | ||
140 | + for(var j=1; j<kt_hitter.length; j++){ | ||
141 | + s+=("<option value="+kt_hitter[j][0]+">"+kt_hitter[j][0]+"</option>"); | ||
142 | + } | ||
143 | + } | ||
144 | + else if(wonjung==5){ | ||
145 | + for(var j=1; j<ssg_hitter.length; j++){ | ||
146 | + s+=("<option value="+ssg_hitter[j][0]+">"+ssg_hitter[j][0]+"</option>"); | ||
147 | + } | ||
148 | + } | ||
149 | + else if(wonjung==6){ | ||
150 | + for(var j=1; j<dusan_hitter.length; j++){ | ||
151 | + s+=("<option value="+dusan_hitter[j][0]+">"+dusan_hitter[j][0]+"</option>"); | ||
152 | + } | ||
153 | + } | ||
154 | + else if(wonjung==7){ | ||
155 | + for(var j=1; j<kiwoom_hitter.length; j++){ | ||
156 | + s+=("<option value="+kiwoom_hitter[j][0]+">"+kiwoom_hitter[j][0]+"</option>"); | ||
157 | + } | ||
158 | + } | ||
159 | + else if(wonjung==8){ | ||
160 | + for(var j=1; j<kia_hitter.length; j++){ | ||
161 | + s+=("<option value="+kia_hitter[j][0]+">"+kia_hitter[j][0]+"</option>"); | ||
162 | + } | ||
163 | + } | ||
164 | + else if(wonjung==9){ | ||
165 | + for(var j=1; j<hanhwa_hitter.length; j++){ | ||
166 | + s+=("<option value="+hanhwa_hitter[j][0]+">"+hanhwa_hitter[j][0]+"</option>"); | ||
167 | + } | ||
168 | + } | ||
169 | + else if(wonjung==10){ | ||
170 | + for(var j=1; j<lotte_hitter.length; j++){ | ||
171 | + s+=("<option value="+lotte_hitter[j][0]+">"+lotte_hitter[j][0]+"</option>"); | ||
172 | + } | ||
173 | + } | ||
174 | + document.getElementById('won1').innerHTML=s; | ||
175 | + document.getElementById('won2').innerHTML=s; | ||
176 | + document.getElementById('won3').innerHTML=s; | ||
177 | + document.getElementById('won4').innerHTML=s; | ||
178 | + document.getElementById('won5').innerHTML=s; | ||
179 | + document.getElementById('won6').innerHTML=s; | ||
180 | + document.getElementById('won7').innerHTML=s; | ||
181 | + document.getElementById('won8').innerHTML=s; | ||
182 | + document.getElementById('won9').innerHTML=s; | ||
183 | +} | ||
184 | + | ||
185 | +function hitter2_option(wonjung){ | ||
186 | + var s=""; | ||
187 | + if(wonjung==1){ | ||
188 | + for(var j=1; j<samsung_hitter.length; j++){ | ||
189 | + s+=("<option value="+samsung_hitter[j][0]+">"+samsung_hitter[j][0]+"</option>"); | ||
190 | + } | ||
191 | + } | ||
192 | + else if(wonjung==2){ | ||
193 | + for(var j=1; j<nc_hitter.length; j++){ | ||
194 | + s+=("<option value="+nc_hitter[j][0]+">"+nc_hitter[j][0]+"</option>"); | ||
195 | + } | ||
196 | + } | ||
197 | + else if(wonjung==3){ | ||
198 | + for(var j=1; j<lg_hitter.length; j++){ | ||
199 | + s+=("<option value="+lg_hitter[j][0]+">"+lg_hitter[j][0]+"</option>"); | ||
200 | + } | ||
201 | + } | ||
202 | + else if(wonjung==4){ | ||
203 | + for(var j=1; j<kt_hitter.length; j++){ | ||
204 | + s+=("<option value="+kt_hitter[j][0]+">"+kt_hitter[j][0]+"</option>"); | ||
205 | + } | ||
206 | + } | ||
207 | + else if(wonjung==5){ | ||
208 | + for(var j=1; j<ssg_hitter.length; j++){ | ||
209 | + s+=("<option value="+ssg_hitter[j][0]+">"+ssg_hitter[j][0]+"</option>"); | ||
210 | + } | ||
211 | + } | ||
212 | + else if(wonjung==6){ | ||
213 | + for(var j=1; j<dusan_hitter.length; j++){ | ||
214 | + s+=("<option value="+dusan_hitter[j][0]+">"+dusan_hitter[j][0]+"</option>"); | ||
215 | + } | ||
216 | + } | ||
217 | + else if(wonjung==7){ | ||
218 | + for(var j=1; j<kiwoom_hitter.length; j++){ | ||
219 | + s+=("<option value="+kiwoom_hitter[j][0]+">"+kiwoom_hitter[j][0]+"</option>"); | ||
220 | + } | ||
221 | + } | ||
222 | + else if(wonjung==8){ | ||
223 | + for(var j=1; j<kia_hitter.length; j++){ | ||
224 | + s+=("<option value="+kia_hitter[j][0]+">"+kia_hitter[j][0]+"</option>"); | ||
225 | + } | ||
226 | + } | ||
227 | + else if(wonjung==9){ | ||
228 | + for(var j=1; j<hanhwa_hitter.length; j++){ | ||
229 | + s+=("<option value="+hanhwa_hitter[j][0]+">"+hanhwa_hitter[j][0]+"</option>"); | ||
230 | + } | ||
231 | + } | ||
232 | + else if(wonjung==10){ | ||
233 | + for(var j=1; j<lotte_hitter.length; j++){ | ||
234 | + s+=("<option value="+lotte_hitter[j][0]+">"+lotte_hitter[j][0]+"</option>"); | ||
235 | + } | ||
236 | + } | ||
237 | + document.getElementById('hom1').innerHTML=s; | ||
238 | + document.getElementById('hom2').innerHTML=s; | ||
239 | + document.getElementById('hom3').innerHTML=s; | ||
240 | + document.getElementById('hom4').innerHTML=s; | ||
241 | + document.getElementById('hom5').innerHTML=s; | ||
242 | + document.getElementById('hom6').innerHTML=s; | ||
243 | + document.getElementById('hom7').innerHTML=s; | ||
244 | + document.getElementById('hom8').innerHTML=s; | ||
245 | + document.getElementById('hom9').innerHTML=s; | ||
246 | +} | ||
247 | + | ||
248 | +function pitcher1_option(wonjung){ | ||
249 | + var s=""; | ||
250 | + if(wonjung==1){ | ||
251 | + for(var j=1; j<samsung_pitcher.length; j++){ | ||
252 | + s+=("<option value="+samsung_pitcher[j][0]+">"+samsung_pitcher[j][0]+"</option>"); | ||
253 | + } | ||
254 | + } | ||
255 | + else if(wonjung==2){ | ||
256 | + for(var j=1; j<nc_pitcher.length; j++){ | ||
257 | + s+=("<option value="+nc_pitcher[j][0]+">"+nc_pitcher[j][0]+"</option>"); | ||
258 | + } | ||
259 | + } | ||
260 | + else if(wonjung==3){ | ||
261 | + for(var j=1; j<lg_pitcher.length; j++){ | ||
262 | + s+=("<option value="+lg_pitcher[j][0]+">"+lg_pitcher[j][0]+"</option>"); | ||
263 | + } | ||
264 | + } | ||
265 | + else if(wonjung==4){ | ||
266 | + for(var j=1; j<kt_pitcher.length; j++){ | ||
267 | + s+=("<option value="+kt_pitcher[j][0]+">"+kt_pitcher[j][0]+"</option>"); | ||
268 | + } | ||
269 | + } | ||
270 | + else if(wonjung==5){ | ||
271 | + for(var j=1; j<ssg_pitcher.length; j++){ | ||
272 | + s+=("<option value="+ssg_pitcher[j][0]+">"+ssg_pitcher[j][0]+"</option>"); | ||
273 | + } | ||
274 | + } | ||
275 | + else if(wonjung==6){ | ||
276 | + for(var j=1; j<dusan_pitcher.length; j++){ | ||
277 | + s+=("<option value="+dusan_pitcher[j][0]+">"+dusan_pitcher[j][0]+"</option>"); | ||
278 | + } | ||
279 | + } | ||
280 | + else if(wonjung==7){ | ||
281 | + for(var j=1; j<kiwoom_pitcher.length; j++){ | ||
282 | + s+=("<option value="+kiwoom_pitcher[j][0]+">"+kiwoom_pitcher[j][0]+"</option>"); | ||
283 | + } | ||
284 | + } | ||
285 | + else if(wonjung==8){ | ||
286 | + for(var j=1; j<kia_pitcher.length; j++){ | ||
287 | + s+=("<option value="+kia_pitcher[j][0]+">"+kia_pitcher[j][0]+"</option>"); | ||
288 | + } | ||
289 | + } | ||
290 | + else if(wonjung==9){ | ||
291 | + for(var j=1; j<hanhwa_pitcher.length; j++){ | ||
292 | + s+=("<option value="+hanhwa_pitcher[j][0]+">"+hanhwa_pitcher[j][0]+"</option>"); | ||
293 | + } | ||
294 | + } | ||
295 | + else if(wonjung==10){ | ||
296 | + for(var j=1; j<lotte_pitcher.length; j++){ | ||
297 | + s+=("<option value="+lotte_pitcher[j][0]+">"+lotte_pitcher[j][0]+"</option>"); | ||
298 | + } | ||
299 | + } | ||
300 | + document.getElementById('won').innerHTML=s; | ||
301 | +} | ||
302 | + | ||
303 | +function pitcher2_option(wonjung){ | ||
304 | + var s=""; | ||
305 | + if(wonjung==1){ | ||
306 | + for(var j=1; j<samsung_pitcher.length; j++){ | ||
307 | + s+=("<option value="+samsung_pitcher[j][0]+">"+samsung_pitcher[j][0]+"</option>"); | ||
308 | + } | ||
309 | + } | ||
310 | + else if(wonjung==2){ | ||
311 | + for(var j=1; j<nc_pitcher.length; j++){ | ||
312 | + s+=("<option value="+nc_pitcher[j][0]+">"+nc_pitcher[j][0]+"</option>"); | ||
313 | + } | ||
314 | + } | ||
315 | + else if(wonjung==3){ | ||
316 | + for(var j=1; j<lg_pitcher.length; j++){ | ||
317 | + s+=("<option value="+lg_pitcher[j][0]+">"+lg_pitcher[j][0]+"</option>"); | ||
318 | + } | ||
319 | + } | ||
320 | + else if(wonjung==4){ | ||
321 | + for(var j=1; j<kt_pitcher.length; j++){ | ||
322 | + s+=("<option value="+kt_pitcher[j][0]+">"+kt_pitcher[j][0]+"</option>"); | ||
323 | + } | ||
324 | + } | ||
325 | + else if(wonjung==5){ | ||
326 | + for(var j=1; j<ssg_pitcher.length; j++){ | ||
327 | + s+=("<option value="+ssg_pitcher[j][0]+">"+ssg_pitcher[j][0]+"</option>"); | ||
328 | + } | ||
329 | + } | ||
330 | + else if(wonjung==6){ | ||
331 | + for(var j=1; j<dusan_pitcher.length; j++){ | ||
332 | + s+=("<option value="+dusan_pitcher[j][0]+">"+dusan_pitcher[j][0]+"</option>"); | ||
333 | + } | ||
334 | + } | ||
335 | + else if(wonjung==7){ | ||
336 | + for(var j=1; j<kiwoom_pitcher.length; j++){ | ||
337 | + s+=("<option value="+kiwoom_pitcher[j][0]+">"+kiwoom_pitcher[j][0]+"</option>"); | ||
338 | + } | ||
339 | + } | ||
340 | + else if(wonjung==8){ | ||
341 | + for(var j=1; j<kia_pitcher.length; j++){ | ||
342 | + s+=("<option value="+kia_pitcher[j][0]+">"+kia_pitcher[j][0]+"</option>"); | ||
343 | + } | ||
344 | + } | ||
345 | + else if(wonjung==9){ | ||
346 | + for(var j=1; j<hanhwa_pitcher.length; j++){ | ||
347 | + s+=("<option value="+hanhwa_pitcher[j][0]+">"+hanhwa_pitcher[j][0]+"</option>"); | ||
348 | + } | ||
349 | + } | ||
350 | + else if(wonjung==10){ | ||
351 | + for(var j=1; j<lotte_pitcher.length; j++){ | ||
352 | + s+=("<option value="+lotte_pitcher[j][0]+">"+lotte_pitcher[j][0]+"</option>"); | ||
353 | + } | ||
354 | + } | ||
355 | + document.getElementById('hom').innerHTML=s; | ||
356 | +} | ||
357 | + | ||
358 | +function hitter1list_append(num, value){ | ||
359 | + if(wonjung==1){ | ||
360 | + for(var j=1; j<samsung_hitter.length; j++){ | ||
361 | + if(value==samsung_hitter[j][0]){ | ||
362 | + for(var k=0; k<samsung_hitter[j].length; k++){ | ||
363 | + hitter_list1[num][k]=samsung_hitter[j][k]; | ||
364 | + } | ||
365 | + return; | ||
366 | + } | ||
367 | + } | ||
368 | + } | ||
369 | + else if(wonjung==2){ | ||
370 | + for(var j=1; j<nc_hitter.length; j++){ | ||
371 | + if(value==nc_hitter[j][0]){ | ||
372 | + for(var k=0; k<nc_hitter[j].length; k++){ | ||
373 | + hitter_list1[num][k]=nc_hitter[j][k]; | ||
374 | + } | ||
375 | + return; | ||
376 | + } | ||
377 | + } | ||
378 | + } | ||
379 | + else if(wonjung==3){ | ||
380 | + for(var j=1; j<lg_hitter.length; j++){ | ||
381 | + if(value==lg_hitter[j][0]){ | ||
382 | + for(var k=0; k<lg_hitter[j].length; k++){ | ||
383 | + hitter_list1[num][k]=lg_hitter[j][k]; | ||
384 | + } | ||
385 | + return; | ||
386 | + } | ||
387 | + } | ||
388 | + } | ||
389 | + else if(wonjung==4){ | ||
390 | + for(var j=1; j<kt_hitter.length; j++){ | ||
391 | + if(value==kt_hitter[j][0]){ | ||
392 | + for(var k=0; k<kt_hitter[j].length; k++){ | ||
393 | + hitter_list1[num][k]=kt_hitter[j][k]; | ||
394 | + } | ||
395 | + return; | ||
396 | + } | ||
397 | + } | ||
398 | + } | ||
399 | + else if(wonjung==5){ | ||
400 | + for(var j=1; j<ssg_hitter.length; j++){ | ||
401 | + if(value==ssg_hitter[j][0]){ | ||
402 | + for(var k=0; k<ssg_hitter[j].length; k++){ | ||
403 | + hitter_list1[num][k]=ssg_hitter[j][k]; | ||
404 | + } | ||
405 | + return; | ||
406 | + } | ||
407 | + } | ||
408 | + } | ||
409 | + else if(wonjung==6){ | ||
410 | + for(var j=1; j<dusan_hitter.length; j++){ | ||
411 | + if(value==dusan_hitter[j][0]){ | ||
412 | + for(var k=0; k<dusan_hitter[j].length; k++){ | ||
413 | + hitter_list1[num][k]=dusan_hitter[j][k]; | ||
414 | + } | ||
415 | + return; | ||
416 | + } | ||
417 | + } | ||
418 | + } | ||
419 | + else if(wonjung==7){ | ||
420 | + for(var j=1; j<kiwoom_hitter.length; j++){ | ||
421 | + if(value==kiwoom_hitter[j][0]){ | ||
422 | + for(var k=0; k<kiwoom_hitter[j].length; k++){ | ||
423 | + hitter_list1[num][k]=kiwoom_hitter[j][k]; | ||
424 | + } | ||
425 | + return; | ||
426 | + } | ||
427 | + } | ||
428 | + } | ||
429 | + else if(wonjung==8){ | ||
430 | + for(var j=1; j<kia_hitter.length; j++){ | ||
431 | + if(value==kia_hitter[j][0]){ | ||
432 | + for(var k=0; k<kia_hitter[j].length; k++){ | ||
433 | + hitter_list1[num][k]=kia_hitter[j][k]; | ||
434 | + } | ||
435 | + return; | ||
436 | + } | ||
437 | + } | ||
438 | + } | ||
439 | + else if(wonjung==9){ | ||
440 | + for(var j=1; j<hanhwa_hitter.length; j++){ | ||
441 | + if(value==hanhwa_hitter[j][0]){ | ||
442 | + for(var k=0; k<hanhwa_hitter[j].length; k++){ | ||
443 | + hitter_list1[num][k]=hanhwa_hitter[j][k]; | ||
444 | + } | ||
445 | + return; | ||
446 | + } | ||
447 | + } | ||
448 | + } | ||
449 | + else if(wonjung==10){ | ||
450 | + for(var j=1; j<lotte_hitter.length; j++){ | ||
451 | + if(value==lotte_hitter[j][0]){ | ||
452 | + for(var k=0; k<lotte_hitter[j].length; k++){ | ||
453 | + hitter_list1[num][k]=lotte_hitter[j][k]; | ||
454 | + } | ||
455 | + return; | ||
456 | + } | ||
457 | + } | ||
458 | + } | ||
459 | +} | ||
460 | + | ||
461 | +function hitter2list_append(num, value){ | ||
462 | + if(home==1){ | ||
463 | + for(var j=1; j<samsung_hitter.length; j++){ | ||
464 | + if(value==samsung_hitter[j][0]){ | ||
465 | + for(var k=0; k<samsung_hitter[j].length; k++){ | ||
466 | + hitter_list2[num][k]=samsung_hitter[j][k]; | ||
467 | + } | ||
468 | + return; | ||
469 | + } | ||
470 | + } | ||
471 | + } | ||
472 | + else if(home==2){ | ||
473 | + for(var j=1; j<nc_hitter.length; j++){ | ||
474 | + if(value==nc_hitter[j][0]){ | ||
475 | + for(var k=0; k<nc_hitter[j].length; k++){ | ||
476 | + hitter_list2[num][k]=nc_hitter[j][k]; | ||
477 | + } | ||
478 | + return; | ||
479 | + } | ||
480 | + } | ||
481 | + } | ||
482 | + else if(home==3){ | ||
483 | + for(var j=1; j<lg_hitter.length; j++){ | ||
484 | + if(value==lg_hitter[j][0]){ | ||
485 | + for(var k=0; k<lg_hitter[j].length; k++){ | ||
486 | + hitter_list2[num][k]=lg_hitter[j][k]; | ||
487 | + } | ||
488 | + return; | ||
489 | + } | ||
490 | + } | ||
491 | + } | ||
492 | + else if(home==4){ | ||
493 | + for(var j=1; j<kt_hitter.length; j++){ | ||
494 | + if(value==kt_hitter[j][0]){ | ||
495 | + for(var k=0; k<kt_hitter[j].length; k++){ | ||
496 | + hitter_list2[num][k]=kt_hitter[j][k]; | ||
497 | + } | ||
498 | + return; | ||
499 | + } | ||
500 | + } | ||
501 | + } | ||
502 | + else if(home==5){ | ||
503 | + for(var j=1; j<ssg_hitter.length; j++){ | ||
504 | + if(value==ssg_hitter[j][0]){ | ||
505 | + for(var k=0; k<ssg_hitter[j].length; k++){ | ||
506 | + hitter_list2[num][k]=ssg_hitter[j][k]; | ||
507 | + } | ||
508 | + return; | ||
509 | + } | ||
510 | + } | ||
511 | + } | ||
512 | + else if(home==6){ | ||
513 | + for(var j=1; j<dusan_hitter.length; j++){ | ||
514 | + if(value==dusan_hitter[j][0]){ | ||
515 | + for(var k=0; k<dusan_hitter[j].length; k++){ | ||
516 | + hitter_list2[num][k]=dusan_hitter[j][k]; | ||
517 | + } | ||
518 | + return; | ||
519 | + } | ||
520 | + } | ||
521 | + } | ||
522 | + else if(home==7){ | ||
523 | + for(var j=1; j<kiwoom_hitter.length; j++){ | ||
524 | + if(value==kiwoom_hitter[j][0]){ | ||
525 | + for(var k=0; k<kiwoom_hitter[j].length; k++){ | ||
526 | + hitter_list2[num][k]=kiwoom_hitter[j][k]; | ||
527 | + } | ||
528 | + return; | ||
529 | + } | ||
530 | + } | ||
531 | + } | ||
532 | + else if(home==8){ | ||
533 | + for(var j=1; j<kia_hitter.length; j++){ | ||
534 | + if(value==kia_hitter[j][0]){ | ||
535 | + for(var k=0; k<kia_hitter[j].length; k++){ | ||
536 | + hitter_list2[num][k]=kia_hitter[j][k]; | ||
537 | + } | ||
538 | + return; | ||
539 | + } | ||
540 | + } | ||
541 | + } | ||
542 | + else if(home==9){ | ||
543 | + for(var j=1; j<hanhwa_hitter.length; j++){ | ||
544 | + if(value==hanhwa_hitter[j][0]){ | ||
545 | + for(var k=0; k<hanhwa_hitter[j].length; k++){ | ||
546 | + hitter_list2[num][k]=hanhwa_hitter[j][k]; | ||
547 | + } | ||
548 | + return; | ||
549 | + } | ||
550 | + } | ||
551 | + } | ||
552 | + else if(home==10){ | ||
553 | + for(var j=1; j<lotte_hitter.length; j++){ | ||
554 | + if(value==lotte_hitter[j][0]){ | ||
555 | + for(var k=0; k<lotte_hitter[j].length; k++){ | ||
556 | + hitter_list2[num][k]=lotte_hitter[j][k]; | ||
557 | + } | ||
558 | + return; | ||
559 | + } | ||
560 | + } | ||
561 | + } | ||
562 | +} | ||
563 | + | ||
564 | +function pitcher1list_append(value){ | ||
565 | + if(wonjung==1){ | ||
566 | + for(var j=1; j<samsung_pitcher.length; j++){ | ||
567 | + if(value==samsung_pitcher[j][0]){ | ||
568 | + for(var k=0; k<samsung_pitcher[j].length; k++){ | ||
569 | + pitcher1[k]=samsung_pitcher[j][k]; | ||
570 | + } | ||
571 | + return; | ||
572 | + } | ||
573 | + } | ||
574 | + } | ||
575 | + else if(wonjung==2){ | ||
576 | + for(var j=1; j<nc_pitcher.length; j++){ | ||
577 | + if(value==nc_pitcher[j][0]){ | ||
578 | + for(var k=0; k<nc_pitcher[j].length; k++){ | ||
579 | + pitcher1[k]=nc_pitcher[j][k]; | ||
580 | + } | ||
581 | + return; | ||
582 | + } | ||
583 | + } | ||
584 | + } | ||
585 | + else if(wonjung==3){ | ||
586 | + for(var j=1; j<lg_pitcher.length; j++){ | ||
587 | + if(value==lg_pitcher[j][0]){ | ||
588 | + for(var k=0; k<lg_pitcher[j].length; k++){ | ||
589 | + pitcher1[k]=lg_pitcher[j][k]; | ||
590 | + } | ||
591 | + return; | ||
592 | + } | ||
593 | + } | ||
594 | + } | ||
595 | + else if(wonjung==4){ | ||
596 | + for(var j=1; j<kt_pitcher.length; j++){ | ||
597 | + if(value==kt_pitcher[j][0]){ | ||
598 | + for(var k=0; k<kt_pitcher[j].length; k++){ | ||
599 | + pitcher1[k]=kt_pitcher[j][k]; | ||
600 | + } | ||
601 | + return; | ||
602 | + } | ||
603 | + } | ||
604 | + } | ||
605 | + else if(wonjung==5){ | ||
606 | + for(var j=1; j<ssg_pitcher.length; j++){ | ||
607 | + if(value==ssg_pitcher[j][0]){ | ||
608 | + for(var k=0; k<ssg_pitcher[j].length; k++){ | ||
609 | + pitcher1[k]=ssg_pitcher[j][k]; | ||
610 | + } | ||
611 | + return; | ||
612 | + } | ||
613 | + } | ||
614 | + } | ||
615 | + else if(wonjung==6){ | ||
616 | + for(var j=1; j<dusan_pitcher.length; j++){ | ||
617 | + if(value==dusan_pitcher[j][0]){ | ||
618 | + for(var k=0; k<dusan_pitcher[j].length; k++){ | ||
619 | + pitcher1[k]=dusan_pitcher[j][k]; | ||
620 | + } | ||
621 | + return; | ||
622 | + } | ||
623 | + } | ||
624 | + } | ||
625 | + else if(wonjung==7){ | ||
626 | + for(var j=1; j<kiwoom_pitcher.length; j++){ | ||
627 | + if(value==kiwoom_pitcher[j][0]){ | ||
628 | + for(var k=0; k<kiwoom_pitcher[j].length; k++){ | ||
629 | + pitcher1[k]=kiwoom_pitcher[j][k]; | ||
630 | + } | ||
631 | + return; | ||
632 | + } | ||
633 | + } | ||
634 | + } | ||
635 | + else if(wonjung==8){ | ||
636 | + for(var j=1; j<kia_pitcher.length; j++){ | ||
637 | + if(value==kia_pitcher[j][0]){ | ||
638 | + for(var k=0; k<kia_pitcher[j].length; k++){ | ||
639 | + pitcher1[k]=kia_pitcher[j][k]; | ||
640 | + } | ||
641 | + return; | ||
642 | + } | ||
643 | + } | ||
644 | + } | ||
645 | + else if(wonjung==9){ | ||
646 | + for(var j=1; j<hanhwa_pitcher.length; j++){ | ||
647 | + if(value==hanhwa_pitcher[j][0]){ | ||
648 | + for(var k=0; k<hanhwa_pitcher[j].length; k++){ | ||
649 | + pitcher1[k]=hanhwa_pitcher[j][k]; | ||
650 | + } | ||
651 | + return; | ||
652 | + } | ||
653 | + } | ||
654 | + } | ||
655 | + else if(wonjung==10){ | ||
656 | + for(var j=1; j<lotte_pitcher.length; j++){ | ||
657 | + if(value==lotte_pitcher[j][0]){ | ||
658 | + for(var k=0; k<lotte_pitcher[j].length; k++){ | ||
659 | + pitcher1[k]=lotte_pitcher[j][k]; | ||
660 | + } | ||
661 | + return; | ||
662 | + } | ||
663 | + } | ||
664 | + } | ||
665 | +} | ||
666 | + | ||
667 | +function pitcher2list_append(value){ | ||
668 | + if(home==1){ | ||
669 | + for(var j=1; j<samsung_pitcher.length; j++){ | ||
670 | + if(value==samsung_pitcher[j][0]){ | ||
671 | + for(var k=0; k<samsung_pitcher[j].length; k++){ | ||
672 | + pitcher2[k]=samsung_pitcher[j][k]; | ||
673 | + } | ||
674 | + return; | ||
675 | + } | ||
676 | + } | ||
677 | + } | ||
678 | + else if(home==2){ | ||
679 | + for(var j=1; j<nc_pitcher.length; j++){ | ||
680 | + if(value==nc_pitcher[j][0]){ | ||
681 | + for(var k=0; k<nc_pitcher[j].length; k++){ | ||
682 | + pitcher2[k]=nc_pitcher[j][k]; | ||
683 | + } | ||
684 | + return; | ||
685 | + } | ||
686 | + } | ||
687 | + } | ||
688 | + else if(home==3){ | ||
689 | + for(var j=1; j<lg_pitcher.length; j++){ | ||
690 | + if(value==lg_pitcher[j][0]){ | ||
691 | + for(var k=0; k<lg_pitcher[j].length; k++){ | ||
692 | + pitcher2[k]=lg_pitcher[j][k]; | ||
693 | + } | ||
694 | + return; | ||
695 | + } | ||
696 | + } | ||
697 | + } | ||
698 | + else if(home==4){ | ||
699 | + for(var j=1; j<kt_pitcher.length; j++){ | ||
700 | + if(value==kt_pitcher[j][0]){ | ||
701 | + for(var k=0; k<kt_pitcher[j].length; k++){ | ||
702 | + pitcher2[k]=kt_pitcher[j][k]; | ||
703 | + } | ||
704 | + return; | ||
705 | + } | ||
706 | + } | ||
707 | + } | ||
708 | + else if(home==5){ | ||
709 | + for(var j=1; j<ssg_pitcher.length; j++){ | ||
710 | + if(value==ssg_pitcher[j][0]){ | ||
711 | + for(var k=0; k<ssg_pitcher[j].length; k++){ | ||
712 | + pitcher2[k]=ssg_pitcher[j][k]; | ||
713 | + } | ||
714 | + return; | ||
715 | + } | ||
716 | + } | ||
717 | + } | ||
718 | + else if(home==6){ | ||
719 | + for(var j=1; j<dusan_pitcher.length; j++){ | ||
720 | + if(value==dusan_pitcher[j][0]){ | ||
721 | + for(var k=0; k<dusan_pitcher[j].length; k++){ | ||
722 | + pitcher2[k]=dusan_pitcher[j][k]; | ||
723 | + } | ||
724 | + return; | ||
725 | + } | ||
726 | + } | ||
727 | + } | ||
728 | + else if(home==7){ | ||
729 | + for(var j=1; j<kiwoom_pitcher.length; j++){ | ||
730 | + if(value==kiwoom_pitcher[j][0]){ | ||
731 | + for(var k=0; k<kiwoom_pitcher[j].length; k++){ | ||
732 | + pitcher2[k]=kiwoom_pitcher[j][k]; | ||
733 | + } | ||
734 | + return; | ||
735 | + } | ||
736 | + } | ||
737 | + } | ||
738 | + else if(home==8){ | ||
739 | + for(var j=1; j<kia_pitcher.length; j++){ | ||
740 | + if(value==kia_pitcher[j][0]){ | ||
741 | + for(var k=0; k<kia_pitcher[j].length; k++){ | ||
742 | + pitcher2[k]=kia_pitcher[j][k]; | ||
743 | + } | ||
744 | + return; | ||
745 | + } | ||
746 | + } | ||
747 | + } | ||
748 | + else if(home==9){ | ||
749 | + for(var j=1; j<hanhwa_pitcher.length; j++){ | ||
750 | + if(value==hanhwa_pitcher[j][0]){ | ||
751 | + for(var k=0; k<hanhwa_pitcher[j].length; k++){ | ||
752 | + pitcher2[k]=hanhwa_pitcher[j][k]; | ||
753 | + } | ||
754 | + return; | ||
755 | + } | ||
756 | + } | ||
757 | + } | ||
758 | + else if(home==10){ | ||
759 | + for(var j=1; j<lotte_pitcher.length; j++){ | ||
760 | + if(value==lotte_pitcher[j][0]){ | ||
761 | + for(var k=0; k<lotte_pitcher[j].length; k++){ | ||
762 | + pitcher2[k]=lotte_pitcher[j][k]; | ||
763 | + } | ||
764 | + return; | ||
765 | + } | ||
766 | + } | ||
767 | + } | ||
768 | +} | ||
769 | +hitter1_option(wonjung); | ||
770 | +pitcher1_option(wonjung); | ||
771 | +hitter2_option(home); | ||
772 | +pitcher2_option(home); | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
temp_algorithm.js
0 → 100644
1 | +function pre_algorithm(hitter_list1, hitter_list2, pitcher1, pitcher2){//algorithm(hitter_list1, hitter_list2, pitcher1, pitcher2) => html에서 가지고와야 한다. | ||
2 | + var base1 = 0; var base2 = 0; var base3 = 0; //1이면 주자 있고 0이면 비어있는것 | ||
3 | + var out = 0; var ining = 1; var home_away = 1;//아웃카운트, 이닝, home이면 1이고 away이면 2. | ||
4 | + var score1 = 0; var score2 = 0; | ||
5 | + var hitter_num1 = 1; var hitter_num2 = 1; | ||
6 | + var hit=false; | ||
7 | + document.getElementById('jstest').innerHTML=""; | ||
8 | + while(true){ | ||
9 | + if(ining == 9 && home_away == 2 && score1 < score2){//9회 초 후 home팀이 이기고 있을 때! | ||
10 | + break; | ||
11 | + } | ||
12 | + else if(ining==10 && home_away==1 && score1>score2 && hit==false){//9회 말 후 home팀이 이기고 있을 때! | ||
13 | + break; | ||
14 | + } | ||
15 | + else if(ining>9 && score1 < score2){//9회 말 후 home팀이 이기고 있을 때! | ||
16 | + break; | ||
17 | + } | ||
18 | + else if(ining>=11 && home_away==1 && hit==false && score1>score2){//연장 이후 원정팀이 이기고 있을 때! | ||
19 | + break; | ||
20 | + } | ||
21 | + else if(ining>=10 && home_away==2 && hit==true && score1<score2){//끝내기 | ||
22 | + break; | ||
23 | + } | ||
24 | + else if(ining==13 && score1==score2){//무승부 | ||
25 | + break; | ||
26 | + } | ||
27 | + | ||
28 | + if(home_away == 1){ | ||
29 | + var hitter = hitter_list1[hitter_num1]; //hitter = hitter_list1[hitter_number1%9] | ||
30 | + var pitcher = pitcher2; //pitcher = pitcher1 | ||
31 | + document.getElementById('jstest').innerHTML+=(ining+ "회 초"+ "<br\><br\>"); | ||
32 | + } | ||
33 | + else if(home_away == 2){ | ||
34 | + var hitter = hitter_list2[hitter_num2]; //hitter = hitter_list2[hitter_number2%9] | ||
35 | + var pitcher = pitcher1; //pitcher = pitcher2 | ||
36 | + document.getElementById('jstest').innerHTML+=(ining+ "회 말"+ "<br\><br\>"); | ||
37 | + } | ||
38 | + | ||
39 | + var num = Math.random(); | ||
40 | + //hitter_number1 = hitter_number(kia); hitter_number2 = hitter_number(dusan); | ||
41 | + if(home_away == 1){ | ||
42 | + document.getElementById('jstest').innerHTML+=(hitter_num1+"번 타자: "+hitter[0]+ "<br\><br\>"); | ||
43 | + } | ||
44 | + else if(home_away == 2){ | ||
45 | + document.getElementById('jstest').innerHTML+=(hitter_num2+"번 타자: "+hitter[0]+ "<br\><br\>"); | ||
46 | + } | ||
47 | + var one = 0; var two = 0; var three = 0; var homerun = 0; | ||
48 | + one = pitcher[2] * (hitter[2] - hitter[3] - hitter[4] - hitter[5])/hitter[2]; | ||
49 | + two = pitcher[2] * hitter[3]/hitter[2]; | ||
50 | + three = pitcher[2] * hitter[4]/hitter[2]; | ||
51 | + homerun = pitcher[2] * hitter[5]/hitter[2]; | ||
52 | + hit=true; | ||
53 | + if(num <= one){ //안타 | ||
54 | + var num1 = Math.random(); | ||
55 | + if(num1 <= 0.5){ | ||
56 | + switch(home_away){ | ||
57 | + case 1: | ||
58 | + score1 = score1 + base3; | ||
59 | + break; | ||
60 | + case 2: | ||
61 | + score2 = score2 + base3; | ||
62 | + break; | ||
63 | + } | ||
64 | + base3 = base2; | ||
65 | + base2 = base1; | ||
66 | + base1 = 1; | ||
67 | + document.getElementById('jstest').innerHTML+=("1루타!"); | ||
68 | + | ||
69 | + } | ||
70 | + else{ | ||
71 | + switch(home_away){ | ||
72 | + case 1: | ||
73 | + score1 = score1 + base3 + base2; | ||
74 | + break; | ||
75 | + case 2: | ||
76 | + score2 = score2 + base3 + base2; | ||
77 | + break; | ||
78 | + } | ||
79 | + base3 = base1; | ||
80 | + base2 = 0; | ||
81 | + base1 = 1; | ||
82 | + document.getElementById('jstest').innerHTML+=("1루타!"); | ||
83 | + | ||
84 | + } | ||
85 | + | ||
86 | + } | ||
87 | + else if((one < num) && (num <= one + two)){//2루타 | ||
88 | + var num2 = Math.random(); | ||
89 | + if(num2 <= 0.4){ | ||
90 | + switch(home_away){ | ||
91 | + case 1: | ||
92 | + score1 = score1 + base3 + base2; | ||
93 | + break; | ||
94 | + case 2: | ||
95 | + score2 = score2 + base3 + base2; | ||
96 | + break; | ||
97 | + } | ||
98 | + base3 = base1; | ||
99 | + base2 = 1; | ||
100 | + base1 = 0; | ||
101 | + document.getElementById('jstest').innerHTML+=("2루타!"); | ||
102 | + | ||
103 | + } | ||
104 | + else if(0.4 < num2 && num2 <=0.7){ | ||
105 | + switch(home_away){ | ||
106 | + case 1: | ||
107 | + score1 = score1 + base3 + base2 + base1; | ||
108 | + break; | ||
109 | + case 2: | ||
110 | + score2 = score2 + base3 + base2 + base1; | ||
111 | + break; | ||
112 | + } | ||
113 | + base3 = 0; | ||
114 | + base2 = 1; | ||
115 | + base1 = 0; | ||
116 | + document.getElementById('jstest').innerHTML+=("2루타!"); | ||
117 | + | ||
118 | + } | ||
119 | + else{ | ||
120 | + switch(home_away){ | ||
121 | + case 1: | ||
122 | + score1 = score1 + base3 + base2; | ||
123 | + break; | ||
124 | + case 2: | ||
125 | + score2 = score2 + base3 + base2; | ||
126 | + break; | ||
127 | + } | ||
128 | + base3 = 0; | ||
129 | + base2 = 1; | ||
130 | + base1 = 0; | ||
131 | + | ||
132 | + document.getElementById('jstest').innerHTML+=("2루타!"); | ||
133 | + | ||
134 | + } | ||
135 | + | ||
136 | + } | ||
137 | + else if((one + two < num) && (num <= one + two + three)){//3루타 | ||
138 | + switch(home_away){ | ||
139 | + case 1: | ||
140 | + score1 = score1 + base3 + base2 + base1; | ||
141 | + break; | ||
142 | + case 2: | ||
143 | + score2 = score2 + base3 + base2 + base1; | ||
144 | + break; | ||
145 | + } | ||
146 | + base3 = 1; | ||
147 | + base2 = 0; | ||
148 | + base1 = 0; | ||
149 | + document.getElementById('jstest').innerHTML+=("3루타!"); | ||
150 | + | ||
151 | + } | ||
152 | + else if(one + two + three < num && num <= one + two + three + homerun){//홈런 | ||
153 | + switch(home_away){ | ||
154 | + case 1: | ||
155 | + score1 = score1 + base3 + base2 + base1 + 1; | ||
156 | + break; | ||
157 | + case 2: | ||
158 | + score2 = score2 + base3 + base2 + base1 + 1; | ||
159 | + break; | ||
160 | + } | ||
161 | + base3 = 0; | ||
162 | + base2 = 0; | ||
163 | + base1 = 0; | ||
164 | + document.getElementById('jstest').innerHTML+=("홈런!"); | ||
165 | + | ||
166 | + } | ||
167 | + | ||
168 | + | ||
169 | + else if( pitcher[2] < num && (num <= pitcher[2] +pitcher[1]*0.01)){//볼넷 | ||
170 | + if(base1==1 && base2==1 && base3==1){//만루 밀어내기 득점 -> 스코어 ++ | ||
171 | + if(home_away==1){ | ||
172 | + score1++; | ||
173 | + } | ||
174 | + else{ | ||
175 | + score2++; | ||
176 | + } | ||
177 | + } | ||
178 | + else{//스코어 추가되지 않는 경우 | ||
179 | + if((base2==1 && base1==0 )||(base3==1 && base1==0)||(base2==1&&base3==1&&base1==0)){//2루만 채워져있거나 3루만 채워져있거나 2,3루만 채워져있거나 | ||
180 | + base1=1; | ||
181 | + } | ||
182 | + else if(base1==1 && base3==1 && base2==0){//1루 3루 채워져있고 2루 비워져있거나 | ||
183 | + base2=base1; | ||
184 | + base1=1; | ||
185 | + } | ||
186 | + else{ | ||
187 | + base3 = base2; | ||
188 | + base2 = base1; | ||
189 | + base1 = 1; | ||
190 | + } | ||
191 | + } | ||
192 | + document.getElementById('jstest').innerHTML+=("볼넷!"); | ||
193 | + } | ||
194 | + | ||
195 | + else{//아웃 | ||
196 | + var ran = Math.random()*0.2; | ||
197 | + if(ran>0.197){ | ||
198 | + switch(home_away){ | ||
199 | + case 1: | ||
200 | + score1 = score1 + base3 + base2 + base1 + 1; | ||
201 | + break; | ||
202 | + case 2: | ||
203 | + score2 = score2 + base3 + base2 + base1 + 1; | ||
204 | + break; | ||
205 | + } | ||
206 | + base3 = 0; | ||
207 | + base2 = 0; | ||
208 | + base1 = 0; | ||
209 | + document.getElementById('jstest').innerHTML+=("홈런!"); | ||
210 | + }else if(ran>0.1955){ | ||
211 | + switch(home_away){ | ||
212 | + case 1: | ||
213 | + score1 = score1 + base3 + base2 + base1; | ||
214 | + break; | ||
215 | + case 2: | ||
216 | + score2 = score2 + base3 + base2 + base1; | ||
217 | + break; | ||
218 | + } | ||
219 | + base3 = 1; | ||
220 | + base2 = 0; | ||
221 | + base1 = 0; | ||
222 | + document.getElementById('jstest').innerHTML+=("3루타!"); | ||
223 | + }else if(ran>0.18){ | ||
224 | + var n = Math.random(); | ||
225 | + if(n <= 0.4){ | ||
226 | + switch(home_away){ | ||
227 | + case 1: | ||
228 | + score1 = score1 + base3 + base2; | ||
229 | + break; | ||
230 | + case 2: | ||
231 | + score2 = score2 + base3 + base2; | ||
232 | + break; | ||
233 | + } | ||
234 | + base3 = base1; | ||
235 | + base2 = 1; | ||
236 | + base1 = 0; | ||
237 | + document.getElementById('jstest').innerHTML+=("2루타!"); | ||
238 | + | ||
239 | + } | ||
240 | + else if(0.4 < n && n <=0.7){ | ||
241 | + switch(home_away){ | ||
242 | + case 1: | ||
243 | + score1 = score1 + base3 + base2 + base1; | ||
244 | + break; | ||
245 | + case 2: | ||
246 | + score2 = score2 + base3 + base2 + base1; | ||
247 | + break; | ||
248 | + } | ||
249 | + base3 = 0; | ||
250 | + base2 = 1; | ||
251 | + base1 = 0; | ||
252 | + document.getElementById('jstest').innerHTML+=("2루타!"); | ||
253 | + | ||
254 | + } | ||
255 | + else{ | ||
256 | + switch(home_away){ | ||
257 | + case 1: | ||
258 | + score1 = score1 + base3 + base2; | ||
259 | + break; | ||
260 | + case 2: | ||
261 | + score2 = score2 + base3 + base2; | ||
262 | + break; | ||
263 | + } | ||
264 | + base3 = 0; | ||
265 | + base2 = 1; | ||
266 | + base1 = 0; | ||
267 | + | ||
268 | + document.getElementById('jstest').innerHTML+=("2루타!"); | ||
269 | + } | ||
270 | + }else{ | ||
271 | + out++; | ||
272 | + document.getElementById('jstest').innerHTML+=("아웃!"); | ||
273 | + } | ||
274 | + | ||
275 | + } | ||
276 | + | ||
277 | + document.getElementById('jstest').innerHTML+=("베이스 상태"+"<br\>"+ "1루 " + base1 + "<br\>"+"2루 " + base2 + "<br\>"+ | ||
278 | + "3루 " + base3 + "<br\><br\>");/////////////////////////// | ||
279 | + document.getElementById('jstest').innerHTML+=("score: "+score1 +"vs"+score2+ "<br\>"); | ||
280 | + document.getElementById('jstest').innerHTML+=("아웃카운트: "+out+"<br\><br\>"); | ||
281 | + if(out >= 3){ | ||
282 | + switch(home_away){ | ||
283 | + case 1: | ||
284 | + home_away = 2; | ||
285 | + hit=false; | ||
286 | + break; | ||
287 | + case 2: | ||
288 | + home_away = 1; | ||
289 | + ining++; | ||
290 | + hit=false; | ||
291 | + break; | ||
292 | + } | ||
293 | + out=0; | ||
294 | + base1=0; base2=0; base3=0; | ||
295 | + } | ||
296 | + else{ | ||
297 | + if(home_away == 1){ | ||
298 | + hitter_num1++; | ||
299 | + if(hitter_num1>=10){ | ||
300 | + hitter_num1=1; | ||
301 | + } | ||
302 | + } | ||
303 | + else if(home_away == 2){ | ||
304 | + hitter_num2++; | ||
305 | + if(hitter_num2>=10){ | ||
306 | + hitter_num2=1; | ||
307 | + } | ||
308 | + } | ||
309 | + } | ||
310 | + | ||
311 | + } | ||
312 | + document.getElementById('jstest').innerHTML+=("<br\><br\>"+"최종스코어 : "+score1+"vs"+score2); | ||
313 | + var score = [score1, score2]; | ||
314 | + return score; | ||
315 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or login to post a comment