Toggle navigation
Toggle navigation
This project
Loading...
Sign in
이찬
/
opensource_term_project
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
이찬
2020-06-10 18:13:43 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
51b8f68942ed6dfce143de7e1c0bb0d4327498cd
51b8f689
1 parent
9c6f20e0
behaviors 어레이로 알고리즘 변경
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
59 deletions
js/generate.js
js/generate.js
View file @
51b8f68
var
total
Job
=
[]
var
total
Behavior
=
[]
for
(
i
=
0
;
i
<
job
s
.
length
;
i
++
)
{
total
Job
=
totalJob
.
concat
(
job
s
[
i
])
for
(
i
=
0
;
i
<
behavior
s
.
length
;
i
++
)
{
total
Behavior
=
totalBehavior
.
concat
(
behavior
s
[
i
])
}
function
generate
(
varName
,
targetID
)
{
function
generate
(
varName
,
targetID
)
{
if
(
isLimitedCheckbox
.
checked
&&
isLimitedNumInput
.
value
>=
12
)
{
result
=
'N'
.
repeat
(
isLimitedNumInput
.
value
+
2
)
while
(
result
.
length
>
isLimitedNumInput
.
value
)
{
...
...
@@ -13,87 +13,60 @@ function generate (varName, targetID) {
}
else
{
result
=
generateResult
(
varName
)
}
document
.
getElementById
(
targetID
).
innerHTML
=
result
}
function
generateResult
(
varName
)
{
function
generateResult
(
varName
)
{
var
result
=
''
if
(
Math
.
random
()
<
0.5
&&
varName
===
'손진웅'
)
{
var
sonjinwungArray
=
[
'리버스투블럭장인'
,
'준구실명먹이기장인'
,
'싸커킥장인'
,
'티베깅하고준구톱에썰리는'
,
'데드하드맨날씹히는'
,
'히오스판자창시자'
,
'욕은필터링하면서야메때는안하는'
]
var
randomSonjinwung
=
sonjinwungArray
[
Math
.
floor
(
Math
.
random
()
*
sonjinwungArray
.
length
)]
return
randomSonjinwung
+
varName
}
if
(
Math
.
random
()
<
0.8
)
{
/* 일반 장소 처리 */
var
randomDetailLocation
=
locations
[
0
][
Math
.
floor
(
Math
.
random
()
*
locations
[
0
].
length
)]
var
randomDetailJob
=
totalJob
[
Math
.
floor
(
Math
.
random
()
*
totalJob
.
length
)]
// debug: console.log(randomDetailLocation, randomDetailJob)
var
randomDetailJob
=
jobs
[
Math
.
floor
(
Math
.
random
()
*
jobs
.
length
)]
var
randomDetailBehavior
=
totalBehavior
[
Math
.
floor
(
Math
.
random
()
*
totalBehavior
.
length
)]
// debug: console.log(randomDetailLocation, randomDetailBehavior, randomDetailJob)
// 특별한 문장 정의
if
(
randomDetailLocation
===
'시내버스'
)
{
if
(
Math
.
random
()
>
0.3
)
{
randomDetailLocation
=
(
Math
.
floor
(
Math
.
random
()
*
999
)
+
1
)
+
'번'
+
randomDetailLocation
}
}
else
if
(
randomDetailLocation
.
indexOf
(
'학교'
)
>=
0
)
{
if
(
Math
.
random
()
>
0.5
)
{
randomDetailLocation
=
randomDetailLocation
+
(
Math
.
floor
(
Math
.
random
()
*
2
)
+
1
)
+
'학년'
+
(
Math
.
floor
(
Math
.
random
()
*
9
)
+
1
)
+
'반'
}
}
if
((
randomDetailLocation
===
'지하철'
||
randomDetailLocation
===
'지하철역'
)
&&
randomDetailJob
===
'앞에서절두번하는'
)
{
// debug: console.log('지하철', '절두번하는')
while
(
randomDetailJob
===
'앞에서절두번하는'
)
{
// debug: console.log('지하철', '절두번하는', '루프')
randomDetailJob
=
totalJob
[
Math
.
floor
(
Math
.
random
()
*
totalJob
.
length
)]
}
// debug: console.log('지하철', '절두번하는', randomDetailJob)
if
(
behaviors
[
0
].
indexOf
(
randomDetailBehavior
)
>=
0
)
{
result
=
generateSpecificCase
(
1
,
[
randomDetailLocation
,
randomDetailBehavior
,
randomDetailJob
,
varName
])
}
else
if
(
behaviors
[
1
].
indexOf
(
randomDetailBehavior
)
>=
0
)
{
result
=
generateSpecificCase
(
2
,
[
randomDetailLocation
,
randomDetailBehavior
,
randomDetailJob
,
varName
])
}
// 특별한 문장 정의 완료
if
(
jobs
[
0
].
indexOf
(
randomDetailJob
)
>=
0
)
{
result
=
generateSpecificCase
(
1
,
[
randomDetailLocation
,
randomDetailJob
,
varName
])
}
else
if
(
jobs
[
1
].
indexOf
(
randomDetailJob
)
>=
0
)
{
result
=
generateSpecificCase
(
2
,
[
randomDetailLocation
,
randomDetailJob
,
varName
])
}
}
else
{
/* 특별한 위치 변수 정의 처리 */
}
else
{
var
randomDetailLocation
=
locations
[
1
][
Math
.
floor
(
Math
.
random
()
*
locations
[
1
].
length
)]
// 여기서 문제가 발생한다면 특별한 위치 변수를 제대로 정의하지 않은것.
// debug: console.log('specificLocations', specificLocations[randomDetailLocation], randomDetailLocation)
if
(
specificLocations
[
randomDetailLocation
][
1
])
{
result
=
generateSpecificCase
(
2
,
[
randomDetailLocation
,
specificLocations
[
randomDetailLocation
][
0
],
varName
])
}
result
=
generateSpecificCase
(
3
,
[
randomDetailLocation
,
specificLocations
[
randomDetailLocation
],
varName
])
}
//debug: console.log(randomDetailLocation, randomDetailJob, result)
//debug: console.log(randomDetailLocation, randomDetail
Behavior, randomDetail
Job, result)
return
result
}
/* params = [randomDetailLocation, randomDetailJob, varName] */
function
generateSpecificCase
(
caseCode
,
params
)
{
/*CASE 1 : params = [randomDetailLocation, randomDetailBehavior, randomDetailJob, varName]
CASE 2 : params = [randomDetailLocation, randomDetailJob, varName]
*/
function
generateSpecificCase
(
caseCode
,
params
)
{
if
(
caseCode
===
1
)
{
var
randomObject
=
objects
[
Math
.
floor
(
Math
.
random
()
*
objects
.
length
)]
// // 특별한 문장 정의
// if (params[1] === '산채비빔밥먹는스님앞에서') {
// return params[1] + randomObject + '먹는' + params[3]
// }
// if (params[2] === '교제사실을들킨'){
// return params[0] + josa.r(randomObject, '와/과') + params[1] + params[2]
// }
// // 특별한 문장 정의 완료
return
params
[
0
]
+
randomObject
+
params
[
1
]
+
params
[
2
]
return
params
[
0
]
+
randomObject
+
params
[
1
]
+
params
[
2
]
+
params
[
3
]
}
else
if
(
caseCode
===
2
)
{
// // 특별한 문장 정의
// if (params[0] === '납골당') {
// params[1] = ['유골항아리도둑', '유골항아리파괴자'][Math.floor(Math.random() * 2)]
// }
// // 특별한 문장 정의 완료
return
params
[
0
]
+
params
[
1
]
+
params
[
2
]
+
params
[
3
]
}
else
if
(
caseCode
===
3
)
{
return
params
[
0
]
+
params
[
1
]
+
params
[
2
]
}
else
{
return
undefined
}
}
function
debug
(
a
,
b
)
{
for
(
i
=
0
;
i
<
100
;
i
++
)
{
function
debug
(
a
,
b
)
{
for
(
i
=
0
;
i
<
100
;
i
++
)
{
generate
(
a
,
b
)
}
}
\ No newline at end of file
...
...
Please
register
or
login
to post a comment