쥬코의 블로그
글쓰기
로그인
회원가입
쥬코
팔로우
통계
작성한 글
1
작성 댓글
0
가입 그룹
0
글
태그
댓글
팔로잉
팔로워
쥬코
· 4년전
질문
R 함수 실행 관련 문의드립니다!
아래와 같이 간단한 야구게임의 코드를 짰는데요, 함수를 실행하면 결과값이 나오지 않고 계속 연산만 하고 있어서요...어디가 잘 못되었는지 봐주실 수 있나요? B <- function(ball, height, side){ sync <- 0 home <- 0 hit <- 0 out <- 0 repeat{ ball_r <- sample(2,1,TRUE) height_r <- sample(2,1,TRUE) side_r <- sample(2,1,TRUE) if(ball_r%%2==0) { ball_r <- 'fast' }else{ball_r <- 'breaking'} if(height_r%%2==0){ height_r <- 'upper' }else{height_r <- 'lower'} if(side_r%%2==0){ side_r <- 'left' }else{side_r <- 'right'} if(ball==ball_r) { sync <- sync +1 } if(height==height_r){ sync <- sync +1 } if(side==side_r){ sync <- sync +1 } if(sync==3) { home <- home +1 } else if(sync==2) { hit <- hit +1 } else if(sync <=1){ out <- out +1 } if(home + hit + out > 10) break} print('home') }
1.0K
1
0
피토니
·
2021-04-25
코드가 정확히 어떤 의미인지는 모르겠지만 B(1, 2, 3) 이런 식으로 호출하셨나요? home이라고 출력되는 것 같긴 합니다만..
더 보기