Time to post your final scores of the first private coding round and the associated KiXtart scripts. You're welcome to post the scripts via PostPrep.
As most of you figures out, the primary way to display the images would be via the KiXforms DLL. However, as I already hinted in the rules, there is at least one other way to create the image display. Some of you suspected Internet Explorer as the tool of choice.
The easiest way to use Internet Explorer to display the images is to create a HTML page. The page would consist of a simple table with rows and columns according to the number of pixels for width and height of the image. Then, each table cell would be set to be one pixel wide and one pixel high. The background color of each cell would represent the coor of the corresponding image pixel. The HTML syntax would look like this for a 10x10 image:
; begin PxMagic ; ;! Function PxMagic($) $PxMagic=PxMDisplay(PxMRead($)) EndFunction ;! ;! ; end PxMagic
code:
; begin PxMRead ; ;! Function PxMRead($a) Dim $ $a=Open(3,$a) DO $=$+' '+ReadLine(3) $a=instr($,'#') $=iif($a>0,left($,$a-1),$) Until @ERROR<0 $PxMRead=$ $=close(3) EndFunction ;! ;! ; end PxMRead
code:
; begin PxMDisplay ; ;! Function PxMDisplay($) Dim $t, $j, $w, $m, $f, $i, $y, $r, $a, $k $f=CreateObject("Kixtart.Form") $=split($) FOR EACH $t in $ IF($t<>'') $[$j]=$t $j=$j+1 EndIf NEXT $t=right($[0],1) $a=iif($t=3,3,1) $k=iif($t=1,3,4) $w=$a*$[1] $m=(1.0/$[3])*255 For $i=$k to $j-1 Step $a $y=($i-$k)/$w $r=iif($t=1,255*(1-$[$i]),$m*$[$i]) $r=$r+256*iif($t=3,$m*$[$i+1],$r)+65536*iif($t=3,$m*$[$i+2],$r) $f.PSet(($i-$y*$w)/$a,$y,$r) Next $t=$f.timer(9999) $t.OnTimer="$f.hide" $f.Show While $f.Visible $=Execute($f.DoEvents) Loop
quote:After looking at Howard's, I am not sure anything can be gained by viewing my effort
Jack, you sold yourself short. I did not realize that the default form size was sufficient to display the images. But after a quick test it does seem to be so. Thanks.
Commenting out the following line from my PxMDisplay (posted above).
code:
$a.Size = 700,700
code:
KiXtart KiXtart Version = KiXtart 2001 4.22 Release Candidate 1 KiXforms Version = 2.3.0.41 KiXGolf Script = kixgolf_pxmagic.kix
Computer OS = Windows 2000 Professional CPU = Intel Pentium III Speed = 848 MHz Memory = 512 MB
k, it looks like hoby cheated. anyway, here is my 481 that works lot better than 480.
now, wasn't the order said, pxmagic does the handling, reader does reading and display does the display? in hoby's code, the reader does the reading and displaying and thus I would not accept it.
Couldn't we have a P1 format that starts with byte value of 1 or am I misunderstanding the function of this code? I think you might need something like this:
code:
if $[1]<>'P1' $k=5 $m=$m/$[4] endif
I do like your code:
quote:$3=2*($[1]=P3) { or $z = $[1]=P3}
Cute
[ 19. October 2003, 21:39: Message edited by: Jack Lothian ]
Lonkero, I think I provided the best overall solution. Even adding four strokes to silence the open and close commands, my entry has a better score. I think that the nesting of UDFs is permissable since each UDF does what it is suppose to do.
I initially had a fixed 700x700 form that would display the test suite. Jens did not like that since it prohibits the functioning of the code with larger images. You relied on the default form size like Jack did . I opt'ed to reduce my score by doing the same. Since this has the same issue as my fix form we all will need to add variable sizing to each image. I had the code in my post but had it commented out. To meet Jens work with any size requirements, we all need to add code. Both your code and mine will require the addition of this line "$a.ClientSize = $[2],$[3]" an addition of 23 strokes to each of our scores.
But I have to say congrats on finding all those unecessary quotes in my code. I don't remember seeing that technique applied previously in other Golf outings and would not have thought to remove them and test. You are the optimum optimizer.
[ 19. October 2003, 23:09: Message edited by: Howard Bullock ]
hoby, my show(3) does display in fullscreen, and thus I wonder what more resizing it needs. it will display all images the current display can handle.
jack, you would need to know what it does to say does it worky or not. the field $[4] ("0" from open in front, thus actually file field 3) is the maximum of color depth in p3 and p2. in P1 it is either 1 or 0. with check of if it is 0 I remove all the other checking needs. if it's zero, the value is kept at 255 which is correct for P1. if it's 1 (which it can be in P1) 255 is devided with it, which means that it still is 255. thus, the code stands fully correct. IIRC, that trick removed 1 stroke.
Function PxMRead($) $=""+open(1,$) do $=join(split($+" "+join(split(split(readline(1),#)[0], ))," ")) until instr($," ")=1+@error PxMDisplay(split($),CreateObject(Kixtart.Form)) close(1) EndFunction
You guys are amazing. I thought I had seen most of the tricks for compressing kixtart but between you two you must have found about a dozen that I had never seen in our previous kixgolf matches. You guys must never sleep or if you do you dream kixtart.
Joel,
Thanks for the explanation. You also you are correct about cropping. I believe that the last line or 2 of pixels in the images "columns" & "Blackbuck" are cropped by the default box size. Also, I think that both the kixform & picturebox objects have beveled edges of 2 pixels width & the beveled edges crop the boxes by 4 extra pixels. Thus I believe the true dimensions of the minimum box is $a.ClientSize = 4+$[2],4+$[3].
PS: When I first started participating in kixgolf, I like Jooel felt players were cheating but after thinking about it I realized the problem was the mindset that I brought to the game. The problem is that I have spent my whole life learning "good" programming techniques & kixgolf forced me & the rest of the players to sometimes disregard this experience. It is kind of like playing give-a-way chess. Every move you make grates on your nerves & feels wrong. The point of this monologue is that I don’t think Howard was cheating. We need to distinguish between breaking “good programming” rules & breaking Jens rules. In Kixgolf the only rules are Jens rules. One of the reason both of you are so successful at kixgolf is your ability to think outside the rules. So how about we leave the penalty calls to the ref.
For $a = $b to ubound($)-1 $d=$[$a] If $x=$[1] $x=0 $y=$y+1 EndIf $c=Iif($d=0,$w,0) If $b=4 $c=Iif($d=0,$w,$f.RGB($d,$d,$d)) EndIf If $[0]=P3 $c=$f.RGB($d,$[$a+1],$[$a+2]) $a=$a+2 EndIf
I might later post that long code of mine which used multidimmed arrays and stuff, like hoby at some point asked.
now what comes to rules, when I shouted about those, I was something called drunk. anyways, shouting aside, IIRC, console-output has been always disliked in golf, no? if I'm wrong, I'm wrong.
anyway, this brings us back to the base. there might be more than jens doing the rule-sets and such as one mind can't think of everything 2 minds can. heh, like in the first topic we saw about dozen questions what is allowed and what is not. never ever it occured to me to ask 2 tricks from hoby are they allowed or not as I just thought they weren't.
now, isn't anyone anymore shrinking the code? see there is lot of potential...
I may have time this weekend, Lonkero. Very busy at work and with activities in the evening this week.
I am just astounded at all the places where quotes are NOT needed and the code still works. With competition like you, one has to pull out all the stops in order to keep ahead of you and keep you wondering. Now that the cat is out out-of-the-bag, it will be hard for me to beat you, but I will give it a try sometime before the cutoff date.
I would really like to be able to compete with Regular expresssions once, but those long class names are killers. Maybe a special scoring match sometime where CreatObject("zzz") counts as 1 regardless of the string inside.