- global pointasked lastptchosen
- if {![info exists pointasked]} {
- if {![string compare $point $lastptchosen]} return
- set lastptchosen $point
- set x [randbyte]
- set pos [expr [regexp {^[89a-f]} $x] ? 1 : 0]
- debug "chose point $point pos=$pos (x=$x)"
- } elseif {[regexp {^M([01])$} $pointasked dummy pos]} {
- if {[lsearch -exact {40 02} [lindex $point 0]] >= 0} {
- set pos [expr {!$pos}]
- debug "chose point $point pos=$pos manual-rl"
- } else {
- debug "chose point $point pos=$pos manual-lr"
- }
- set pointasked M
- } elseif {![string compare $pointasked M]} {
- debug "leave point $point manual"
- return
+ upvar #0 pointpos($point) oldpos
+ global lastptchosen pointprob pointabs
+ if {![string compare $point $lastptchosen]} return
+ set lastptchosen $point
+ set x 0x[randbyte]
+ set pos [expr {$x < $pointprob ? 1 : 0}]
+ if {$pointabs} {
+ debug "chose point $point $pos (abs x=$x prob=$pointprob)"
+ set pos [expr {!$pos}]
+ } elseif {[info exists oldpos] && !$oldpos} {
+ debug "chose point $point $pos (0-> x=$x prob=$pointprob)"