Anaminus
|
  |
 |
| Joined: 29 Nov 2006 |
| Total Posts: 5945 |
|
|
| 09 May 2013 02:43 PM |
Here's something interesting I though of the other day:
---- Assuming there's an unknown number of BrickColors, create a Lua function, which can run in a Script, that returns a table of all existing BrickColors. ----
A function is valid if it is provable that it returns all existing BrickColors. For example, if you can prove that there are no BrickColors with numbers greater than 1032 and less than 1, then you could just iterate between 1 and 1032.
|
|
|
| Report Abuse |
|
|
|
| 09 May 2013 03:04 PM |
I have a very inefficient method...
BCs = {} for r = 0, 255 do for g = 0, 255 do for b = 0, 255 do table.insert(BCs, BrickColor.new(Color3.new(r/255, b/255, g/255))) end end end singles = {} for i = 1, #BCs do if not singles[BCs[i]] then singles[BCs[i]] = BCs[i] end end for i, v in next, singles do print(i) end |
|
|
| Report Abuse |
|
|
|
| 09 May 2013 03:12 PM |
Umm, perhaps not...
Tried it out, studio crashed after using 2 GB of memory. |
|
|
| Report Abuse |
|
|
Dr01d3k4
|
  |
| Joined: 11 Oct 2007 |
| Total Posts: 17916 |
|
|
| 09 May 2013 03:15 PM |
Taking prehistoric's idea, trying to make it more efficient (a table of length 255 * 255 * 255 = bad): local brickColours = { }; for r = 0, 255, 1 do for g = 0, 255, 1 do for b = 0, 255, 1 do local n = BrickColor.new(r / 255, g / 255, b / 255).Name; if (not brickColours[n]) then brickColours[n] = true; end end end end |
|
|
| Report Abuse |
|
|
TheMyrco
|
  |
| Joined: 13 Aug 2011 |
| Total Posts: 15105 |
|
|
| 09 May 2013 03:35 PM |
You guys forgot that you need to write a function xD http://pastebin.com /NCMSXh7z
Also, http://puu.sh /2Q7L8.png |
|
|
| Report Abuse |
|
|
|
| 09 May 2013 04:07 PM |
Myrco, your little wait() would delay the whole thing by 500 thousand seconds. I suggest moving it :)
Nice takes on my method though. |
|
|
| Report Abuse |
|
|
|
| 09 May 2013 04:23 PM |
| Oh lol, I didn't see your qq image before posting that. |
|
|
| Report Abuse |
|
|
TheMyrco
|
  |
| Joined: 13 Aug 2011 |
| Total Posts: 15105 |
|
| |
|
|
| 09 May 2013 04:38 PM |
| I would test droid's, but my memory is sorta taken up at the moment... *cough*50billiondigitsofPi*cough* |
|
|
| Report Abuse |
|
|
|
| 09 May 2013 04:38 PM |
More first world problems... Not enough computer memory. |
|
|
| Report Abuse |
|
|
TheMyrco
|
  |
| Joined: 13 Aug 2011 |
| Total Posts: 15105 |
|
|
| 09 May 2013 04:39 PM |
| Droid's crashes your studio due to the many calculations and operations being done in a short period of time, I mean 255³ (= 16 581 375) is a lot. |
|
|
| Report Abuse |
|
|
|
| 09 May 2013 04:41 PM |
| Stick a wait in the first loop. |
|
|
| Report Abuse |
|
|
TheMyrco
|
  |
| Joined: 13 Aug 2011 |
| Total Posts: 15105 |
|
|
| 09 May 2013 04:44 PM |
Wouldn't help much, the last loop is done the most frequently. The second loop with a wait is doable, but can cause lagg waves. |
|
|
| Report Abuse |
|
|
Anaminus
|
  |
 |
