Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2021-1-open-source
/
BaseBallSimulator
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
정주희
2021-06-03 21:34:08 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
f70e7cde8b44434a1e8ee165f1509b660ea786eb
f70e7cde
1 parent
9bbc63f8
temporary Simulation html/css/js
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
138 additions
and
6 deletions
aaaa.js
simulation.css
simulation.html
aaaa.js
0 → 100644
View file @
f70e7cd
function
aaaa
(){
var
pitcher
=
kia_pitcher
[
1
];
//선발투수, 나중에 사용자가 지정해주는 투수로 바뀌도록 수정해야 한다.
var
base1
=
0
;
base2
=
0
;
base3
=
0
;
//1이면 주자 있고 0이면 비어있는것
var
out
=
0
;
ining
=
1
;
//아웃카운트, 이닝
var
hitter_number1
=
0
;
hitter_number2
=
0
;
//이전 타석 타자 번호
var
score
=
0
;
score2
=
0
;
document
.
getElementById
(
'jstest'
).
innerHTML
=
" "
;
for
(
i
=
0
;
i
<
10
;
i
++
){
var
num
=
Math
.
random
();
document
.
getElementById
(
'jstest'
).
innerHTML
+=
(
num
+
" "
+
"<br\>"
);
//hitter_number1 = hitter_number(kia); hitter_number2 = hitter_number(dusan);
hitter
=
kia_hitter
[
1
];
//선발타자, 나중에 사용자가 지정해주는 타자로 바뀌도록 수정해야 한다.
document
.
getElementById
(
'jstest'
).
innerHTML
+=
(
hitter
[
0
]
+
" "
);
var
one
=
0
;
var
two
=
0
;
var
three
=
0
;
var
homerun
=
0
;
if
(
num
<=
kia_pitcher
[
1
][
2
]){
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
];
document
.
getElementById
(
'jstest'
).
innerHTML
+=
(
"확률"
+
" "
+
"1루타 "
+
one
+
" "
+
"2루타 "
+
two
+
" "
+
"3루타 "
+
three
+
" "
,
"홈런 "
+
homerun
,
" "
);
//////////////////////////////
if
(
num
<=
one
){
//그냥 간단하게 다음 베이스로 한 칸씩 이동하도록 계산, 모든 경우의 수 계산하는게 불가능
var
num1
=
Math
.
random
();
if
(
num1
<=
0.5
){
score
=
score
+
base3
;
base3
=
base2
;
base2
=
base1
;
base1
=
1
;
document
.
getElementById
(
'jstest'
).
innerHTML
+=
(
"1루타!"
);
document
.
getElementById
(
'jstest'
).
innerHTML
+=
(
"베이스 상태"
+
" "
,
"1루 "
+
base1
+
" "
+
"2루 "
+
base2
+
" "
+
"3루 "
+
base3
+
" "
);
///////////////////////////
document
.
getElementById
(
'jstest'
).
innerHTML
+=
(
"score: "
+
score
+
" "
);
}
if
(
num1
>
0.5
){
score
=
score
+
base3
+
base2
;
base3
=
base1
;
base2
=
0
;
base1
=
1
;
document
.
getElementById
(
'jstest'
).
innerHTML
+=
(
"1루타!"
);
document
.
getElementById
(
'jstest'
).
innerHTML
+=
(
"베이스 상태"
+
" "
+
"1루 "
+
base1
+
" "
+
"2루 "
+
base2
+
" "
+
"3루 "
+
base3
+
" "
);
///////////////////////////
document
.
getElementById
(
'jstest'
).
innerHTML
+=
(
"score: "
+
score
+
" "
);
}
}
else
if
(
one
<
num
&&
num
<=
one
+
two
){
var
num2
=
Math
.
random
();
if
(
num2
<=
0.4
){
score
=
score
+
base3
+
base2
;
base3
=
base1
;
base2
=
1
;
base1
=
0
;
document
.
getElementById
(
'jstest'
).
innerHTML
+=
(
"2루타!"
);
document
.
getElementById
(
'jstest'
).
innerHTML
+=
(
"베이스 상태"
+
" "
+
"1루 "
+
base1
+
" "
+
"2루 "
+
base2
+
" "
+
"3루 "
+
base3
+
" "
);
///////////////////////////
document
.
getElementById
(
'jstest'
).
innerHTML
+=
(
"score: "
+
score
+
" "
);
}
if
(
0.4
<
num2
&&
num2
<=
0.7
){
score
=
score
+
base3
+
base2
+
base1
;
base3
=
0
;
base2
=
1
;
base1
=
0
;
document
.
getElementById
(
'jstest'
).
innerHTML
+=
(
"2루타!"
);
document
.
getElementById
(
'jstest'
).
innerHTML
+=
(
"베이스 상태"
+
" "
+
"1루 "
+
base1
+
" "
+
"2루 "
+
base2
+
" "
+
"3루 "
+
base3
+
" "
);
///////////////////////////
document
.
getElementById
(
'jstest'
).
innerHTML
+=
(
"score: "
+
score
+
" "
);
}
if
(
0.7
<
num2
&&
num2
<=
1
){
score
=
score
+
base3
+
base2
;
base3
=
0
;
base2
=
1
;
base1
=
0
;
out
++
;
document
.
getElementById
(
'jstest'
).
innerHTML
+=
(
"2루타!"
);
document
.
getElementById
(
'jstest'
).
innerHTML
+=
(
"베이스 상태"
+
" "
+
"1루 "
+
base1
+
" "
+
"2루 "
+
base2
+
" "
+
"3루 "
+
base3
+
" "
);
///////////////////////////
document
.
getElementById
(
'jstest'
).
innerHTML
+=
(
"score: "
+
score
+
" "
);
}
}
else
if
(
one
+
two
<
num
&&
num
<=
one
+
two
+
three
){
score
=
score
+
base3
+
base2
+
base1
;
base3
=
1
;
base2
=
0
;
base1
=
0
;
document
.
getElementById
(
'jstest'
).
innerHTML
+=
(
"3루타!"
);
document
.
getElementById
(
'jstest'
).
innerHTML
+=
(
"베이스 상태"
+
" "
+
"1루 "
+
base1
+
" "
+
"2루 "
+
base2
+
" "
+
"3루 "
+
base3
+
" "
);
///////////////////////////
document
.
getElementById
(
'jstest'
).
innerHTML
+=
(
"score: "
+
score
+
" "
);
}
else
if
(
one
+
two
+
three
<
num
&&
num
<=
one
+
two
+
three
+
homerun
){
score
=
score
+
base3
+
base2
+
base1
+
1
;
base3
=
0
;
base2
=
0
;
base1
=
0
;
document
.
getElementById
(
'jstest'
).
innerHTML
+=
(
"홈런!"
);
document
.
getElementById
(
'jstest'
).
innerHTML
+=
(
"베이스 상태"
+
" "
+
"1루 "
+
base1
+
" "
+
"2루 "
+
base2
+
" "
+
"3루 "
+
base3
+
" "
);
///////////////////////////
document
.
getElementById
(
'jstest'
).
innerHTML
+=
(
"score: "
+
score
+
" "
);
}
}
if
(
kia_pitcher
[
1
][
2
]
<
num
&&
num
<=
kia_pitcher
[
1
][
2
]
+
kia_pitcher
[
1
][
1
]
*
0.01
){
base3
=
base2
;
base2
=
base1
;
base1
=
1
;
document
.
getElementById
(
'jstest'
).
innerHTML
+=
(
"볼넷!"
);
document
.
getElementById
(
'jstest'
).
innerHTML
+=
(
"베이스 상태"
+
" "
+
"1루 "
+
base1
+
" "
+
"2루 "
+
base2
+
" "
+
"3루 "
+
base3
+
" "
);
///////////////////////////
document
.
getElementById
(
'jstest'
).
innerHTML
+=
(
"score: "
+
score
+
" "
);
}
if
(
kia_pitcher
[
1
][
2
]
+
kia_pitcher
[
1
][
1
]
*
0.01
<
num
&&
num
<=
1
){
out
++
;
if
(
out
>=
3
){
hitter
=
dusan_hitter
[
1
];
pitcher
=
dusan_pitcher
[
1
];
break
;
}
document
.
getElementById
(
'jstest'
).
innerHTML
+=
(
"아웃!"
);
document
.
getElementById
(
'jstest'
).
innerHTML
+=
(
"베이스 상태"
+
" "
+
"1루 "
+
base1
+
" "
+
"2루 "
+
base2
+
" "
+
"3루 "
+
base3
+
" "
);
///////////////////////////
document
.
getElementById
(
'jstest'
).
innerHTML
+=
(
"score: "
+
score
+
" "
);
}
}
}
\ No newline at end of file
simulation.css
View file @
f70e7cd
...
...
@@ -53,7 +53,7 @@ body{
}
.container2
{
width
:
25%
;
height
:
6
00px
;
height
:
8
00px
;
float
:
left
;
}
.team
{
...
...
@@ -85,12 +85,12 @@ body{
}
.container3
{
width
:
50%
;
height
:
9
00px
;
height
:
8
00px
;
float
:
left
;
}
.container4
{
width
:
25%
;
height
:
6
00px
;
height
:
8
00px
;
float
:
left
;
}
.t2
{
...
...
@@ -151,7 +151,8 @@ td{
}
#jstest
{
width
:
100%
;
height
:
500px
;
margin
:
350px
0px
0px
0px
;
height
:
300px
;
overflow-y
:
scroll
;
overflow-x
:
auto
;
background-color
:
white
;
}
\ No newline at end of file
...
...
simulation.html
View file @
f70e7cd
...
...
@@ -3,6 +3,11 @@
<head>
<title>
Simulation
</title>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"simulation.css"
>
<script
src =
"kia.js"
></script>
<script
src =
"dusan.js"
></script>
<script
src =
"algorithm.js"
></script>
<script
src =
"shuffle_list.js"
></script>
<script
src =
"aaaa.js"
></script>
<script>
var
wonjung
=
6
;
var
home
=
8
;
...
...
@@ -183,7 +188,7 @@
</div>
<div
class=
"simul"
>
<div
class=
"but"
>
<
button
type=
"submit"
class=
"simulbtr"
>
시뮬레이션
</button
>
<
input
type=
"button"
onclick=
aaaa()
class=
"simulbtr"
value=
"시뮬레이션"
>
</div>
<div
class=
"result"
>
...
...
Please
register
or
login
to post a comment