정주희

Update files about javascript

var dusan_hitter = [
['선수명', 'AVG', 'H', '2B', '3B', 'HR'],
['김재환',0.268,48,4,1,13],
['박건우',0.340,52,10,0,2],
['페르난데스',0.333,66,7,0,8],
['허경민',0.330,63,9,0,4],
['양석환',0.269,52,10,0,12],
['김인태',0.267,36,5,1,4],
['안재석',0.316,25,4,2,0],
['최용제',0.311,14,3,0,0],
['조수행',0.277,13,1,1,0],
['장승현',0.248,27,3,0,2],
['김재호',0.262,28,5,0,1],
['박계범',0.266,21,5,0,2],
['강승호',0.247,19,2,1,2],
['정수빈',0.226,14,2,1,0],
['박세혁',0.182,6,0,0,0],
['오재원',0.175,11,2,0,0],
]
var dusan_pitcher = [
['선수명', '볼넷%', '피안타율'],
['로켓', 7.4, 0.251],
['미란다', 12.5, 0.243],
['최원준', 5.6, 0.237],
['박정수', 10.2, 0.302],
['곽빈', 16.7, 0.256],
['유희관', 7.6, 0.409],
['조제영', 16.7, 0.367],
['이영하', 16.0, 0.393],
]
var hanhwa_hitter = [
['선수명', 'AVG', 'H', '2B', '3B', 'HR'],
['정은원',0.284,54,10,4,1],
['노시환',0.266,49,8,0,11],
['하주석',0.283,53,10,1,4],
['조한민',0.308,8,1,2,2],
['최재훈',0.216,27,3,0,2],
['김민하',0.240,18,4,0,1],
['장운호',0.273,35,8,0,0],
['노수광',0.217,15,1,0,1],
['강상원',0.167,3,0,0,0],
['강경학',0.136,3,0,0,0],
['이해창',0.231,9,3,0,0],
['허관회',0.161,5,0,0,0],
['이성열',0.203,16,4,0,1],
['힐리',0.258,46,8,1,4],
['정진호',0.216,16,3,0,0],
['박정현',0.196,21,4,0,0],
['유장혁',0.143,14,5,0,1],
['임종찬',0.155,16,5,0,1],
]
var hanhwa_pitcher = [
['선수명', '볼넷%', '피안타율'],
['킹험', 6.4, 0.211],
['카펜터', 11.7, 0.209],
['김민우', 11.2, 0.208],
['김범수', 13.9, 0.284],
['장시환', 15.8, 0.306],
['윤대경', 15.0, 0.208],
['김기중', 5.6, 0.353],
['김이환', 16.7, 0.283],
['박주홍', 50.0, 0.250],
['이승관', 39.1, 0.538],
['배동현', 15.4, 0.252],
]
var kia_hitter = [
['선수명', 'AVG', 'H', '2B', '3B', 'HR'],
['최원준',0.324,71,5,5,1],
['김민식',0.247,22,3,0,2],
['김선빈',0.281,52,10,0,0],
['이정훈',0.298,25,5,0,2],
['김태진',0.336,41,3,1,0],
['터커',0.269,56,11,1,3],
['이진영',0.188,6,2,0,2],
['한승택',0.238,19,3,0,0],
['김호령',0.163,7,2,0,1],
['류지혁',0.259,21,3,0,0],
['김규성',0.133,2,1,0,0],
['이창진',0.218,22,5,0,0],
['나지완',0.184,9,1,0,0],
['박찬호',0.241,42,6,2,0],
['이우성',0.194,6,1,0,0],
['유민상',0.143,3,1,0,0],
['최형우',0.195,22,1,0,5],
['황대인',0.259,15,2,0,2],
['나주환',0.172,5,0,0,0],
]
var kia_pitcher = [
['선수명', '볼넷%', '피안타율'],
['브룩스', 5.3, 0.307],
['멩덴', 10, 0.243],
['이의리', 14, 0.223],
['임기영', 7.1, 0.254],
['김현수', 14.5, 0.243],
['이민우', 7.9, 0.346],
['남재현', 27.8, 0.208],
['김유신', 16.2, 0.269],
['차명진', 8.0, 0.273],
]
var kiwoom_hitter = [
['선수명', 'AVG', 'H', '2B', '3B', 'HR'],
['이정후',0.346,71,21,4,1],
['박동원',0.281,34,7,0,9],
['김혜성',0.283,62,8,1,3],
['서건창',0.266,49,9,0,1],
['김웅빈',0.250,39,10,0,4],
['이용규',0.256,42,4,4,0],
['송우현',0.280,46,11,1,1],
['박병호',0.219,35,8,0,8],
['전병우',0.196,22,6,0,3],
['박준태',0.048,1,1,0,0],
['프레이타스',0.285,35,10,0,2],
['김수환',0.220,9,2,0,2],
['허정협',0.179,5,0,0,0],
['박주홍',0.143,4,2,0,0],
['이지영',0.253,22,2,1,0],
['변상권',0.105,2,0,0,0],
]
var kiwoom_pitcher = [
['선수명', '볼넷%', '피안타율'],
['요키시', 6.8, 0.252],
['한현희', 8.8, 0.261],
['최원태', 7.7, 0.276],
['안우진', 10.4, 0.269],
['브리검', 13.3, 0.243],
['이승호', 18, 0.263],
['스미스', 11.6, 0.237],
['장재영', 26.5, 0.217],
['김정인', 12.5, 0.246],
]
var kt_hitter = [
['선수명', 'AVG', 'H', '2B', '3B', 'HR'],
['강백호',0.407,81,12,1,7],
['배정대',0.295,57,13,0,3],
['심우준',0.306,49,11,1,3],
['김병희',0.300,12,3,0,3],
['황재균',0.316,31,3,1,1],
['조용호',0.281,47,7,0,0],
['장성우',0.234,36,6,0,6],
['알몬테',0.296,58,9,0,5],
['김민혁',0.302,19,0,2,0],
['유한준',0.280,30,6,0,1],
['권동진',0.182,6,3,0,0],
['송민섭',0.080,2,0,0,0],
['문상철',0.222,16,6,0,2],
['신본기',0.400,18,4,0,0],
['박경수',0.185,22,6,0,5],
['이홍구',0.178,8,0,0,1],
]
var kt_pitcher = [
['선수명', '볼넷%', '피안타율'],
['데스파이네', 11.3, 0.213],
['고영표', 3.9, 0.243],
['배제성', 13.8, 0.226],
['소형준', 12.3, 0.269],
['김민수', 11.8, 0.299],
['쿠에바스', 12.0, 0.306],
['이정현', 12.0, 0.318],
]
var lg_hitter = [
['선수명', 'AVG', 'H', '2B', '3B', 'HR'],
['홍창기', 0.316, 60, 8, 1, 3],
['김현수', 0.317, 59, 9, 0, 8],
['채은성', 0.303, 47, 11, 0, 7],
['문보경', 0.275, 19, 7, 0, 2],
['유강남', 0.241, 40, 6, 0, 5],
['오지환', 0.231, 37, 9, 1, 2],
['이형종', 0.222, 22, 6, 0, 4],
['한석현', 0.286, 6, 2, 1, 0],
['라모스', 0.243, 45, 7, 1, 8],
['김재성', 0.188, 6, 1, 1, 1],
['신민재', 0.167, 3, 0, 0, 0],
['정주현', 0.222, 30, 6, 1, 2],
['구본혁', 0.150, 3, 2, 0, 0],
['김민성', 0.207, 34, 9, 0, 3],
['이천웅', 0.211, 27, 6, 0, 2],
]
var lg_pitcher = [
['선수명', '볼넷%', '피안타율'],
['수아레즈', 9.6, 0.208],
['정찬헌', 5.6, 0.271],
['켈리', 9.6, 0.228],
['이민호', 11.5, 0.234],
['이우찬', 10.2, 0.264]
['배재준', 6.2, 0.356],
['차우찬', 9.5, 0.211],
['함덕주', 17.2, 0.224],
['김윤식', 12.7, 0.254],
['임찬규', 25.8, 0.476],
['이상영', 11.1, 0.257],
]
var lotte_hitter = [
['선수명', 'AVG', 'H', '2B', '3B', 'HR'],
['전준우', 0.325, 65, 12, 0, 2],
['정훈', 0.305, 57, 13, 0, 6],
['마차도', 0.272, 43, 9, 0, 4],
['안치홍', 0.310, 54, 11, 2, 3],
['이대호', 0.328, 44, 3, 0, 8],
['한동희', 0.241, 41, 8, 0, 7],
['추재현', 0.318, 28, 6, 0, 3],
['김준태', 0.221, 23, 5, 0, 4],
['김재유', 0.290, 9, 2, 0, 0],
['배성근', 0.270, 10, 1, 0, 0],
['이병규', 0.235, 8, 0, 0, 0],
['지시완', 0.237, 14, 2, 0, 2],
['오윤석', 0.245, 13, 7, 0, 1],
['장두성', 0.214, 6, 2, 0, 0],
['나승엽', 0.268, 11, 1, 0, 0],
['김민수', 0.232, 16, 5, 0, 1],
['강태율', 0.100, 2, 1, 0, 1],
['손아섭', 0.271, 57, 6, 0, 0],
]
var lotte_pitcher = [
['선수명', '볼넷%', '피안타율'],
['스트레일리', 9.3, 0.268],
['박세웅', 8.3, 0.230],
['나균안', 9.4, 0.274],
['프랑코', 11.0, 0.234],
['김진욱', 20.0, 0.261],
['서준원', 13.9, 0.299],
['이승헌', 19.6, 0.325],
['노경은', 10.7, 0.344],
]
var nc_hitter = [
['선수명', 'AVG', 'H', '2B', '3B', 'HR'],
['양의지', 0.349, 60, 11, 1, 11],
['알테어', 0.303, 56, 10, 0, 14],
['박석민', 0.299, 35, 8, 0, 10],
['나성범', 0.280, 60, 12, 1, 13,]
['노진혁', 0.296, 45, 5, 0, 5],
['이명기', 0.296, 47, 10, 0, 2],
['박민우', 0.287, 41, 5, 1, 1],
['권희동', 0.237, 22, 3, 0, 6],
['김태군', 0.248, 26, 5, 0, 3],
['윤형준', 0.400, 10, 0, 0, 3],
['박준영', 0.238, 24, 2, 1, 5],
['김찬형', 0.364, 8, 1, 0, 0],
['정진기', 0.333, 7, 3, 0, 0],
['전민수', 0.318, 7, 0, 0, 0],
['강진성', 0.234, 26, 7, 0, 1],
['지석훈', 0.147, 5, 1, 0, 0],
['최정원', 0.158, 3, 0, 0, 0],
['도태훈', 0.067, 2, 0, 0, 0],
['이원재', 0.226, 14, 2, 0, 0],
]
var nc_pitcher = [
['선수명', '볼넷%', '피안타율'],
['루친스키', 9.0, 0.235],
['파슨스', 11.9, 0.219],
['송명기', 7.2, 0.348],
['신민혁', 7.8, 0.245],
['강동연', 9.0, 0.271],
['김진호', 42.9, 0.500],
['김영규', 11.9, 0.312],
['이재학', 24.4, 0.290],
]
var samsung_hitter = [
['선수명', 'AVG', 'H', '2B', '3B', 'HR'],
['피렐라',0.347,77,10,1,13],
['강민호',0.351,54,8,0,6],
['박해민',0.292,52,8,0,3],
['구자욱',0.287,58,10,4,6],
['오재일',0.295,36,8,0,8],
['김헌곤',0.310,31,2,0,3],
['김민수',0.313,15,4,0,2],
['이원석',0.241,33,8,0,3],
['김지찬',0.259,30,5,0,1],
['이학주',0.220,18,6,0,2],
['김호재',0.222,8,1,0,0],
['송준석',0.235,12,2,0,2],
['강한울',0.231,24,3,0,0],
['김상수',0.206,37,4,1,0],
['김동엽',0.157,8,1,0,0],
]
var samsung_pitcher = [
['선수명', '볼넷%', '피안타율'],
['뷰캐넌', 8.5, 0.228],
['원태인', 8.6, 0.246],
['라이블리', 9.3, 0.190],
['백정현', 10.5, 0.250],
['최채흥', 9.7, 0.346],
['이승민', 10.2, 0.294],
['김윤수', 19.3, 0.348],
['김대우', 8.3, 0.275],
['구준범', 25.0, 0.250],
]
var ssg_hitter = [
['선수명', 'AVG', 'H', '2B', '3B', 'HR'],
['최정',0.293,49,8,0,13],
['추신수',0.263,44,4,1,8],
['로맥',0.253,46,6,0,13],
['박성한',0.297,38,8,0,1],
['최주환',0.304,35,7,0,4],
['최지훈',0.237,32,4,1,3],
['김성현',0.278,27,4,0,2],
['한유섬',0.250,41,9,0,6],
['이흥련',0.281,16,1,0,0],
['이재원',0.258,34,9,0,2],
['정현',0.190,4,2,0,0],
['김강민',0.242,22,5,1,3],
['김찬형',0.174,4,1,0,0],
['오태곤',0.232,19,2,0,4],
['오준혁',0.207,6,1,0,1],
['정의윤',0.224,22,0,0,5],
['고종욱',0.250,13,0,0,0],
]
var ssg_pitcher = [
['선수명', '볼넷%', '피안타율'],
['폰트', 7.1, 0.206],
['박종훈', 7.2, 0.205],
['문승원', 8.5, 0.220],
['오원석', 13.6, 0.251],
['르위키', 3.6, 0.278],
['조영우', 9.5, 0.321],
['양선률', 30.0, 0.500],
['정수민', 17.3, 0.284],
['김정빈', 19.4, 0.304],
['이건욱', 26.4, 0.333],
]
\ No newline at end of file
function add_predict(){
var s="";
s+=("<option value="+10+">"+10+"</option>");
s+=("<option value="+20+">"+20+"</option>");
s+=("<option value="+50+">"+50+"</option>");
s+=("<option value="+70+">"+70+"</option>");
s+=("<option value="+100+">"+100+"</option>");
s+=("<option value="+500+">"+500+"</option>");
s+=("<option value="+1000+">"+1000+"</option>");
s+=("<option value="+5000+">"+5000+"</option>");
s+=("<option value="+10000+">"+10000+"</option>");
s+=("<option value="+50000+">"+50000+"</option>");
s+=("<option value="+100000+">"+100000+"</option>");
document.getElementById('pr').innerHTML=s;
}
function predict(value, hitter_list1, hitter_list2, pitcher1, pitcher2){
var score=[0,0];
var w=0;
var h=0;
var d=0;
for(var i=0; i<value; i++){
score=algorithms(hitter_list1, hitter_list2, pitcher1, pitcher2);
if(score[0]>score[1]){
w++;
}else if(score[0]<score[1]){
h++;
}else{
d++;
}
}
document.getElementById('jstest').innerHTML="예측 결과"+"<br\>"+"TEST "+value+"번"+"<br\><br\>"+"원정팀 승리 횟수 : "+w+"<br\>"
+"홈팀 승리 횟수 : "+h+"<br\>"+"무승부 횟수 : "+d+"<br\><br\>"+"원정팀 승리 확률 : "+w*100/value+"%"+"<br\>"+"홈팀 승리 확률 : "+h*100/value+"%"+"<br\>";
}
function algorithms(hitter_list1, hitter_list2, pitcher1, pitcher2){
var base1 = 0; var base2 = 0; var base3 = 0; //1이면 주자 있고 0이면 비어있는것
var out = 0; var ining = 1; var home_away = 1;//아웃카운트, 이닝, home이면 1이고 away이면 2.
var score1 = 0; var score2 = 0;
var hitter_num1 = 1; var hitter_num2 = 1;
var hit=false;
while(true){
if(ining == 9 && home_away == 2 && score1 < score2){//9회 초 후 home팀이 이기고 있을 때!
break;
}
else if(ining==10 && home_away==1 && score1>score2 && hit==false){//9회 말 후 home팀이 이기고 있을 때!
break;
}
else if(ining>9 && score1 < score2){//9회 말 후 home팀이 이기고 있을 때!
break;
}
else if(ining>=11 && home_away==1 && hit==false && score1>score2){//연장 이후 원정팀이 이기고 있을 때!
break;
}
else if(ining>=10 && home_away==2 && hit==true && score1<score2){//끝내기
break;
}
else if(ining==13 && score1==score2){//무승부
break;
}
if(home_away == 1){
var hitter = hitter_list1[hitter_num1]; //hitter = hitter_list1[hitter_number1%9]
var pitcher = pitcher2; //pitcher = pitcher1
}
else if(home_away == 2){
var hitter = hitter_list2[hitter_num2]; //hitter = hitter_list2[hitter_number2%9]
var pitcher = pitcher1; //pitcher = pitcher2
}
var num = Math.random();
//hitter_number1 = hitter_number(kia); hitter_number2 = hitter_number(dusan);
var one = 0; var two = 0; var three = 0; var homerun = 0;
one = pitcher[2] * (hitter[2] - hitter[3] - hitter[4] - hitter[5])/hitter[2];
two = pitcher[2] * hitter[3]/hitter[2];
three = pitcher[2] * hitter[4]/hitter[2];
homerun = pitcher[2] * hitter[5]/hitter[2];
hit=true;
if(num <= one){ //안타
var num1 = Math.random();
if(num1 <= 0.5){
switch(home_away){
case 1:
score1 = score1 + base3;
break;
case 2:
score2 = score2 + base3;
break;
}
base3 = base2;
base2 = base1;
base1 = 1;
}
else{
switch(home_away){
case 1:
score1 = score1 + base3 + base2;
break;
case 2:
score2 = score2 + base3 + base2;
break;
}
base3 = base1;
base2 = 0;
base1 = 1;
}
}
else if((one < num) && (num <= one + two)){//2루타
var num2 = Math.random();
if(num2 <= 0.4){
switch(home_away){
case 1:
score1 = score1 + base3 + base2;
break;
case 2:
score2 = score2 + base3 + base2;
break;
}
base3 = base1;
base2 = 1;
base1 = 0;
}
else if(0.4 < num2 && num2 <=0.7){
switch(home_away){
case 1:
score1 = score1 + base3 + base2 + base1;
break;
case 2:
score2 = score2 + base3 + base2 + base1;
break;
}
base3 = 0;
base2 = 1;
base1 = 0;
}
else{
switch(home_away){
case 1:
score1 = score1 + base3 + base2;
break;
case 2:
score2 = score2 + base3 + base2;
break;
}
base3 = 0;
base2 = 1;
base1 = 0;
}
}
else if((one + two < num) && (num <= one + two + three)){//3루타
switch(home_away){
case 1:
score1 = score1 + base3 + base2 + base1;
break;
case 2:
score2 = score2 + base3 + base2 + base1;
break;
}
base3 = 1;
base2 = 0;
base1 = 0;
}
else if(one + two + three < num && num <= one + two + three + homerun){//홈런
switch(home_away){
case 1:
score1 = score1 + base3 + base2 + base1 + 1;
break;
case 2:
score2 = score2 + base3 + base2 + base1 + 1;
break;
}
base3 = 0;
base2 = 0;
base1 = 0;
}
else if( pitcher[2] < num && (num <= pitcher[2] +pitcher[1]*0.01)){//볼넷
if(base1==1 && base2==1 && base3==1){//만루 밀어내기 득점 -> 스코어 ++
if(home_away==1){
score1++;
}
else{
score2++;
}
}
else{//스코어 추가되지 않는 경우
if((base2==1 && base1==0 )||(base3==1 && base1==0)||(base2==1&&base3==1&&base1==0)){//2루만 채워져있거나 3루만 채워져있거나 2,3루만 채워져있거나
base1=1;
}
else if(base1==1 && base3==1 && base2==0){//1루 3루 채워져있고 2루 비워져있거나
base2=base1;
base1=1;
}
else{
base3 = base2;
base2 = base1;
base1 = 1;
}
}
}
else{//아웃
out++;
}
if(out >= 3){
switch(home_away){
case 1:
home_away = 2;
hit=false;
break;
case 2:
home_away = 1;
ining++;
hit=false;
break;
}
out=0;
base1=0; base2=0; base3=0;
}
else{
if(home_away == 1){
hitter_num1++;
if(hitter_num1>=10){
hitter_num1=1;
}
}
else if(home_away == 2){
hitter_num2++;
if(hitter_num2>=10){
hitter_num2=1;
}
}
}
}
var score = [score1, score2];
return score;
}
var wonjung=8;
var home=6;
var hitter_list1=[
['선수명', 'AVG', 'H', '2B', '3B', 'HR'],
['', 0, 0, 0, 0, 0],
['', 0, 0, 0, 0, 0],
['', 0, 0, 0, 0, 0],
['', 0, 0, 0, 0, 0],
['', 0, 0, 0, 0, 0],
['', 0, 0, 0, 0, 0],
['', 0, 0, 0, 0, 0],
['', 0, 0, 0, 0, 0],
['', 0, 0, 0, 0, 0],
];
var hitter_list2=[
['선수명', 'AVG', 'H', '2B', '3B', 'HR'],
['', 0, 0, 0, 0, 0],
['', 0, 0, 0, 0, 0],
['', 0, 0, 0, 0, 0],
['', 0, 0, 0, 0, 0],
['', 0, 0, 0, 0, 0],
['', 0, 0, 0, 0, 0],
['', 0, 0, 0, 0, 0],
['', 0, 0, 0, 0, 0],
['', 0, 0, 0, 0, 0],
];
var pitcher1=['',0,0];
var pitcher2=['',0,0];
function imgchange1(a){
var img=document.getElementById("wonjung");
if(a==1){
wonjung=1;
img.setAttribute("src","pngs/samsung.png");
}
else if(a==2){
wonjung=2;
img.setAttribute("src","pngs/nc.png");
}
else if(a==3){
wonjung=3;
img.setAttribute("src","pngs/LG.png");
}
else if(a==4){
wonjung=4;
img.setAttribute("src","pngs/kt.png");
}
else if(a==5){
wonjung=5;
img.setAttribute("src","pngs/ssg.png");
}
else if(a==6){
wonjung=6;
img.setAttribute("src","pngs/dusan.png");
}
else if(a==7){
wonjung=7;
img.setAttribute("src","pngs/kiwoom.png");
}
else if(a==8){
wonjung=8;
img.setAttribute("src","pngs/kia.png");
}
else if(a==9){
wonjung=9;
img.setAttribute("src","pngs/hanhwa.png");
}
else if(a==10){
wonjung=10;
img.setAttribute("src","pngs/Lotte.png");
}
hitter1_option(wonjung);
pitcher1_option(wonjung);
}
function imgchange2(a){
var img=document.getElementById("home");
if(a==1){
home=1;
img.setAttribute("src","pngs/samsung.png");
}
else if(a==2){
home=2;
img.setAttribute("src","pngs/nc.png");
}
else if(a==3){
home=3;
img.setAttribute("src","pngs/LG.png");
}
else if(a==4){
home=4;
img.setAttribute("src","pngs/kt.png");
}
else if(a==5){
home=5;
img.setAttribute("src","pngs/ssg.png");
}
else if(a==6){
home=6;
img.setAttribute("src","pngs/dusan.png");
}
else if(a==7){
home=7;
img.setAttribute("src","pngs/kiwoom.png");
}
else if(a==8){
home=8;
img.setAttribute("src","pngs/kia.png");
}
else if(a==9){
home=9;
img.setAttribute("src","pngs/hanhwa.png");
}
else if(a==10){
home=10;
img.setAttribute("src","pngs/Lotte.png");
}
hitter2_option(home);
pitcher2_option(home);
}
function hitter1_option(wonjung){
var s="";
if(wonjung==1){
for(var j=1; j<samsung_hitter.length; j++){
s+=("<option value="+samsung_hitter[j][0]+">"+samsung_hitter[j][0]+"</option>");
}
}
else if(wonjung==2){
for(var j=1; j<nc_hitter.length; j++){
s+=("<option value="+nc_hitter[j][0]+">"+nc_hitter[j][0]+"</option>");
}
}
else if(wonjung==3){
for(var j=1; j<lg_hitter.length; j++){
s+=("<option value="+lg_hitter[j][0]+">"+lg_hitter[j][0]+"</option>");
}
}
else if(wonjung==4){
for(var j=1; j<kt_hitter.length; j++){
s+=("<option value="+kt_hitter[j][0]+">"+kt_hitter[j][0]+"</option>");
}
}
else if(wonjung==5){
for(var j=1; j<ssg_hitter.length; j++){
s+=("<option value="+ssg_hitter[j][0]+">"+ssg_hitter[j][0]+"</option>");
}
}
else if(wonjung==6){
for(var j=1; j<dusan_hitter.length; j++){
s+=("<option value="+dusan_hitter[j][0]+">"+dusan_hitter[j][0]+"</option>");
}
}
else if(wonjung==7){
for(var j=1; j<kiwoom_hitter.length; j++){
s+=("<option value="+kiwoom_hitter[j][0]+">"+kiwoom_hitter[j][0]+"</option>");
}
}
else if(wonjung==8){
for(var j=1; j<kia_hitter.length; j++){
s+=("<option value="+kia_hitter[j][0]+">"+kia_hitter[j][0]+"</option>");
}
}
else if(wonjung==9){
for(var j=1; j<hanhwa_hitter.length; j++){
s+=("<option value="+hanhwa_hitter[j][0]+">"+hanhwa_hitter[j][0]+"</option>");
}
}
else if(wonjung==10){
for(var j=1; j<lotte_hitter.length; j++){
s+=("<option value="+lotte_hitter[j][0]+">"+lotte_hitter[j][0]+"</option>");
}
}
document.getElementById('won1').innerHTML=s;
document.getElementById('won2').innerHTML=s;
document.getElementById('won3').innerHTML=s;
document.getElementById('won4').innerHTML=s;
document.getElementById('won5').innerHTML=s;
document.getElementById('won6').innerHTML=s;
document.getElementById('won7').innerHTML=s;
document.getElementById('won8').innerHTML=s;
document.getElementById('won9').innerHTML=s;
}
function hitter2_option(wonjung){
var s="";
if(wonjung==1){
for(var j=1; j<samsung_hitter.length; j++){
s+=("<option value="+samsung_hitter[j][0]+">"+samsung_hitter[j][0]+"</option>");
}
}
else if(wonjung==2){
for(var j=1; j<nc_hitter.length; j++){
s+=("<option value="+nc_hitter[j][0]+">"+nc_hitter[j][0]+"</option>");
}
}
else if(wonjung==3){
for(var j=1; j<lg_hitter.length; j++){
s+=("<option value="+lg_hitter[j][0]+">"+lg_hitter[j][0]+"</option>");
}
}
else if(wonjung==4){
for(var j=1; j<kt_hitter.length; j++){
s+=("<option value="+kt_hitter[j][0]+">"+kt_hitter[j][0]+"</option>");
}
}
else if(wonjung==5){
for(var j=1; j<ssg_hitter.length; j++){
s+=("<option value="+ssg_hitter[j][0]+">"+ssg_hitter[j][0]+"</option>");
}
}
else if(wonjung==6){
for(var j=1; j<dusan_hitter.length; j++){
s+=("<option value="+dusan_hitter[j][0]+">"+dusan_hitter[j][0]+"</option>");
}
}
else if(wonjung==7){
for(var j=1; j<kiwoom_hitter.length; j++){
s+=("<option value="+kiwoom_hitter[j][0]+">"+kiwoom_hitter[j][0]+"</option>");
}
}
else if(wonjung==8){
for(var j=1; j<kia_hitter.length; j++){
s+=("<option value="+kia_hitter[j][0]+">"+kia_hitter[j][0]+"</option>");
}
}
else if(wonjung==9){
for(var j=1; j<hanhwa_hitter.length; j++){
s+=("<option value="+hanhwa_hitter[j][0]+">"+hanhwa_hitter[j][0]+"</option>");
}
}
else if(wonjung==10){
for(var j=1; j<lotte_hitter.length; j++){
s+=("<option value="+lotte_hitter[j][0]+">"+lotte_hitter[j][0]+"</option>");
}
}
document.getElementById('hom1').innerHTML=s;
document.getElementById('hom2').innerHTML=s;
document.getElementById('hom3').innerHTML=s;
document.getElementById('hom4').innerHTML=s;
document.getElementById('hom5').innerHTML=s;
document.getElementById('hom6').innerHTML=s;
document.getElementById('hom7').innerHTML=s;
document.getElementById('hom8').innerHTML=s;
document.getElementById('hom9').innerHTML=s;
}
function pitcher1_option(wonjung){
var s="";
if(wonjung==1){
for(var j=1; j<samsung_pitcher.length; j++){
s+=("<option value="+samsung_pitcher[j][0]+">"+samsung_pitcher[j][0]+"</option>");
}
}
else if(wonjung==2){
for(var j=1; j<nc_pitcher.length; j++){
s+=("<option value="+nc_pitcher[j][0]+">"+nc_pitcher[j][0]+"</option>");
}
}
else if(wonjung==3){
for(var j=1; j<lg_pitcher.length; j++){
s+=("<option value="+lg_pitcher[j][0]+">"+lg_pitcher[j][0]+"</option>");
}
}
else if(wonjung==4){
for(var j=1; j<kt_pitcher.length; j++){
s+=("<option value="+kt_pitcher[j][0]+">"+kt_pitcher[j][0]+"</option>");
}
}
else if(wonjung==5){
for(var j=1; j<ssg_pitcher.length; j++){
s+=("<option value="+ssg_pitcher[j][0]+">"+ssg_pitcher[j][0]+"</option>");
}
}
else if(wonjung==6){
for(var j=1; j<dusan_pitcher.length; j++){
s+=("<option value="+dusan_pitcher[j][0]+">"+dusan_pitcher[j][0]+"</option>");
}
}
else if(wonjung==7){
for(var j=1; j<kiwoom_pitcher.length; j++){
s+=("<option value="+kiwoom_pitcher[j][0]+">"+kiwoom_pitcher[j][0]+"</option>");
}
}
else if(wonjung==8){
for(var j=1; j<kia_pitcher.length; j++){
s+=("<option value="+kia_pitcher[j][0]+">"+kia_pitcher[j][0]+"</option>");
}
}
else if(wonjung==9){
for(var j=1; j<hanhwa_pitcher.length; j++){
s+=("<option value="+hanhwa_pitcher[j][0]+">"+hanhwa_pitcher[j][0]+"</option>");
}
}
else if(wonjung==10){
for(var j=1; j<lotte_pitcher.length; j++){
s+=("<option value="+lotte_pitcher[j][0]+">"+lotte_pitcher[j][0]+"</option>");
}
}
document.getElementById('won').innerHTML=s;
}
function pitcher2_option(wonjung){
var s="";
if(wonjung==1){
for(var j=1; j<samsung_pitcher.length; j++){
s+=("<option value="+samsung_pitcher[j][0]+">"+samsung_pitcher[j][0]+"</option>");
}
}
else if(wonjung==2){
for(var j=1; j<nc_pitcher.length; j++){
s+=("<option value="+nc_pitcher[j][0]+">"+nc_pitcher[j][0]+"</option>");
}
}
else if(wonjung==3){
for(var j=1; j<lg_pitcher.length; j++){
s+=("<option value="+lg_pitcher[j][0]+">"+lg_pitcher[j][0]+"</option>");
}
}
else if(wonjung==4){
for(var j=1; j<kt_pitcher.length; j++){
s+=("<option value="+kt_pitcher[j][0]+">"+kt_pitcher[j][0]+"</option>");
}
}
else if(wonjung==5){
for(var j=1; j<ssg_pitcher.length; j++){
s+=("<option value="+ssg_pitcher[j][0]+">"+ssg_pitcher[j][0]+"</option>");
}
}
else if(wonjung==6){
for(var j=1; j<dusan_pitcher.length; j++){
s+=("<option value="+dusan_pitcher[j][0]+">"+dusan_pitcher[j][0]+"</option>");
}
}
else if(wonjung==7){
for(var j=1; j<kiwoom_pitcher.length; j++){
s+=("<option value="+kiwoom_pitcher[j][0]+">"+kiwoom_pitcher[j][0]+"</option>");
}
}
else if(wonjung==8){
for(var j=1; j<kia_pitcher.length; j++){
s+=("<option value="+kia_pitcher[j][0]+">"+kia_pitcher[j][0]+"</option>");
}
}
else if(wonjung==9){
for(var j=1; j<hanhwa_pitcher.length; j++){
s+=("<option value="+hanhwa_pitcher[j][0]+">"+hanhwa_pitcher[j][0]+"</option>");
}
}
else if(wonjung==10){
for(var j=1; j<lotte_pitcher.length; j++){
s+=("<option value="+lotte_pitcher[j][0]+">"+lotte_pitcher[j][0]+"</option>");
}
}
document.getElementById('hom').innerHTML=s;
}
function hitter1list_append(num, value){
if(wonjung==1){
for(var j=1; j<samsung_hitter.length; j++){
if(value==samsung_hitter[j][0]){
for(var k=0; k<samsung_hitter[j].length; k++){
hitter_list1[num][k]=samsung_hitter[j][k];
}
return;
}
}
}
else if(wonjung==2){
for(var j=1; j<nc_hitter.length; j++){
if(value==nc_hitter[j][0]){
for(var k=0; k<nc_hitter[j].length; k++){
hitter_list1[num][k]=nc_hitter[j][k];
}
return;
}
}
}
else if(wonjung==3){
for(var j=1; j<lg_hitter.length; j++){
if(value==lg_hitter[j][0]){
for(var k=0; k<lg_hitter[j].length; k++){
hitter_list1[num][k]=lg_hitter[j][k];
}
return;
}
}
}
else if(wonjung==4){
for(var j=1; j<kt_hitter.length; j++){
if(value==kt_hitter[j][0]){
for(var k=0; k<kt_hitter[j].length; k++){
hitter_list1[num][k]=kt_hitter[j][k];
}
return;
}
}
}
else if(wonjung==5){
for(var j=1; j<ssg_hitter.length; j++){
if(value==ssg_hitter[j][0]){
for(var k=0; k<ssg_hitter[j].length; k++){
hitter_list1[num][k]=ssg_hitter[j][k];
}
return;
}
}
}
else if(wonjung==6){
for(var j=1; j<dusan_hitter.length; j++){
if(value==dusan_hitter[j][0]){
for(var k=0; k<dusan_hitter[j].length; k++){
hitter_list1[num][k]=dusan_hitter[j][k];
}
return;
}
}
}
else if(wonjung==7){
for(var j=1; j<kiwoom_hitter.length; j++){
if(value==kiwoom_hitter[j][0]){
for(var k=0; k<kiwoom_hitter[j].length; k++){
hitter_list1[num][k]=kiwoom_hitter[j][k];
}
return;
}
}
}
else if(wonjung==8){
for(var j=1; j<kia_hitter.length; j++){
if(value==kia_hitter[j][0]){
for(var k=0; k<kia_hitter[j].length; k++){
hitter_list1[num][k]=kia_hitter[j][k];
}
return;
}
}
}
else if(wonjung==9){
for(var j=1; j<hanhwa_hitter.length; j++){
if(value==hanhwa_hitter[j][0]){
for(var k=0; k<hanhwa_hitter[j].length; k++){
hitter_list1[num][k]=hanhwa_hitter[j][k];
}
return;
}
}
}
else if(wonjung==10){
for(var j=1; j<lotte_hitter.length; j++){
if(value==lotte_hitter[j][0]){
for(var k=0; k<lotte_hitter[j].length; k++){
hitter_list1[num][k]=lotte_hitter[j][k];
}
return;
}
}
}
}
function hitter2list_append(num, value){
if(home==1){
for(var j=1; j<samsung_hitter.length; j++){
if(value==samsung_hitter[j][0]){
for(var k=0; k<samsung_hitter[j].length; k++){
hitter_list2[num][k]=samsung_hitter[j][k];
}
return;
}
}
}
else if(home==2){
for(var j=1; j<nc_hitter.length; j++){
if(value==nc_hitter[j][0]){
for(var k=0; k<nc_hitter[j].length; k++){
hitter_list2[num][k]=nc_hitter[j][k];
}
return;
}
}
}
else if(home==3){
for(var j=1; j<lg_hitter.length; j++){
if(value==lg_hitter[j][0]){
for(var k=0; k<lg_hitter[j].length; k++){
hitter_list2[num][k]=lg_hitter[j][k];
}
return;
}
}
}
else if(home==4){
for(var j=1; j<kt_hitter.length; j++){
if(value==kt_hitter[j][0]){
for(var k=0; k<kt_hitter[j].length; k++){
hitter_list2[num][k]=kt_hitter[j][k];
}
return;
}
}
}
else if(home==5){
for(var j=1; j<ssg_hitter.length; j++){
if(value==ssg_hitter[j][0]){
for(var k=0; k<ssg_hitter[j].length; k++){
hitter_list2[num][k]=ssg_hitter[j][k];
}
return;
}
}
}
else if(home==6){
for(var j=1; j<dusan_hitter.length; j++){
if(value==dusan_hitter[j][0]){
for(var k=0; k<dusan_hitter[j].length; k++){
hitter_list2[num][k]=dusan_hitter[j][k];
}
return;
}
}
}
else if(home==7){
for(var j=1; j<kiwoom_hitter.length; j++){
if(value==kiwoom_hitter[j][0]){
for(var k=0; k<kiwoom_hitter[j].length; k++){
hitter_list2[num][k]=kiwoom_hitter[j][k];
}
return;
}
}
}
else if(home==8){
for(var j=1; j<kia_hitter.length; j++){
if(value==kia_hitter[j][0]){
for(var k=0; k<kia_hitter[j].length; k++){
hitter_list2[num][k]=kia_hitter[j][k];
}
return;
}
}
}
else if(home==9){
for(var j=1; j<hanhwa_hitter.length; j++){
if(value==hanhwa_hitter[j][0]){
for(var k=0; k<hanhwa_hitter[j].length; k++){
hitter_list2[num][k]=hanhwa_hitter[j][k];
}
return;
}
}
}
else if(home==10){
for(var j=1; j<lotte_hitter.length; j++){
if(value==lotte_hitter[j][0]){
for(var k=0; k<lotte_hitter[j].length; k++){
hitter_list2[num][k]=lotte_hitter[j][k];
}
return;
}
}
}
}
function pitcher1list_append(value){
if(wonjung==1){
for(var j=1; j<samsung_pitcher.length; j++){
if(value==samsung_pitcher[j][0]){
for(var k=0; k<samsung_pitcher[j].length; k++){
pitcher1[k]=samsung_pitcher[j][k];
}
return;
}
}
}
else if(wonjung==2){
for(var j=1; j<nc_pitcher.length; j++){
if(value==nc_pitcher[j][0]){
for(var k=0; k<nc_pitcher[j].length; k++){
pitcher1[k]=nc_pitcher[j][k];
}
return;
}
}
}
else if(wonjung==3){
for(var j=1; j<lg_pitcher.length; j++){
if(value==lg_pitcher[j][0]){
for(var k=0; k<lg_pitcher[j].length; k++){
pitcher1[k]=lg_pitcher[j][k];
}
return;
}
}
}
else if(wonjung==4){
for(var j=1; j<kt_pitcher.length; j++){
if(value==kt_pitcher[j][0]){
for(var k=0; k<kt_pitcher[j].length; k++){
pitcher1[k]=kt_pitcher[j][k];
}
return;
}
}
}
else if(wonjung==5){
for(var j=1; j<ssg_pitcher.length; j++){
if(value==ssg_pitcher[j][0]){
for(var k=0; k<ssg_pitcher[j].length; k++){
pitcher1[k]=ssg_pitcher[j][k];
}
return;
}
}
}
else if(wonjung==6){
for(var j=1; j<dusan_pitcher.length; j++){
if(value==dusan_pitcher[j][0]){
for(var k=0; k<dusan_pitcher[j].length; k++){
pitcher1[k]=dusan_pitcher[j][k];
}
return;
}
}
}
else if(wonjung==7){
for(var j=1; j<kiwoom_pitcher.length; j++){
if(value==kiwoom_pitcher[j][0]){
for(var k=0; k<kiwoom_pitcher[j].length; k++){
pitcher1[k]=kiwoom_pitcher[j][k];
}
return;
}
}
}
else if(wonjung==8){
for(var j=1; j<kia_pitcher.length; j++){
if(value==kia_pitcher[j][0]){
for(var k=0; k<kia_pitcher[j].length; k++){
pitcher1[k]=kia_pitcher[j][k];
}
return;
}
}
}
else if(wonjung==9){
for(var j=1; j<hanhwa_pitcher.length; j++){
if(value==hanhwa_pitcher[j][0]){
for(var k=0; k<hanhwa_pitcher[j].length; k++){
pitcher1[k]=hanhwa_pitcher[j][k];
}
return;
}
}
}
else if(wonjung==10){
for(var j=1; j<lotte_pitcher.length; j++){
if(value==lotte_pitcher[j][0]){
for(var k=0; k<lotte_pitcher[j].length; k++){
pitcher1[k]=lotte_pitcher[j][k];
}
return;
}
}
}
}
function pitcher2list_append(value){
if(home==1){
for(var j=1; j<samsung_pitcher.length; j++){
if(value==samsung_pitcher[j][0]){
for(var k=0; k<samsung_pitcher[j].length; k++){
pitcher2[k]=samsung_pitcher[j][k];
}
return;
}
}
}
else if(home==2){
for(var j=1; j<nc_pitcher.length; j++){
if(value==nc_pitcher[j][0]){
for(var k=0; k<nc_pitcher[j].length; k++){
pitcher2[k]=nc_pitcher[j][k];
}
return;
}
}
}
else if(home==3){
for(var j=1; j<lg_pitcher.length; j++){
if(value==lg_pitcher[j][0]){
for(var k=0; k<lg_pitcher[j].length; k++){
pitcher2[k]=lg_pitcher[j][k];
}
return;
}
}
}
else if(home==4){
for(var j=1; j<kt_pitcher.length; j++){
if(value==kt_pitcher[j][0]){
for(var k=0; k<kt_pitcher[j].length; k++){
pitcher2[k]=kt_pitcher[j][k];
}
return;
}
}
}
else if(home==5){
for(var j=1; j<ssg_pitcher.length; j++){
if(value==ssg_pitcher[j][0]){
for(var k=0; k<ssg_pitcher[j].length; k++){
pitcher2[k]=ssg_pitcher[j][k];
}
return;
}
}
}
else if(home==6){
for(var j=1; j<dusan_pitcher.length; j++){
if(value==dusan_pitcher[j][0]){
for(var k=0; k<dusan_pitcher[j].length; k++){
pitcher2[k]=dusan_pitcher[j][k];
}
return;
}
}
}
else if(home==7){
for(var j=1; j<kiwoom_pitcher.length; j++){
if(value==kiwoom_pitcher[j][0]){
for(var k=0; k<kiwoom_pitcher[j].length; k++){
pitcher2[k]=kiwoom_pitcher[j][k];
}
return;
}
}
}
else if(home==8){
for(var j=1; j<kia_pitcher.length; j++){
if(value==kia_pitcher[j][0]){
for(var k=0; k<kia_pitcher[j].length; k++){
pitcher2[k]=kia_pitcher[j][k];
}
return;
}
}
}
else if(home==9){
for(var j=1; j<hanhwa_pitcher.length; j++){
if(value==hanhwa_pitcher[j][0]){
for(var k=0; k<hanhwa_pitcher[j].length; k++){
pitcher2[k]=hanhwa_pitcher[j][k];
}
return;
}
}
}
else if(home==10){
for(var j=1; j<lotte_pitcher.length; j++){
if(value==lotte_pitcher[j][0]){
for(var k=0; k<lotte_pitcher[j].length; k++){
pitcher2[k]=lotte_pitcher[j][k];
}
return;
}
}
}
}
hitter1_option(wonjung);
pitcher1_option(wonjung);
hitter2_option(home);
pitcher2_option(home);
\ No newline at end of file
function pre_algorithm(hitter_list1, hitter_list2, pitcher1, pitcher2){//algorithm(hitter_list1, hitter_list2, pitcher1, pitcher2) => html에서 가지고와야 한다.
var base1 = 0; var base2 = 0; var base3 = 0; //1이면 주자 있고 0이면 비어있는것
var out = 0; var ining = 1; var home_away = 1;//아웃카운트, 이닝, home이면 1이고 away이면 2.
var score1 = 0; var score2 = 0;
var hitter_num1 = 1; var hitter_num2 = 1;
var hit=false;
document.getElementById('jstest').innerHTML="";
while(true){
if(ining == 9 && home_away == 2 && score1 < score2){//9회 초 후 home팀이 이기고 있을 때!
break;
}
else if(ining==10 && home_away==1 && score1>score2 && hit==false){//9회 말 후 home팀이 이기고 있을 때!
break;
}
else if(ining>9 && score1 < score2){//9회 말 후 home팀이 이기고 있을 때!
break;
}
else if(ining>=11 && home_away==1 && hit==false && score1>score2){//연장 이후 원정팀이 이기고 있을 때!
break;
}
else if(ining>=10 && home_away==2 && hit==true && score1<score2){//끝내기
break;
}
else if(ining==13 && score1==score2){//무승부
break;
}
if(home_away == 1){
var hitter = hitter_list1[hitter_num1]; //hitter = hitter_list1[hitter_number1%9]
var pitcher = pitcher2; //pitcher = pitcher1
document.getElementById('jstest').innerHTML+=(ining+ "회 초"+ "<br\><br\>");
}
else if(home_away == 2){
var hitter = hitter_list2[hitter_num2]; //hitter = hitter_list2[hitter_number2%9]
var pitcher = pitcher1; //pitcher = pitcher2
document.getElementById('jstest').innerHTML+=(ining+ "회 말"+ "<br\><br\>");
}
var num = Math.random();
//hitter_number1 = hitter_number(kia); hitter_number2 = hitter_number(dusan);
if(home_away == 1){
document.getElementById('jstest').innerHTML+=(hitter_num1+"번 타자: "+hitter[0]+ "<br\><br\>");
}
else if(home_away == 2){
document.getElementById('jstest').innerHTML+=(hitter_num2+"번 타자: "+hitter[0]+ "<br\><br\>");
}
var one = 0; var two = 0; var three = 0; var homerun = 0;
one = pitcher[2] * (hitter[2] - hitter[3] - hitter[4] - hitter[5])/hitter[2];
two = pitcher[2] * hitter[3]/hitter[2];
three = pitcher[2] * hitter[4]/hitter[2];
homerun = pitcher[2] * hitter[5]/hitter[2];
hit=true;
if(num <= one){ //안타
var num1 = Math.random();
if(num1 <= 0.5){
switch(home_away){
case 1:
score1 = score1 + base3;
break;
case 2:
score2 = score2 + base3;
break;
}
base3 = base2;
base2 = base1;
base1 = 1;
document.getElementById('jstest').innerHTML+=("1루타!");
}
else{
switch(home_away){
case 1:
score1 = score1 + base3 + base2;
break;
case 2:
score2 = score2 + base3 + base2;
break;
}
base3 = base1;
base2 = 0;
base1 = 1;
document.getElementById('jstest').innerHTML+=("1루타!");
}
}
else if((one < num) && (num <= one + two)){//2루타
var num2 = Math.random();
if(num2 <= 0.4){
switch(home_away){
case 1:
score1 = score1 + base3 + base2;
break;
case 2:
score2 = score2 + base3 + base2;
break;
}
base3 = base1;
base2 = 1;
base1 = 0;
document.getElementById('jstest').innerHTML+=("2루타!");
}
else if(0.4 < num2 && num2 <=0.7){
switch(home_away){
case 1:
score1 = score1 + base3 + base2 + base1;
break;
case 2:
score2 = score2 + base3 + base2 + base1;
break;
}
base3 = 0;
base2 = 1;
base1 = 0;
document.getElementById('jstest').innerHTML+=("2루타!");
}
else{
switch(home_away){
case 1:
score1 = score1 + base3 + base2;
break;
case 2:
score2 = score2 + base3 + base2;
break;
}
base3 = 0;
base2 = 1;
base1 = 0;
document.getElementById('jstest').innerHTML+=("2루타!");
}
}
else if((one + two < num) && (num <= one + two + three)){//3루타
switch(home_away){
case 1:
score1 = score1 + base3 + base2 + base1;
break;
case 2:
score2 = score2 + base3 + base2 + base1;
break;
}
base3 = 1;
base2 = 0;
base1 = 0;
document.getElementById('jstest').innerHTML+=("3루타!");
}
else if(one + two + three < num && num <= one + two + three + homerun){//홈런
switch(home_away){
case 1:
score1 = score1 + base3 + base2 + base1 + 1;
break;
case 2:
score2 = score2 + base3 + base2 + base1 + 1;
break;
}
base3 = 0;
base2 = 0;
base1 = 0;
document.getElementById('jstest').innerHTML+=("홈런!");
}
else if( pitcher[2] < num && (num <= pitcher[2] +pitcher[1]*0.01)){//볼넷
if(base1==1 && base2==1 && base3==1){//만루 밀어내기 득점 -> 스코어 ++
if(home_away==1){
score1++;
}
else{
score2++;
}
}
else{//스코어 추가되지 않는 경우
if((base2==1 && base1==0 )||(base3==1 && base1==0)||(base2==1&&base3==1&&base1==0)){//2루만 채워져있거나 3루만 채워져있거나 2,3루만 채워져있거나
base1=1;
}
else if(base1==1 && base3==1 && base2==0){//1루 3루 채워져있고 2루 비워져있거나
base2=base1;
base1=1;
}
else{
base3 = base2;
base2 = base1;
base1 = 1;
}
}
document.getElementById('jstest').innerHTML+=("볼넷!");
}
else{//아웃
var ran = Math.random()*0.2;
if(ran>0.197){
switch(home_away){
case 1:
score1 = score1 + base3 + base2 + base1 + 1;
break;
case 2:
score2 = score2 + base3 + base2 + base1 + 1;
break;
}
base3 = 0;
base2 = 0;
base1 = 0;
document.getElementById('jstest').innerHTML+=("홈런!");
}else if(ran>0.1955){
switch(home_away){
case 1:
score1 = score1 + base3 + base2 + base1;
break;
case 2:
score2 = score2 + base3 + base2 + base1;
break;
}
base3 = 1;
base2 = 0;
base1 = 0;
document.getElementById('jstest').innerHTML+=("3루타!");
}else if(ran>0.18){
var n = Math.random();
if(n <= 0.4){
switch(home_away){
case 1:
score1 = score1 + base3 + base2;
break;
case 2:
score2 = score2 + base3 + base2;
break;
}
base3 = base1;
base2 = 1;
base1 = 0;
document.getElementById('jstest').innerHTML+=("2루타!");
}
else if(0.4 < n && n <=0.7){
switch(home_away){
case 1:
score1 = score1 + base3 + base2 + base1;
break;
case 2:
score2 = score2 + base3 + base2 + base1;
break;
}
base3 = 0;
base2 = 1;
base1 = 0;
document.getElementById('jstest').innerHTML+=("2루타!");
}
else{
switch(home_away){
case 1:
score1 = score1 + base3 + base2;
break;
case 2:
score2 = score2 + base3 + base2;
break;
}
base3 = 0;
base2 = 1;
base1 = 0;
document.getElementById('jstest').innerHTML+=("2루타!");
}
}else{
out++;
document.getElementById('jstest').innerHTML+=("아웃!");
}
}
document.getElementById('jstest').innerHTML+=("베이스 상태"+"<br\>"+ "1루 " + base1 + "<br\>"+"2루 " + base2 + "<br\>"+
"3루 " + base3 + "<br\><br\>");///////////////////////////
document.getElementById('jstest').innerHTML+=("score: "+score1 +"vs"+score2+ "<br\>");
document.getElementById('jstest').innerHTML+=("아웃카운트: "+out+"<br\><br\>");
if(out >= 3){
switch(home_away){
case 1:
home_away = 2;
hit=false;
break;
case 2:
home_away = 1;
ining++;
hit=false;
break;
}
out=0;
base1=0; base2=0; base3=0;
}
else{
if(home_away == 1){
hitter_num1++;
if(hitter_num1>=10){
hitter_num1=1;
}
}
else if(home_away == 2){
hitter_num2++;
if(hitter_num2>=10){
hitter_num2=1;
}
}
}
}
document.getElementById('jstest').innerHTML+=("<br\><br\>"+"최종스코어 : "+score1+"vs"+score2);
var score = [score1, score2];
return score;
}
\ No newline at end of file