#181542 - 2007-10-12 04:35 AM
Re: KiXgolf: Linear Pachinko - Public Round
[Re: Sealeopard]
|
Gargoyle
MM club member
   
Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
|
Well for my blindness to the ball - KiXGolf Score = 481
; begin Linear Pachinko ; ;! Function a($) Dim $l,$c,$v,$t,$w
For $l = 1 to Len($) $c = M($,$l)
Select Case $c = "." $v = 100 Case $c = "|" $v = (B($,$l,1) + C($,$l,1)) / 2 Case $c = "/" $v = B($,$l,1) Case $c = "\" $v = c($,$l,1) Case 1 $v = 0 EndSelect
$t = $t + $v
Next
$a = $t / len($)
EndFunction
Function M($,$r) $m = substr($,$r,1) EndFunction
Function b($,$l,$z) Dim $y
$y = M($,$l - $z) While $y = "_" $z = $z + 1 $y = M($,$l - $z) Loop If $y = "." | $l - $z = 0 $b = 100 Else $b = 0
endFunction
Function c($,$l,$z) Dim $x
$x = M($,$l + $z) While $x = "_" $z = $z + 1 $x = M($,$l + $z) Loop If $x = "." | $l + $z > Len($) $c = 100 Else $c = 0
EndFunction
;! ;! ; end Linear Pachinko
_________________________
Today is the tomorrow you worried about yesterday.
|
|
Top
|
|
|
|
#181543 - 2007-10-12 06:53 AM
Re: KiXgolf: Linear Pachinko - Public Round
[Re: Gargoyle]
|
DrillSergeant
MM club member
   