| Joined: 29 Nov 2006 |
| Total Posts: 5945 |
|
|
| 09 May 2013 04:44 PM |
You know, it seems that may be the most best solution. Since, given an unknown number of BrickColors, there could potentially be BrickColors at every possible point. You could try to optimize such that it finds a reasonable amount of BrickColors at the start, but you would still have to look at every point in order to prove that you have all the BrickColors. And if you were only looking for reasonable amounts, then it would be way faster just to iterate through the BrickColor numbers. |
|
|
| Report Abuse |
|
|
|
| 09 May 2013 04:48 PM |
Technically gets all the current BrickColors.
pastebin /QL5WzmFR
> 142 > Time elapsed: 0.026945352554321 seconds |
|
|
| Report Abuse |
|
|
|
| 09 May 2013 04:49 PM |
@Myrco
I did it to my one. It got BrickColors, but crashed white outputting them.
@Ana We could do it to a reasonable degree of accuracy while skipping out a few possibilities:
local brickColours = { } for r = 0, 255, 3 do --Notice the step of 3 wait() for g = 0, 255, 3 do for b = 0, 255, 3 do local n = BrickColor.new(r/255, g/255, b/255) if (not brickColours[n]) then brickColours[n] = true end end end end |
|
|
| Report Abuse |
|
|
TheMyrco
|
  |
| Joined: 13 Aug 2011 |
| Total Posts: 15105 |
|
|
| 09 May 2013 04:50 PM |
@Pre: Trolol. Try a for loop for that.
@Scar: I like your optimizations, maybe I could do that too and adjust things. |
|
|
| Report Abuse |
|
|
|
| 09 May 2013 04:55 PM |
but there is a loss of quality dere.
Of course, the BrickColor system has to have less than 255^3 colours, otherwise there would be no point and we should use Color3 instead.
2.09 million is about the max values of BrickColors you would ever have. 262 thousand is a bit more realistic, but not really... practical. Steps of 15 reduces the total to around 5 thousand. |
|
|
| Report Abuse |
|
|
TheMyrco
|
  |
| Joined: 13 Aug 2011 |
| Total Posts: 15105 |
|
|
| 09 May 2013 04:58 PM |
Currently using http://pastebin.com /VYsPxtEK |
|
|
| Report Abuse |
|
|
TheMyrco
|
  |
| Joined: 13 Aug 2011 |
| Total Posts: 15105 |
|
|
| 09 May 2013 05:01 PM |
| Maybe storing all the possible numbers (0...255/255) in a table would've been more efficient. |
|
|
| Report Abuse |
|
|
TheMyrco
|
  |
| Joined: 13 Aug 2011 |
| Total Posts: 15105 |
|
|
| 09 May 2013 05:06 PM |
If you want the table then just run
local tab = {}; for x = 0, 255, 1 do table.insert(tab, x, x/255); wait(); end print(table.concat(tab, ", "))
and copy and paste the output between two braces (don't forget to add a zero at the beginning, though.) |
|
|
| Report Abuse |
|
|
TheMyrco
|
  |
| Joined: 13 Aug 2011 |
| Total Posts: 15105 |
|
|
| 09 May 2013 05:37 PM |
| Curently at 220, almost at 255 when it'll start out printing =D |
|
|
| Report Abuse |
|
|
Anaminus
|
  |
 |
| Joined: 29 Nov 2006 |
| Total Posts: 5945 |
|
|
| 09 May 2013 05:41 PM |
> Of course, the BrickColor system has to have less than 255^3 colours, otherwise there would be no point and we should use Color3 instead.
That isn't apart of the question. For an unknown amount of BrickColors, the maximum possible amount is 256^3, since that's the size of the Color3 space.
And like I said, if we're ignoring the proof part, then all you have to do is iterate between 1 and 1032 for BrickColors numbers, which gives you 144 colors, which is a pretty darn reasonable amount (all of them actually). You could also use BrickColor.palette to get 64 BrickColors guaranteed.
I suppose a better challenge might be to retrieve all 144 BrickColors only using BrickColor.new(Color3) or BrickColor.new(r,g,b). As efficiently as possible, of course. |
|
|
| Report Abuse |
|
|
TheMyrco
|
  |
| Joined: 13 Aug 2011 |
| Total Posts: 15105 |
|
|
| 09 May 2013 05:44 PM |
http://puu.sh /2QcVJ.png
o_o' |
|
|
| Report Abuse |
|
|
TheMyrco
|
  |
| Joined: 13 Aug 2011 |
| Total Posts: 15105 |
|
|
| 09 May 2013 05:47 PM |
It's probably because of how ROBLOX automaticly sorts tables.
(1, 1, 1) goes first because 0 has a higher value, therefore (0, 0, 0) is last (1, 1, 254/255) (1, 1, 253/255) ... (1, 254/255, 1) (1, 254/255, 254/255) (1, 254/255, 253/255) ...
Ye
|
|
|
| Report Abuse |
|
|