- #1
MathematicalPhysicist
Gold Member
- 4,699
- 371
the question in the title.
Nothing which is in a classical computer is truly random.Greg Bernhardt said:As far as I know it's random. Obviously the background and letter colors are coordinated to keep contrast.
That's like saying that coin flips aren't really random because you could use Newton's laws to calculate on which side the coin will end up. Some results from computers can be random FAPP.MathematicalPhysicist said:Nothing which is in a classical computer is truly random.
Though you can say that you don't know how is the colour chosen.
And what's wrong with that?DrClaude said:That's like saying that coin flips aren't really random because you could use Newton's laws to calculate on which side the coin will end up. Some results from computers can be random FAPP.
In @DrClaude's response, 'FAPP' abbreviates 'for all practical purposes'.MathematicalPhysicist said:And what's wrong with that?
If you know what the outcome will be how it can be random?
We don't actually know how to calculate this because of the unknown unknowns.
The point is that you can't know what the outcome will be. One could in theory dive in the code and try to figure out what the next color for an avatar will be, but even then that will probably depend on exactly how many new accounts have been created since the state of the program was checked. So FAPP no one knows, not even @Greg Bernhardt, what a particular new user's avatar's color will be. Therefore, it is random.MathematicalPhysicist said:If you know what the outcome will be how it can be random?
I searched google for FAPP and got a colorful definition from the urban dictionary which won't be displayed here. So I was quite sure that wasn't what he meant... :-Dsysprog said:In @DrClaude's response, 'FAPP' abbreviates 'for all practical purposes'.
If you knew that @DrClaude didn't mean that, and you didn't confidently surmise what he did mean, you could have asked, and if you did know what he meant, there wasn't much good reason for you to take him to task over the distinction between web server random number generators that produce imperfectly random numbers that are nonetheless usably random, and numbers that are more completely random.MathematicalPhysicist said:So I was quite sure that wasn't what he meant... :-D
So you're looking for a quantum explanation for how the dynamic avatars are built?MathematicalPhysicist said:Nothing which is in a classical computer is truly random.
I'm not a xenforo licensee, so I don't have access to the source code; however, if you're right about the color being 'random', presumably over a predefined pallette (the color and other characteristics can be overridden in css in file message.less, according to content of the discussion thread a link to which was posted by @jedishrfu), you would have to look at the server's php.ini file to ensure that php is getting its numbers from /dev/random, and then investigate the specifics of the implementation there, in order to get a reasonable idea of 'how random' the numbers generated really are, and the 'quantum explanation' would extend only to the ensourcement of the numbers in the /dev/random entropy pool.Greg Bernhardt said:So you're looking for a quantum explanation for how the dynamic avatars are built?
Let me take a look and see if I can find the code for it.
Honestly I don't have time for all this. Best I can do is find the php code.sysprog said:you would have to look at the server's php.ini file to ensure that php is getting its numbers from /dev/random, and then investigate the specifics of the implementation there, in order to get a reasonable idea of 'how random' the numbers generated really are, and the 'quantum explanation' would extend only to the ensourcement of the numbers in the /dev/random entropy pool.
That's in itself far beyond any reasonable call of duty.Greg Bernhardt said:Honestly I don't have time for all this. Best I can do is find the php code.
protected function getDefaultAvatarHtml($username, $innerClassHtml, array &$outerAttributes)
{
$styling = $this->getDefaultAvatarStyling($username);
if (empty($outerAttributes['style']))
{
$outerAttributes['style'] = '';
}
else
{
$outerAttributes['style'] .= '; ';
}
$outerAttributes['style'] .= "background-color: $styling[bgColor]; color: $styling[color]";
if (empty($outerAttributes['class']))
{
$outerAttributes['class'] = '';
}
else
{
$outerAttributes['class'] .= ' ';
}
$outerAttributes['class'] .= 'avatar--default avatar--default--dynamic';
return '<span class="' . $innerClassHtml . '">' . $styling['innerContent'] . '</span>';
}
protected function getDefaultAvatarStyling($username)
{
if (!isset($this->avatarDefaultStylingCache[$username]))
{
$bytes = md5($username, true);
$r = dechex(round(5 * ord($bytes[0]) / 255) * 0x33);
$g = dechex(round(5 * ord($bytes[1]) / 255) * 0x33);
$b = dechex(round(5 * ord($bytes[2]) / 255) * 0x33);
$hexBgColor = sprintf('%02s%02s%02s', $r, $g, $b);
$hslBgColor = \XF\Util\Color::hexToHsl($hexBgColor);
$bgChanged = false;
if ($hslBgColor[1] > 60)
{
$hslBgColor[1] = 60;
$bgChanged = true;
}
else if ($hslBgColor[1] < 15)
{
$hslBgColor[1] = 15;
$bgChanged = true;
}
if ($hslBgColor[2] > 85)
{
$hslBgColor[2] = 85;
$bgChanged = true;
}
else if ($hslBgColor[2] < 15)
{
$hslBgColor[2] = 15;
$bgChanged = true;
}
if ($bgChanged)
{
$hexBgColor = \XF\Util\Color::hslToHex($hslBgColor);
}
$hslColor = \XF\Util\Color::darkenOrLightenHsl($hslBgColor, 35);
$hexColor = \XF\Util\Color::hslToHex($hslColor);
$bgColor = '#' . $hexBgColor;
$color = '#' . $hexColor;
if (preg_match($this->avatarLetterRegex, $username, $match))
{
$innerContent = htmlspecialchars(utf8_strtoupper($match[0]));
}
else
{
$innerContent = '?';
}
$this->avatarDefaultStylingCache[$username] = [
'bgColor' => $bgColor,
'color' => $color,
'innerContent' => $innerContent
];
}
return $this->avatarDefaultStylingCache[$username];
}
$bytes = md5($username, true);
$r = dechex(round(5 * ord($bytes[0]) / 255) * 0x33);
$g = dechex(round(5 * ord($bytes[1]) / 255) * 0x33);
$b = dechex(round(5 * ord($bytes[2]) / 255) * 0x33);
$hexBgColor = sprintf('%02s%02s%02s', $r, $g, $b);
You just tagged the wrong person.jedishrfu said:Thanks @Greg
That means it will eventually happen again.jedishrfu said:Oops! It was a pseudo-random mistake, I swear.
Dunno, I once learned electronic devices and also still learn solid state physics.Greg Bernhardt said:So you're looking for a quantum explanation for how the dynamic avatars are built?
Let me take a look and see if I can find the code for it.
You are using a custom image as an avatar though.MathematicalPhysicist said:I am asking since the same colour here in my avatar also appeared in the math.stackexchange, so I guess that's sort of a coincidence.
StackExchange sites don't use XF. They have their own software, much different from PF.jedishrfu said:Probably not a coincidence as they may be using the same software as PF with different outward color schemes...
I meant before I uploaded the custom pic, the same colour used in both websites.Greg Bernhardt said:You are using a custom image as an avatar though.
You could test your observation for probable non-coincidentiality by having a friend register with the same new username at both sites, and seeing whether the friend's 2 color pairs (letter and background) are also the same -- establishing repeatability is important in scientific investigation ...MathematicalPhysicist said:I meant before I uploaded the custom pic, the same colour used in both websites.
Could be, but generally StackExchange site developers won't publish the code for the public. In fact, getting hold of site developers is much more difficult there than in PF, because a simple ping to Greg won't work there.jedishrfu said:Could be using a common php library then?
https://www.idquantique.com/random-number-generation/products/quantis-random-number-generator/Wrichik Basu said:Please don't tell me after a while that Greg's servers use Quantum computation to choose an avatar.
The color of the avatar in PF is decided based on a combination of factors, including the user's preferences, the design of the platform, and the coding of the website.
No, the color of the avatar in PF is not chosen randomly. While there may be an element of randomness in some cases, the color is usually determined by specific criteria set by the platform or the user.
Yes, in most cases, users are able to change the color of their avatar in PF. This can usually be done through the platform's settings or preferences menu.
There may be scientific reasons for the color choices in PF avatars, depending on the platform and its goals. For example, certain colors may be associated with certain emotions or may be chosen to improve user experience.
The color of your avatar in PF may affect your experience on the platform in various ways. For example, it may influence how other users perceive you, or it may impact your own mood and behavior while using the platform.