Registered: 2004-07-09
Posts: 1164
Loc: Eijsden, the Netherlands
|
Here's my 152, I don't know how to present it with nice colors like Gargoyle did...
Gargoyle, I meant to say that you don't have to worry about how the ball rolls, you just have to count the holes and other possibilities 
; begin Linear Pachinko ; ;! Function a($) dim $c, $h, $l, $s
$l = $^0
For $c = 3 to 9 $ = Split(x+$+x, Split('_ . x/ \x x|x x| |x')[$c-3]) $s = $s + UBound($) * 100/($c/4) $a = $s / $l $ = Join($, $h) $h = x EndFunction ;! ;! ; end Linear Pachinko
I'm done commuting in three hours, I'll provide some explanation then (if needed )
Edited by DrillSergeant (2007-10-12 09:57 AM)
_________________________
The Code is out there
|
|
Top
|
|
|
|
#181545 - 2007-10-12 09:02 AM
Re: KiXgolf: Linear Pachinko - Public Round
[Re: Jochen]
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
My 174. I'm already getting Doh! moments looking at some of the tricks in the code that has already been posted.
Function a($p) Dim $b,$c,$x,$ $c=1 For $a=1 to $p^0 $x=SubStr($p,$a,1) If $x<>_ $=$+$c*InStr("|/",$x) $c=0 If $x="." $=$+2+$b $c=1 EndIf $b=InStr("|\",$x) EndIf Next $a=($+$b)*50/($p^0) EndFunction
|
|
|
Top
|
|
|
|
#181551 - 2007-10-12 10:17 AM
Re: KiXgolf: Linear Pachinko - Public Round
[Re: DrillSergeant]
|
DrillSergeant
MM club member
   
Registered: 2004-07-09
Posts: 1164
Loc: Eijsden, the Netherlands
|
To provide some information to non-golfers I have two versions of my code in which I've included some explanation of the steps. This code is NOT eligable for golfing in the public round, it's just for informational purposes.
My 198 with explanation:
; begin Linear Pachinko
;
;!
Function a($)
dim $c, $d, $h, $l, $x, $y
; Get the length for division.
$l = $^0
; Add a hole to the left and right.
$ = '.' + $ + '.'
; Put all relevant occurences in an array.
$x = _, '.', './', '\.', '.|.', '.|', '|.'
; Assign points for occurences in array $x (floor = 0, mountain side or
; wall with two holes = 10, wall with single hole = 5). These will be
;multiplied by 10 later to get 100% or 50%.
$y = 0, 10, 10, 10, 10, 5, 5
; Loop through array $x.
For $c = 0 to 6
; Split on occurence. The ubound of the array is the number of occurences.
$ = Split($,$x[$c])
; Add the points to the total (occurences X value X 10).
$h = $h + UBound($)*$y[$c]*10
; Join $ again. On the first occurence (floor) it is replaced
; with nothing ($d = empty), because we don't need them.
$ = Join($,$d)
; The rest of the occurences are replaced with a single hole.
$d = '.'
; Divide the total points (minus 200 because of the added left and right
; holes) by the length of the original $.
$a = ($h-200) / $l
EndFunction
;!
;!
; end Linear Pachinko
My 161 with explanation:
; begin Linear Pachinko
;
;!
; I'm setting up an array of all possible occurences. I've
; put the length of the original string in an extra field,
; because that saves me a variable. The use of the other
; fields will be explained later.
; I'm looping from 3 to 9 because of the linear result in
; the calculation ($c/4). this will return the following
; range: 0, 1, 1, 1, 1, 2, 2.
; In the first run I'm splitting on floor parts. they don't
; have any value (the calculation 100/($c/4) will result in
; 0 (see range above) and I don't want them back in the
; string, so they will be replaced with an empty var ($h).
; When I've removed the floor parts, the only remaining
; possibilities are the ones that are in the array $o.
; The second run I'm splitting on holes. They always have a
; 100% value, so the calculation will be 100/1 and this is
; added to the total $s. Because the variable $h is now
; filled with an x, all the holes will be replaced with an x.
; the x-es in the split line represent the left and Right
; exits so they will be included in the next evaluations.
; The third to fifth fields in $o are 100% values so they
; are also added to the total. The sixth and seventh fields
; are 50% values, so the calculation results in 2 which gives
; 100/2 = 50.
; After each calculation of $s I generate a $a, but this is
; just done because of shortness of code. Only after the
; seventh run is $s complete and will the calculation
; $s / $o[7] ($o[7] being the original length of the string)
; result in the correct return value.
; This explains why I can do without the floor parts. After
; all, if it's not a 100% or a 50% hit, it must be a 0% hit
; (ie a floor part).
Function a($)
dim $c, $h, $s, $o
$o = _, '.', 'x/', '\x', 'x|x', 'x|', '|x', $^0
For $c = 3 to 9
$ = Split(x+$+x, $o[$c-3])
$s = $s + UBound($) * 100/($c/4)
$a = $s / $o[7]
$ = Join($, $h)
$h = x
EndFunction
;!
;!
; end Linear Pachinko
Edited by DrillSergeant (2007-10-12 10:18 AM)
_________________________
The Code is out there
|
|
Top
|
|
|
|
#181552 - 2007-10-12 10:43 AM
Re: KiXgolf: Linear Pachinko - Public Round
[Re: DrillSergeant]
|
Mart
KiX Supporter
   
Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
|
|
|
Top
|
|
|
|
#181558 - 2007-10-12 03:33 PM
Re: KiXgolf: Linear Pachinko - Public Round
[Re: Allen]
|
Benny69
Moderator
   
Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
|
Ok now I understand, Gargoyle and I are the only ones from Earth.
Gargoyle, our solutions are almost the same thought process.
Here is my 288:
; begin Linear Pachinko
;
;!
Function a($b)
Dim $c,$d,$,$x,$y
For $d = 1 to $b^0
$c=SubStr($b,$d,1)
$x=f($b,$d,-1)
$y=f($b,$d,1)
If $c = '/'
$=$+$x
Else
If $c = \
$=$+$y
Else
If $c = '|'
$=$+($x+$y)/2
Else
If $c = '.'
$=$+100
EndIf
; EndIf
; EndIf
; EndIf
; Next
$a=$/($b^)
EndFunction
Function f($g,$,$h)
Dim $j
While $h
$=$+$h
$j=SubStr($g,$,1)
If $j <> _
$h=0
If $j = '.' | $ < 1 | $ > ($g^)
$f=100
; EndIf
; EndIf
; Loop
EndFunction
;!
;!
; end Linear Pachinko
|
|
Top
|
|
|
|
#181559 - 2007-10-12 03:58 PM
Re: KiXgolf: Linear Pachinko - Public Round
[Re: Benny69]
|
Benny69
Moderator
   
Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
|
Jochens' for 175
Function a($b)
Dim $c,$d,$
$d=Join(Split($b,_),'')
$=1
While $d
$c=Asc($d)
$d=Right($d,~)
$=$+(Asc($d)<47)
$a=$a+50*(2*($c=46|$*($c=47|$c=92))|$*($c>99))
$=$c=46
Loop
$a=$a/($b^)
EndFunction
|
|
Top
|
|
|
|
#181570 - 2007-10-12 09:23 PM
Re: KiXgolf: Linear Pachinko - Public Round
[Re: Benny69]
|
DrillSergeant
MM club member
   
Registered: 2004-07-09
Posts: 1164
Loc: Eijsden, the Netherlands
|
Benny, here's your 274 
; begin Linear Pachinko
;
;!
Function a($b)
Dim $c,$d,$,$x,$y
For $d = 1 to $b^0
$c=SubStr($b,$d,1)
; $x=f($b,$d,-1)
$x=f($b,$d,~)
$y=f($b,$d,1)
; If $c = '/'
$=$+$x*($c='/')
; Else
; If $c = \
$=$+$y*($c=\)
; Else
;If $c = '|'
$=$+($x+$y)/2*($c='|')
;Else
; If $c = '.'
$=$+100*($c='.')
; EndIf
; EndIf
; EndIf
; EndIf
; Next
$a=$/($b^)
EndFunction
Function f($g,$,$h)
Dim $j
While $h
$=$+$h
$j=SubStr($g,$,1)
If $j <> _
$h=0
If $j = '.' | $ < 1 | $ > ($g^)
$f=100
; EndIf
; EndIf
; Loop
EndFunction
;!
;!
; end Linear Pachinko
Edited by DrillSergeant (2007-10-12 09:23 PM)
_________________________
The Code is out there
|
|
Top
|
|
|
|
#181571 - 2007-10-12 09:26 PM
Re: KiXgolf: Linear Pachinko - Public Round
[Re: DrillSergeant]
|
DrillSergeant
MM club member
   
Registered: 2004-07-09
Posts: 1164
Loc: Eijsden, the Netherlands
|
and your 265 
; begin Linear Pachinko
;
;!
Function a($b)
Dim $c,$d,$,$x,$y
For $d = 1 to $b^0
$c=SubStr($b,$d,1)
$x=f($b,$d,~)
$y=f($b,$d,1)
$=$+$x*($c='/')+$y*($c=\)+($x+$y)/2*($c='|')+100*($c='.')
$a=$/($b^)
EndFunction
Function f($g,$,$h)
Dim $j
While $h
$=$+$h
$j=SubStr($g,$,1)
If $j <> _
$h=0
If $j = '.' | $ < 1 | $ > ($g^)
$f=100
EndFunction
;!
;!
; end Linear Pachinko
_________________________
The Code is out there
|
|
Top
|
|
|
|
#181573 - 2007-10-12 10:19 PM
Re: KiXgolf: Linear Pachinko - Public Round
[Re: DrillSergeant]
|
Benny69
Moderator
   
Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
|
Nice Roger!
|
|
Top
|
|
|
|
#181574 - 2007-10-12 10:21 PM
Re: KiXgolf: Linear Pachinko - Public Round
[Re: Benny69]
|
DrillSergeant
MM club member
   
Registered: 2004-07-09
Posts: 1164
Loc: Eijsden, the Netherlands
|
263 (switched some vars)
Your code has potential, benny... I wouldn't be surprised if we could get this below 250
; begin Linear Pachinko
;
;!
Function a($b)
Dim $,$d,$e,$x,$y
For $d = 1 to $b^0
$=SubStr($b,$d,1)
$x=f($b,$d,~)
$y=f($b,$d,1)
$e=$e+$x*($='/')+$y*($=\)+($x+$y)/2*($='|')+100*($='.')
$a=$e/($b^)
EndFunction
Function f($g,$,$h)
Dim $j
While $h
$=$+$h
$j=SubStr($g,$,1)
If $j <> _
$h=0
If $j = '.' | $ < 1 | $ > ($g^)
$f=100
EndFunction
;!
;!
; end Linear Pachinko
_________________________
The Code is out there
|
|
Top
|
|
|
|
Moderator: Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 685 anonymous users online.
|
|
|