#66046 - 2002-06-05 02:27 PM
Re: KixGolf scoring script
|
Shawn
Administrator
Registered: 1999-08-13
Posts: 8611
|
LOL, as long as you promise to stay - and post at least once a day !
Howard, Jens, I'm getting a little nervous now - all these other big guns want a piece of the action - afraid my Kixtart slice might come back to haunt me ...
-Shawn
[nice to see you back my friend - missed you !]
|
Top
|
|
|
|
#66047 - 2002-06-05 03:43 PM
Re: KixGolf scoring script
|
Sealeopard
KiX Master
Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
|
Okay, just to make it official: Despite having a dead computer at home right now (messed up the BOOT.INI during a repartitioning operation [and yes, I do have a backup ;-)]) I am already designing a new course. It will be posted on Saturday morning EST and will contain updated rules for KiXtart Golf to make it a) more challenging, b) more interesting, c) give you the chance of messing with others people's code, too.
I am also soliciting ideas for the coding challenge, it does not need to be anything practical, though.
I will also give the KiXGolf script a try. [ 05 June 2002, 16:05: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.
|
Top
|
|
|
|
#66048 - 2002-06-05 05:18 PM
Re: KixGolf scoring script
|
BrianTX
Korg Regular
Registered: 2002-04-01
Posts: 895
|
You're right, Howard. The problem with the quotes was in MY script, not yours. I had just assumed you had to work around it as well. After counting, I think I only saved about 5 keystrokes total in the script.
Brian
|
Top
|
|
|
|
#66049 - 2002-06-05 05:47 PM
Re: KixGolf scoring script
|
Howard Bullock
KiX Supporter
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
We seem to concur...
KixGolf.kix is my code KixGolf2.kix is Brian's code
C:\Data\Scripts>%tmp%\kix32 kixgolf.kix $A=KixGolf.kix
KixGolf score = 393
C:\Data\Scripts>%tmp%\kix32 kixgolf.kix $A=KixGolf2.kix
KixGolf score = 335
C:\Data\Scripts>%tmp%\kix32 kixgolf2.kix $F=KixGolf.kix
KixGolf score = 393
C:\Data\Scripts>%tmp%\kix32 kixgolf2.kix $F=KixGolf2.kix
KixGolf score = 335 [ 05 June 2002, 17:48: Message edited by: Howard Bullock ]
|
Top
|
|
|
|
#66051 - 2002-06-05 07:59 PM
Re: KixGolf scoring script
|
Radimus
Moderator
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
Hey Jens, There a bunch of stuff on this board that isn't practical...
Why should this be any different?
|
Top
|
|
|
|
#66052 - 2002-06-05 08:16 PM
Re: KixGolf scoring script
|
Howard Bullock
KiX Supporter
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
Yes Shawn I have 8 white-space characters in quotes. That added to your 385 makes 393.
I am glad to see that the code was at least executed a few times. [ 05 June 2002, 20:17: Message edited by: Howard Bullock ]
|
Top
|
|
|
|
#66054 - 2002-06-05 08:28 PM
Re: KixGolf scoring script
|
Howard Bullock
KiX Supporter
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
Jens, it appears that your right!
C:\Data\Scripts>%tmp%\kix32 kixgolf.kix $A=junk.txt
KixGolf score = 18
where junk.txt = code:
? 'This is a text!'
|
Top
|
|
|
|
#66056 - 2002-06-05 08:37 PM
Re: KixGolf scoring script
|
Shawn
Administrator
Registered: 1999-08-13
Posts: 8611
|
Right than ... lets hit the links ...
|
Top
|
|
|
|
#66057 - 2002-06-07 04:49 PM
Re: KixGolf scoring script
|
BrianTX
Korg Regular
Registered: 2002-04-01
Posts: 895
|
It seems pretty slow... I wonder when the KixGolf will start?
Brian
|
Top
|
|
|
|
#66059 - 2002-07-17 10:14 PM
Re: KixGolf scoring script
|
kholm
Korg Regular
Registered: 2000-06-19
Posts: 714
Loc: Randers, Denmark
|
Howard,
Your KixGolf scoring script is reporting to few point !!!
Each CRLF must be counted as one point (nessesary whitespace) Also it dosn't count the nessary whitespaces inside the code, your script will count this code:
code:
If $a>5 $x=1 EndIf
As 15 points Assuming this would be working KiX-code:
code:
If$a>5$x=1EndIf
The result should be 18, because all the whitespaces are required.
The following UDF, also counts required whitespaces, it might stil need some minor ajusts.
I have added the possibility to count parts of a script. If the optional parameter $CountMarkers is used and <> '' or 0 the UDF wil look for the line: ;GolfStart before beginning to count And wil stop counting when the line: ;GolfEnd is found.
code:
Function KixGolf($A,Optional $CountMarkers) $SpaceChars=Chr(9)+' ,;=<>()+-*/"'+"'" If Open(1,$A) = 0 $X=0 If $CountMarkers Do $C=ReadLine(1) Until $C = ';GolfStart' EndIf $C=ReadLine(1) While @Error=0 And $C <> ';GolfEnd' $InStr = 0 $StrCh = '' $j=len($C) For $h=1 To $j $Ch = substr($C,$h,1) If $Ch = '"' Or $Ch = "'" If $InStr If $Ch = $StrCh $InStr = 0 EndIf Else $InStr = 1 $StrCh = $Ch EndIf $X=$X+1 ; Count stringdelimiter Else If $InStr $X=$X+1 ; Count all chars inside strings Else $D=Asc($Ch) If $D=59 ; Ignore comments in rest of line $h=$j Else If $D=9 Or $D=32 ; Space or Tab: Count only if whitespace is demanded $Count = 1 If InStr($SpaceChars,SubStr($C,$h-1,1)) $Count=0 Else If InStr($SpaceChars,SubStr($C,$h+1,1)) $Count=0 EndIf EndIf $X=$X+$Count Else $X=$X+1 ; Count the character EndIf EndIf EndIf EndIf Next $C=Trim(ReadLine(1)) If $C <> '' And Left(Trim($C),1) <> ';' $X=$X+1 ; Each CRLF counts as one whitespace, If not a full comment-line EndIf Loop $RC=Close(1) $KixGolf=$X Else $KixGolf = "KixGolf, bad filename: " + $A EndIf EndFunction
-Erik
ps. I belive that only expirienced 'KiXters' will use this function, so it is not commented on how to use. I won't release it in the UDF section because i am sure it can be improved, and maybe some of you wil have something to add. Also, this UDF is of no general use, so maybe this or something similar should be linked directly to the active Golf tournament. [ 17 July 2002, 22:19: Message edited by: kholm ]
|
Top
|
|
|
|
#66062 - 2002-07-17 10:49 PM
Re: KixGolf scoring script
|
kholm
Korg Regular
Registered: 2000-06-19
Posts: 714
Loc: Randers, Denmark
|
Jens,
You have to count CRLF as ONE whitespace, because this code is also reported as 15 points
code:
If $a>5 $x=1 EndIf
Statements has to be separated by at least one whitespace, being: @CRLF Space Tabulator
If you omit to count the @CRLF the reported size wil not be of an operational script!!
-Erik
|
Top
|
|
|
|
#66063 - 2002-07-18 12:59 AM
Re: KixGolf scoring script
|
kholm
Korg Regular
Registered: 2000-06-19
Posts: 714
Loc: Randers, Denmark
|
The goal of a golf tournament should be to create the smallest WORKING KiX-script
The current rules state: Strokes are all characters in a piece of code except whitespace characters, unless the whitespace character is necessary for the line of code to work. Therefore, carriage returns and line feeds do not count.
I my opinion this should be refrased to: Strokes are all characters in a piece of code except whitespace characters, unless the whitespace character is necessary for the code to work. @CRLF counts 1 if the line containes code !!!!
If the goal of the golf tournament is to find the size of the smallest possible WORKING KiX-script to accomplish the job @CRLF has to be counted as 1 point when a line containes code.
Observe that @CRLF would normally count as 2. So you do get a small discount
-Erik [ 18 July 2002, 01:16: Message edited by: kholm ]
|
Top
|
|
|
|
#66064 - 2002-07-18 01:40 AM
Re: KixGolf scoring script
|
Howard Bullock
KiX Supporter
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
I'll let you guys argue this one out. The code I provide strips all white out and counts what left. I have not sat down to to examine all the possibilities where a white space character is or is not required. I do count all spaces within quoted strings. I think that as long as we measure with the same yard/meter stick the judging will be OK, especially when the spread seems to be 1,000 strokes. If the finalist are 1 or 2 strokes off at the end and they want to be so detailed, then they can counted anyway they want.
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 515 anonymous users online.
|
|
|