Showing
3 changed files
with
138 additions
and
6 deletions
aaaa.js
0 → 100644
1 | +function aaaa(){ | ||
2 | + var pitcher = kia_pitcher[1]; //선발투수, 나중에 사용자가 지정해주는 투수로 바뀌도록 수정해야 한다. | ||
3 | + var base1 = 0; base2 = 0; base3 = 0; //1이면 주자 있고 0이면 비어있는것 | ||
4 | + var out = 0; ining = 1; //아웃카운트, 이닝 | ||
5 | + var hitter_number1 = 0; hitter_number2 = 0; //이전 타석 타자 번호 | ||
6 | + var score = 0; score2 = 0; | ||
7 | + document.getElementById('jstest').innerHTML=" "; | ||
8 | + for(i = 0; i < 10; i++){ | ||
9 | + var num = Math.random(); | ||
10 | + document.getElementById('jstest').innerHTML+=(num+" "+"<br\>"); | ||
11 | + //hitter_number1 = hitter_number(kia); hitter_number2 = hitter_number(dusan); | ||
12 | + hitter = kia_hitter[1]; //선발타자, 나중에 사용자가 지정해주는 타자로 바뀌도록 수정해야 한다. | ||
13 | + document.getElementById('jstest').innerHTML+=(hitter[0]+" "); | ||
14 | + var one = 0; var two = 0; var three = 0; var homerun = 0; | ||
15 | + | ||
16 | + if( num <= kia_pitcher[1][2]){ | ||
17 | + one = pitcher[2] * (hitter[2] - hitter[3] - hitter[4] - hitter[5])/hitter[2]; | ||
18 | + two = pitcher[2] * hitter[3]/hitter[2]; | ||
19 | + three = pitcher[2] * hitter[4]/hitter[2]; | ||
20 | + homerun = pitcher[2] * hitter[5]/hitter[2]; | ||
21 | + document.getElementById('jstest').innerHTML+=("확률" + " " + "1루타 " + one+ " "+"2루타 " + | ||
22 | + two+" "+"3루타 "+ three+ " ","홈런 " + homerun, " ");////////////////////////////// | ||
23 | + | ||
24 | + if(num <= one){ //그냥 간단하게 다음 베이스로 한 칸씩 이동하도록 계산, 모든 경우의 수 계산하는게 불가능 | ||
25 | + var num1 = Math.random(); | ||
26 | + if(num1 <= 0.5){ | ||
27 | + score = score + base3; | ||
28 | + base3 = base2; | ||
29 | + base2 = base1; | ||
30 | + base1 = 1; | ||
31 | + document.getElementById('jstest').innerHTML+=("1루타!"); | ||
32 | + document.getElementById('jstest').innerHTML+=("베이스 상태"+" ", "1루 " + base1 + " "+ "2루 " + base2 + " "+ | ||
33 | + "3루 " + base3 + " ");/////////////////////////// | ||
34 | + document.getElementById('jstest').innerHTML+=("score: "+score+ " "); | ||
35 | + } | ||
36 | + if(num1 > 0.5){ | ||
37 | + score = score + base3 + base2; | ||
38 | + base3 = base1; | ||
39 | + base2 = 0; | ||
40 | + base1 = 1; | ||
41 | + document.getElementById('jstest').innerHTML+=("1루타!"); | ||
42 | + document.getElementById('jstest').innerHTML+=("베이스 상태"+" "+ "1루 " + base1 + " "+ "2루 " + base2 + " "+ | ||
43 | + "3루 " + base3 + " ");/////////////////////////// | ||
44 | + document.getElementById('jstest').innerHTML+=("score: "+score+ " "); | ||
45 | + } | ||
46 | + | ||
47 | + } | ||
48 | + else if(one < num && num <= one + two){ | ||
49 | + var num2 = Math.random(); | ||
50 | + if(num2 <= 0.4){ | ||
51 | + score = score + base3 + base2; | ||
52 | + base3 = base1; | ||
53 | + base2 = 1; | ||
54 | + base1 = 0; | ||
55 | + document.getElementById('jstest').innerHTML+=("2루타!"); | ||
56 | + document.getElementById('jstest').innerHTML+=("베이스 상태"+" "+ "1루 " + base1 + " "+ "2루 " + base2 + " "+ | ||
57 | + "3루 " + base3 + " ");/////////////////////////// | ||
58 | + document.getElementById('jstest').innerHTML+=("score: "+score+ " "); | ||
59 | + } | ||
60 | + if(0.4 < num2 && num2 <=0.7){ | ||
61 | + score = score + base3 + base2 + base1; | ||
62 | + base3 = 0; | ||
63 | + base2 = 1; | ||
64 | + base1 = 0; | ||
65 | + document.getElementById('jstest').innerHTML+=("2루타!"); | ||
66 | + document.getElementById('jstest').innerHTML+=("베이스 상태"+" "+ "1루 " + base1 + " "+ "2루 " + base2 + " "+ | ||
67 | + "3루 " + base3 + " ");/////////////////////////// | ||
68 | + document.getElementById('jstest').innerHTML+=("score: "+score+ " "); | ||
69 | + } | ||
70 | + if(0.7 < num2 && num2 <= 1){ | ||
71 | + score = score + base3 + base2; | ||
72 | + base3 = 0; | ||
73 | + base2 = 1; | ||
74 | + base1 = 0; | ||
75 | + out++; | ||
76 | + document.getElementById('jstest').innerHTML+=("2루타!"); | ||
77 | + document.getElementById('jstest').innerHTML+=("베이스 상태"+" "+ "1루 " + base1 + " "+ "2루 " + base2 + " "+ | ||
78 | + "3루 " + base3 + " ");/////////////////////////// | ||
79 | + document.getElementById('jstest').innerHTML+=("score: "+score+ " "); | ||
80 | + } | ||
81 | + | ||
82 | + } | ||
83 | + else if(one + two < num && num <= one + two + three){ | ||
84 | + score = score + base3 + base2 + base1; | ||
85 | + base3 = 1; | ||
86 | + base2 = 0; | ||
87 | + base1 = 0; | ||
88 | + document.getElementById('jstest').innerHTML+=("3루타!"); | ||
89 | + document.getElementById('jstest').innerHTML+=("베이스 상태"+" "+ "1루 " + base1 + " "+ "2루 " + base2 + " "+ | ||
90 | + "3루 " + base3 + " ");/////////////////////////// | ||
91 | + document.getElementById('jstest').innerHTML+=("score: "+score+ " "); | ||
92 | + } | ||
93 | + else if(one + two + three < num && num <= one + two + three + homerun){ | ||
94 | + score = score + base3 + base2 + base1 + 1; | ||
95 | + base3 = 0; | ||
96 | + base2 = 0; | ||
97 | + base1 = 0; | ||
98 | + document.getElementById('jstest').innerHTML+=("홈런!"); | ||
99 | + document.getElementById('jstest').innerHTML+=("베이스 상태"+" "+ "1루 " + base1 + " "+ "2루 " + base2 + " "+ | ||
100 | + "3루 " + base3 + " ");/////////////////////////// | ||
101 | + document.getElementById('jstest').innerHTML+=("score: "+score+ " "); | ||
102 | + } | ||
103 | + } | ||
104 | + if( kia_pitcher[1][2] < num && num <= kia_pitcher[1][2] + kia_pitcher[1][1]*0.01){ | ||
105 | + base3 = base2; | ||
106 | + base2 = base1; | ||
107 | + base1 = 1; | ||
108 | + document.getElementById('jstest').innerHTML+=("볼넷!"); | ||
109 | + document.getElementById('jstest').innerHTML+=("베이스 상태"+" "+ "1루 " + base1 + " "+ "2루 " + base2 + " "+ | ||
110 | + "3루 " + base3 + " ");/////////////////////////// | ||
111 | + document.getElementById('jstest').innerHTML+=("score: "+score+ " "); | ||
112 | + } | ||
113 | + if( kia_pitcher[1][2] + kia_pitcher[1][1]*0.01 < num && num <= 1){ | ||
114 | + out++; | ||
115 | + if(out >= 3){ | ||
116 | + hitter = dusan_hitter[1]; | ||
117 | + pitcher = dusan_pitcher[1]; | ||
118 | + break; | ||
119 | + } | ||
120 | + document.getElementById('jstest').innerHTML+=("아웃!"); | ||
121 | + document.getElementById('jstest').innerHTML+=("베이스 상태"+" "+ "1루 " + base1 + " "+ "2루 " + base2 + " "+ | ||
122 | + "3루 " + base3 + " ");/////////////////////////// | ||
123 | + document.getElementById('jstest').innerHTML+=("score: "+score+ " "); | ||
124 | + } | ||
125 | + } | ||
126 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -53,7 +53,7 @@ body{ | ... | @@ -53,7 +53,7 @@ body{ |
53 | } | 53 | } |
54 | .container2{ | 54 | .container2{ |
55 | width:25%; | 55 | width:25%; |
56 | - height:600px; | 56 | + height:800px; |
57 | float:left; | 57 | float:left; |
58 | } | 58 | } |
59 | .team{ | 59 | .team{ |
... | @@ -85,12 +85,12 @@ body{ | ... | @@ -85,12 +85,12 @@ body{ |
85 | } | 85 | } |
86 | .container3{ | 86 | .container3{ |
87 | width:50%; | 87 | width:50%; |
88 | - height:900px; | 88 | + height:800px; |
89 | float:left; | 89 | float:left; |
90 | } | 90 | } |
91 | .container4{ | 91 | .container4{ |
92 | width:25%; | 92 | width:25%; |
93 | - height:600px; | 93 | + height:800px; |
94 | float:left; | 94 | float:left; |
95 | } | 95 | } |
96 | .t2{ | 96 | .t2{ |
... | @@ -151,7 +151,8 @@ td{ | ... | @@ -151,7 +151,8 @@ td{ |
151 | } | 151 | } |
152 | #jstest{ | 152 | #jstest{ |
153 | width:100%; | 153 | width:100%; |
154 | - height:500px; | 154 | + height:300px; |
155 | - margin:350px 0px 0px 0px; | 155 | + overflow-y: scroll; |
156 | + overflow-x: auto; | ||
156 | background-color:white; | 157 | background-color:white; |
157 | } | 158 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -3,6 +3,11 @@ | ... | @@ -3,6 +3,11 @@ |
3 | <head> | 3 | <head> |
4 | <title> Simulation </title> | 4 | <title> Simulation </title> |
5 | <link rel="stylesheet" type="text/css"href="simulation.css"> | 5 | <link rel="stylesheet" type="text/css"href="simulation.css"> |
6 | + <script src = "kia.js"></script> | ||
7 | + <script src = "dusan.js"></script> | ||
8 | + <script src = "algorithm.js"></script> | ||
9 | + <script src = "shuffle_list.js"></script> | ||
10 | + <script src = "aaaa.js"></script> | ||
6 | <script> | 11 | <script> |
7 | var wonjung=6; | 12 | var wonjung=6; |
8 | var home=8; | 13 | var home=8; |
... | @@ -183,7 +188,7 @@ | ... | @@ -183,7 +188,7 @@ |
183 | </div> | 188 | </div> |
184 | <div class="simul"> | 189 | <div class="simul"> |
185 | <div class="but"> | 190 | <div class="but"> |
186 | - <button type="submit" class="simulbtr">시뮬레이션</button> | 191 | + <input type="button" onclick=aaaa() class="simulbtr" value="시뮬레이션"> |
187 | </div> | 192 | </div> |
188 | <div class="result"> | 193 | <div class="result"> |
189 | 194 | ... | ... |
-
Please register or login to post a comment