# Variable calculations should be done in this file.
# It is read and interpreted by wims for all valid calls to the module.

insdraw_size=250,250
tolerance=0.05

!if $cmd=resume
 !exit
!endif

!if $status=next
 !changeto var.prep
!endif

!if $cmd=reply and $status!=waiting
 error=double_reply
 !exit
!endif

!if $cmd=reply and $status=waiting
 !if $click_x iswordof out1 out2 osci
  anstype=dv
 !else
  anstype=cv
  cx=$[$click_x*4/250-2]
  cy=$[$click_y*4/250-2]
  !if NaN isin $cx $cy
   !reset cx,cy
   anstype=er
  !endif
 !endif
 !if $good notwordof out out1 out2 osci
  isgood=yes
 !endif
 !if $anstype=dv and $click_x=$good or \
  $isgood=yes and abs($cx-$good)<$tolerance
  sc=10
  ans=good
 !else
  !if $isgood=yes and abs($cx-$good)<$tolerance*3
   sc=!item $level of 7,6,4,4,3,3,3,2,2,2,2,2,2,2
   ans=tolerance
  !endif
 !endif
 accu=$[$accu+$sc]

 !read anim.proc
 !if $cnt<$repeat
  status=next
  !exit
 !endif
 status=done
 module_score=$[$accu/$repeat]
 wims_module_log=score $module_score
!endif

