R
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