get("#356") -- num2hex get("#485") -- containsColor -- Job: Distinguish two classes of images -- Two images are supplied at once, one of each class. -- Task is to find out if the two images are swapped or not. -- -- input variables: img1, img2, solution [to last pair] -- output: a function returning: -- nil if still learning -- {"#executorid", varname1=value1, varname2=value2, ...} function selectColor(img) local x, y = math.random(0, img.width-1), math.random(0, img.height-1) color = img.getInt(x, y) end return function() -- select a new color when last guess was wrong if solution ~= guess then color = nil end if color == nil then if solution == nil then lastimg1, lastimg2 = img1, img2 return nil end selectColor(lastimg1) class2sampled = solution print("color of class "..(class2sampled and "2" or "1")..": ".. num2hex(color)) end lastimg1, lastimg2 = img1, img2 flag1 = containsColor(img1, color) flag2 = containsColor(img2, color) if flag1 == flag2 then color = nil return nil end guess = flag1 == class2sampled return {"#486", class2sampled=class2sampled, color=color} end
Began life as a copy of #484
test run test run with input download show line numbers
Travelled to 12 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #487 |
Snippet name: | Image distinguisher by randomly selected color [learner part] |
Eternal ID of this version: | #487/1 |
Text MD5: | a76912bdb80b158dcacf700446cee68f |
Author: | stefan |
Category: | |
Type: | Lua code - Image distinction (learner) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2015-03-03 18:26:57 |
Source code size: | 1209 bytes / 42 lines |
Pitched / IR pitched: | No / Yes |
Views / Downloads: | 613 / 167 |
Referenced in: | [show references] |