Skip to main content
added 8 characters in body
Source Link
Jeremy
  • 121
  • 4

My code is all up on GitHub at github.com/jrotter/starry_night_contesthttps://github.com/jrotter/starry_night_contest

My code is all up on GitHub at github.com/jrotter/starry_night_contest

My code is all up on GitHub at https://github.com/jrotter/starry_night_contest

added 18 characters in body
Source Link
N. Virgo
  • 7.5k
  • 4
  • 33
  • 52

#Ruby, 7834.38

This was fun!

This was fun!

#Ruby, 7834.38

This was fun!

Source Link
Jeremy
  • 121
  • 4

This was fun!

I used a ruby generator program to write a ruby script as follows:

  • Draw a white 386x320 rectangle.

  • Put the rectangle in a list. Build a ruby file to generate that list of rectangles (only one in this initial case)

  • While the generated ruby file is less than 1024 bytes:

  • Search the list for the highest scoring rectangle

  • Try halving that rectangle horizontally and vertically

  • Replace that rectangle in the list with whichever pair scored lower

  • Build a ruby file to generate that list of rectangles

Note that my scoring algorithm randomly samples a bunch of colors and picks the one that results in the smallest difference from ORIGINAL.png. As it is probabilistic, I have rerun the script a bunch of times and picked the lowest scoring result.

Here's my best script thus far:

require 'chunky_png'
def r(w,x,y,z,k)
c=k*256+255
$p.rect(w,x,y,z,c,c)
end
$p=ChunkyPNG::Image.new(386,320,255)
r(97,160,192,199,7374989)
r(0,80,48,159,7045519)
r(193,160,289,199,6716560)
r(0,220,192,239,2963277)
r(338,80,385,159,8623770)
r(0,0,48,79,4938368)
r(49,0,96,79,4212844)
r(193,240,385,259,3756895)
r(193,260,385,279,3094854)
r(290,0,313,159,5271706)
r(314,0,337,159,8555664)
r(290,160,337,199,7570058)
r(338,160,385,199,3883603)
r(193,0,289,39,4674429)
r(193,40,289,79,5398918)
r(0,240,96,319,2566701)
r(97,240,192,319,2041898)
r(193,200,289,239,3424622)
r(290,200,385,239,4348033)
r(97,80,144,159,6124943)
r(145,80,192,159,5926550)
r(97,0,192,39,4609663)
r(97,40,192,79,5334923)
r(193,280,385,299,3619650)
r(193,300,385,319,3815999)
r(49,80,96,119,5334650)
r(49,120,96,159,2767683)
r(0,200,96,219,3951445)
r(97,200,192,219,5860985)
r(0,160,48,199,5468034)
r(49,160,96,199,2503733)
r(193,80,289,119,5599124)
r(193,120,289,159,6189974)
r(338,0,385,39,7900038)
r(338,40,385,79,11317092)
$p.save('o.png')

It generated the following image, which scored 7834 points:

[![Jeremy's entry: 7834 points][1]][1] [1]: https://i.sstatic.net/XvBps.png


To see how my algorithm came up with this, here's an animated GIF showing how it splits rectangles:

[![Jeremy's entry: How it was built][2]][2] [2]: https://i.sstatic.net/uFp9g.gif


My code is all up on GitHub at github.com/jrotter/starry_night_contest