오진혁

Modify README

...@@ -25,10 +25,10 @@ ...@@ -25,10 +25,10 @@
25 </ul> 25 </ul>
26 </nav> 26 </nav>
27 <div class="container2"> 27 <div class="container2">
28 - <a href="https://sports.news.naver.com/kbaseball/record/index.nhn?category=kbo&year=2021"><img src="pngs/rank.jpg" style="display:block; margin:0 auto; width:600px; height:400px;"></a> 28 + <a href="https://sports.news.naver.com/kbaseball/record/index.nhn?category=kbo&year=2021"><img src="pngs/rank.JPG" style="display:block; margin:0 auto; width:600px; height:400px;"></a>
29 </div> 29 </div>
30 <div class="container3"> 30 <div class="container3">
31 - <a href="https://sports.news.naver.com/kbaseball/schedule/index.nhn"><img src="pngs/today.jpg" style="display:block; margin:0 auto; width:655px; height:150px;"></a> 31 + <a href="https://sports.news.naver.com/kbaseball/schedule/index.nhn"><img src="pngs/today.JPG" style="display:block; margin:0 auto; width:655px; height:150px;"></a>
32 </div> 32 </div>
33 <div class="container4"> 33 <div class="container4">
34 <img src="pngs/1.jpg" style="display:block; margin:0 auto; width:200px; height:100px;"> 34 <img src="pngs/1.jpg" style="display:block; margin:0 auto; width:200px; height:100px;">
......
This diff is collapsed. Click to expand it.
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 +}
1 const express = require('express'); 1 const express = require('express');
2 const app = express(); 2 const app = express();
3 -app.use(express.static(__dirname));
4 3
5 app.listen(8080, function(){ 4 app.listen(8080, function(){
6 console.log('listening on 8080'); 5 console.log('listening on 8080');
7 }); 6 });
8 7
9 -app.get('/', function(req, res){ 8 +app.get('/test', function(req, res){
10 - res.sendFile(__dirname + '/main.html'); 9 + res.send('test');
11 }); 10 });
12 11
13 -app.get('/main.html', function(req, res){ 12 +app.get('/', function(req, res){
14 res.sendFile(__dirname + '/main.html'); 13 res.sendFile(__dirname + '/main.html');
14 + res.sendFile(__dirname + '/main.css');
15 }); 15 });
...\ No newline at end of file ...\ No newline at end of file
16 -
17 -app.get('/introduction.html', function(req, res){
18 - res.sendFile(__dirname + '/introduction.html');
19 -});
20 -
21 -app.get('/calendar.html', function(req, res){
22 - res.sendFile(__dirname + '/calendar.html');
23 -});
24 -
25 -
26 -app.get('/simulation.html', function(req, res){
27 - res.sendFile(__dirname + '/simulation.html');
28 -});
29 -
......
...@@ -78,6 +78,10 @@ body{ ...@@ -78,6 +78,10 @@ body{
78 font-size:15px; 78 font-size:15px;
79 border-radius:5px; 79 border-radius:5px;
80 } 80 }
81 +.t1:hover{
82 + color:#0053b3;
83 + background-color: #2E294E;
84 +}
81 .row{ 85 .row{
82 display:flex; 86 display:flex;
83 justify-content: space-evenly; 87 justify-content: space-evenly;
...@@ -102,6 +106,10 @@ body{ ...@@ -102,6 +106,10 @@ body{
102 font-size:15px; 106 font-size:15px;
103 border-radius:5px; 107 border-radius:5px;
104 } 108 }
109 +.t2:hover{
110 + color:#be4209;
111 + background-color: #2E294E;
112 +}
105 .l{ 113 .l{
106 width:33%; 114 width:33%;
107 height:200px; 115 height:200px;
...@@ -118,24 +126,26 @@ body{ ...@@ -118,24 +126,26 @@ body{
118 text-align:center; 126 text-align:center;
119 } 127 }
120 .simul{ 128 .simul{
129 + width:50%;
121 height:150px; 130 height:150px;
122 display:flex; 131 display:flex;
123 - float:left; 132 + margin: auto;
124 - margin-top:50px; 133 + text-align:center;
125 - margin-left:250px;
126 -}
127 -.but{
128 - height:150px;
129 - margin: 0px auto;
130 } 134 }
131 .simulbtr{ 135 .simulbtr{
132 - width:250px; 136 + width:200px;
133 height:50px; 137 height:50px;
134 color: #c9d6de; 138 color: #c9d6de;
135 border: 1px solid #c9d6de; 139 border: 1px solid #c9d6de;
136 background: black; 140 background: black;
137 - font-size:30px; 141 + margin-top:50px;
142 + font-size:20px;
138 border-radius:5px; 143 border-radius:5px;
144 + margin-right:5px;
145 +}
146 +.simulbtr:hover{
147 + color:#7700ff;
148 + background-color: #2E294E;
139 } 149 }
140 .tb{ 150 .tb{
141 padding: 10px 0px 0px 90px; 151 padding: 10px 0px 0px 90px;
...@@ -156,3 +166,9 @@ td{ ...@@ -156,3 +166,9 @@ td{
156 overflow-x: auto; 166 overflow-x: auto;
157 background-color:white; 167 background-color:white;
158 } 168 }
169 +#select_list{
170 + width:50%;
171 + margin: auto;
172 + text-align:center;
173 + margin-bottom:50px;
174 +}
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
6 <script src = "player.js"></script> 6 <script src = "player.js"></script>
7 <script src = "temp_algorithm.js"></script> 7 <script src = "temp_algorithm.js"></script>
8 <script src = "simulation.js"></script> 8 <script src = "simulation.js"></script>
9 + <script src = "predict.js"></script>
9 </head> 10 </head>
10 <body> 11 <body>
11 <div class="container1"> 12 <div class="container1">
...@@ -125,12 +126,11 @@ ...@@ -125,12 +126,11 @@
125 <img src="pngs/dusan.png" id="home" class="vs"> 126 <img src="pngs/dusan.png" id="home" class="vs">
126 </div> 127 </div>
127 <div class="simul"> 128 <div class="simul">
128 - <div class="but">
129 <input type="button" onclick="pre_algorithm(hitter_list1, hitter_list2, pitcher1, pitcher2);" class="simulbtr" value="시뮬레이션"> 129 <input type="button" onclick="pre_algorithm(hitter_list1, hitter_list2, pitcher1, pitcher2);" class="simulbtr" value="시뮬레이션">
130 + <input type="button" onclick="add_predict();" class="simulbtr" value="승률예측">
130 </div> 131 </div>
131 - <div class="result"> 132 + <div id="select_list">
132 - 133 + <select name="pr" id="pr" onclick="predict(this.value, hitter_list1, hitter_list2, pitcher1, pitcher2);"></select>
133 - </div>
134 </div> 134 </div>
135 <div id="jstest"></div> 135 <div id="jstest"></div>
136 </div> 136 </div>
......
...@@ -193,8 +193,84 @@ function pre_algorithm(hitter_list1, hitter_list2, pitcher1, pitcher2){//algorit ...@@ -193,8 +193,84 @@ function pre_algorithm(hitter_list1, hitter_list2, pitcher1, pitcher2){//algorit
193 } 193 }
194 194
195 else{//아웃 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{
196 out++; 271 out++;
197 document.getElementById('jstest').innerHTML+=("아웃!"); 272 document.getElementById('jstest').innerHTML+=("아웃!");
273 + }
198 274
199 } 275 }
200 276
...@@ -234,4 +310,6 @@ function pre_algorithm(hitter_list1, hitter_list2, pitcher1, pitcher2){//algorit ...@@ -234,4 +310,6 @@ function pre_algorithm(hitter_list1, hitter_list2, pitcher1, pitcher2){//algorit
234 310
235 } 311 }
236 document.getElementById('jstest').innerHTML+=("<br\><br\>"+"최종스코어 : "+score1+"vs"+score2); 312 document.getElementById('jstest').innerHTML+=("<br\><br\>"+"최종스코어 : "+score1+"vs"+score2);
313 + var score = [score1, score2];
314 + return score;
237 } 315 }
...\ No newline at end of file ...\ No newline at end of file
......