Pages:
Author

Topic: 1 or 0. The Binary Guessing Game. (Read 2794 times)

member
Activity: 81
Merit: 1002
It was only the wind.
March 22, 2013, 05:30:38 PM
#26
Couldn't he just generate an Excel spreadsheet, take a screenshot of it, sha512 the image and post the digest? Then reveal the image when the game is over?
legendary
Activity: 1512
Merit: 1036
January 05, 2013, 04:04:20 AM
#23
I was initially making a number of bits (yes, a single 256-bit number, known in JavaScript as NaN), where the probability of a bit being set was based on a ratio, however "true randomness" could let the OP cheat so I had hacked a check loop on.
Yes, but that is not going to work because the OP can just keep generating until he gets one that favors him, and only THEN reveal it.
Please re-read my sentence. One sentence isn't too much to comprehend before posting. Finish reading until the end.

My second posted code only gives fair results. I added checking because I saw within minutes (not two months later) and addressed such a possibility for cheating:
I tweaked the code so only a secret grid with an equal number of 0 and 1 bits will be used (only about 1 in 20 will have an equal number). Otherwise the operator may search for one with bias.

The script also creates a unfalsifiable hash that can be published before gaming begins:
You post the SHA256 now so we can later verify the real secret "grid" was used.

The coding was just an example to show in comparison how preposterous, naive, and unprovable the original poster's game proposal was (bet against his unpublished Excel spreadsheet). Getting either a working Python environment or being able to do something with your JavaScript snippet are both tasks likely out of his depth.
vip
Activity: 1316
Merit: 1043
👻
January 05, 2013, 12:40:41 AM
#22

Wow, really? Some JS:

var gridSize = 1024;
var bits = 512;

var assignedBits = 0;
var grid = [];

while(assignedBits < bits){
newLoc = Math.floor(Math.random() * gridSize);
if(!grid[newLoc]){
grid[newLoc] = 1;
assignedBits++;
}
}

No need for floats or anything.

Wow, really? Some Python (that produces output):

import random;s=1024;b=512;g=[1]*b+[0]*(s-b);random.shuffle(g)
for i in range(0,s,16):print '{0:4d}:{1}'.format(i,g[i:i+16])


I was initially making a number of bits (yes, a single 256-bit number, known in JavaScript as NaN), where the probability of a bit being set was based on a ratio, however "true randomness" could let the OP cheat so I had hacked a check loop on.
Yes, but that is not going to work because the OP can just keep generating until he gets one that favors him, and only THEN reveal it.
legendary
Activity: 1512
Merit: 1036
December 27, 2012, 04:13:57 PM
#21

Wow, really? Some JS:

var gridSize = 1024;
var bits = 512;

var assignedBits = 0;
var grid = [];

while(assignedBits < bits){
newLoc = Math.floor(Math.random() * gridSize);
if(!grid[newLoc]){
grid[newLoc] = 1;
assignedBits++;
}
}

No need for floats or anything.

Wow, really? Some Python (that produces output):

import random;s=1024;b=512;g=[1]*b+[0]*(s-b);random.shuffle(g)
for i in range(0,s,16):print '{0:4d}:{1}'.format(i,g[i:i+16])


I was initially making a number of bits (yes, a single 256-bit number, known in JavaScript as NaN), where the probability of a bit being set was based on a ratio, however "true randomness" could let the OP cheat so I had hacked a check loop on.
sr. member
Activity: 412
Merit: 250
December 27, 2012, 03:30:37 PM
#20
Awh we all love JavaScript Smiley
vip
Activity: 1316
Merit: 1043
👻
December 25, 2012, 11:26:27 PM
#19
Because coding iz phun: I made a revision to this silly game with some awful python code where you can choose any number of bits when you generate your "grid", and can specify how many 1 bits you want in it. Less 1's = harder odds, and guess-the-bit is more like playing battleship.

import random, hashlib
numberOfBits = 192  # edit this: how many bits (max 65536, slow above 4096)
numberOfOnes = 4  # edit this: how many 1's in the bit list
numberOfOnesFound = 0
while numberOfOnesFound != numberOfOnes:
    secret = 0
    bitIndex = 0
    while bitIndex < numberOfBits:
        randomBit = int(random.uniform((float(numberOfOnes)/float(numberOfBits)),(1+(float(numberOfOnes)/float(numberOfBits)))))
        secret = secret + (randomBit) * 2**(numberOfBits-bitIndex-1)
        bitIndex +=1
    binsecret = bin(secret)[2:].zfill(numberOfBits)
    numberOfOnesFound = binsecret.count('1')
#    print 'checking: number-of-ones-found: ' + str(numberOfOnesFound) + ' (need ' + str(numberOfOnes) + ')'
hexsecret = hex(secret)[2:-1].zfill((numberOfBits+3)/4)  # was 64
print '\nsecret: ' + hexsecret
print 'SHA256: ' + hashlib.sha256(hexsecret).hexdigest()
print '\n       01234567 89ABCDEF\n       -------- --------'
linprt = 0
while linprt <= numberOfBits-1:
    print hex(linprt)[2:].zfill(4) + 'h: ' + str(binsecret[linprt:linprt+8]) + ' ' + str(binsecret[linprt+8:linprt+16])
    linprt += 16


secret: 800000001000000000000000000000080000000000010000
SHA256: b97f4dfd717c877a8bbbc84b7eb7e569fcd9c8618846e3fcecc4aa5ed93bb81d

       01234567 89ABCDEF
       -------- --------
0000h: 10000000 00000000
0010h: 00000000 00000000
0020h: 00010000 00000000
0030h: 00000000 00000000
0040h: 00000000 00000000
0050h: 00000000 00000000
0060h: 00000000 00000000
0070h: 00000000 00001000
0080h: 00000000 00000000
0090h: 00000000 00000000
00a0h: 00000000 00000001
00b0h: 00000000 00000000


Wow, really? Some JS:

var gridSize = 1024;
var bits = 512;

var assignedBits = 0;
var grid = [];

while(assignedBits < bits){
newLoc = Math.floor(Math.random() * gridSize);
if(!grid[newLoc]){
grid[newLoc] = 1;
assignedBits++;
}
}

No need for floats or anything.
sr. member
Activity: 412
Merit: 250
November 11, 2012, 02:05:46 AM
#18
Wow. Flame wars are childish. And Daniel Daniel that was unescerry.anyone can run a website! Yup hate to ruin your day but anyone can design a website these days.
hero member
Activity: 854
Merit: 1000
November 10, 2012, 08:16:53 PM
#17
I'm 12.
I fully understand bitcoin concepts.
Age should never be a problem.
I run a hosting company.
I built my computer.
I mine bitcoins and have fully worked out electric costs and shares per hour.
Never underestimate a kid.
I've been doing Bitcoin since I was 12.  My solution was to say I was 17 until a couple months ago, where I said I wasn't telling anyone.  Then I told people here.  The trick is to build up a reputation, then reveal your age.  People won't care as much.
hero member
Activity: 854
Merit: 1000
November 10, 2012, 08:05:35 PM
#16
Well you do. Even with colo.
Actually it's a resellers account.

Actually no, do your research, if your a reseller account then you made a bad contract, also all hosting companies i know of have there own hardware, and rent space in a datacenter.

No more 12 yrs allowed, we can't have Chris Henson coming for us
Bitcoin doesn't discriminate against age, and we shouldn't in this forum. How old were you when you when you first learned about money and it's value? Probably even before you started getting your lunch money stolen in school.

As we have learned in this forum, being of age to be able to enter into a contract has little value in determining if something is a scam or evaluating whether preponderance of law in a courtroom will allow you to successfully seek relief. After all, a contract is nothing but a "permission to sue" form.

I learned about money, but I wasn't making decisions how the money was evolving. Also never got my lunch money stolen, I was taking lunch money Wink
Also I pretty sure, that you have to be of a certain age to enter into a contract without a parent consenting for you since, you may not understand what the fact of the contract is. While bitcoin doesn't discriminate against age, this forum should since they are spreading false information. This is not daycare.
(1) Fuck you.
(2) I'm 14 (I revealed my age #bitcoin-otc!  This is a major event!).
(3) I've run a few websites.  I've co-run one website.
(4) I have participated in HUNDREDS of trades on #bitcoin-otc, since I was 12.  Age doesn't mean anything.
(5) Fuck you.
legendary
Activity: 1498
Merit: 1000
November 05, 2012, 10:22:01 AM
#15
Well you do. Even with colo.
Actually it's a resellers account.

Actually no, do your research, if your a reseller account then you made a bad contract, also all hosting companies i know of have there own hardware, and rent space in a datacenter.

No more 12 yrs allowed, we can't have Chris Henson coming for us
Bitcoin doesn't discriminate against age, and we shouldn't in this forum. How old were you when you when you first learned about money and it's value? Probably even before you started getting your lunch money stolen in school.

As we have learned in this forum, being of age to be able to enter into a contract has little value in determining if something is a scam or evaluating whether preponderance of law in a courtroom will allow you to successfully seek relief. After all, a contract is nothing but a "permission to sue" form.

I learned about money, but I wasn't making decisions how the money was evolving. Also never got my lunch money stolen, I was taking lunch money Wink
Also I pretty sure, that you have to be of a certain age to enter into a contract without a parent consenting for you since, you may not understand what the fact of the contract is. While bitcoin doesn't discriminate against age, this forum should since they are spreading false information. This is not daycare.
legendary
Activity: 1512
Merit: 1036
November 05, 2012, 07:29:29 AM
#14
Well you do. Even with colo.
Actually it's a resellers account.

Actually no, do your research, if your a reseller account then you made a bad contract, also all hosting companies i know of have there own hardware, and rent space in a datacenter.

No more 12 yrs allowed, we can't have Chris Henson coming for us
Bitcoin doesn't discriminate against age, and we shouldn't in this forum. How old were you when you when you first learned about money and it's value? Probably even before you started getting your lunch money stolen in school.

As we have learned in this forum, being of age to be able to enter into a contract has little value in determining if something is a scam or evaluating whether preponderance of law in a courtroom will allow you to successfully seek relief. After all, a contract is nothing but a "permission to sue" form.
legendary
Activity: 1498
Merit: 1000
November 05, 2012, 01:56:37 AM
#13
Well you do. Even with colo.
Actually it's a resellers account.

Actually no, do your research, if your a reseller account then you made a bad contract, also all hosting companies i know of have there own hardware, and rent space in a datacenter.

No more 12 yrs allowed, we can't have Chris Henson coming for us
sr. member
Activity: 412
Merit: 250
November 05, 2012, 01:48:09 AM
#12
Well you do. Even with colo.
Actually it's a resellers account.
legendary
Activity: 1498
Merit: 1000
November 04, 2012, 03:21:51 AM
#11
Fair enough. Grin. Even sometimes I can overlook the simple ;(.
I still use free image hosting services because it doesn't damage my max bandwidth.

then you obviously don't run a hosting company if you have a max bandwidth.


When can we get an age restriction on this site, maybe 17+ I feel like I am at daycare.
sr. member
Activity: 412
Merit: 250
November 04, 2012, 03:00:06 AM
#10
Fair enough. Grin. Even sometimes I can overlook the simple ;(.
I still use free image hosting services because it doesn't damage my max bandwidth.
legendary
Activity: 1512
Merit: 1036
November 03, 2012, 07:03:02 AM
#9
I know about the tag thing. I meant where's the best place to host the images. And I use many forums and sometime the image system is different.

I'm 12.
I fully understand bitcoin concepts.
Age should never be a problem.
I run a hosting company.
I built my computer.
I mine bitcoins and have fully worked out electric costs and shares per hour.
Never underestimate a kid.


sr. member
Activity: 412
Merit: 250
November 03, 2012, 03:37:18 AM
#8
Thanks guys for the advice. I will use the python version as its pretty useful. Thanks.
Deepceleron Ty alot. I will donate some share of any profit.
I'll see if I can play with the code a bit.
So I'm guessing I post the sha256 before the draw. And the private afterwards.
legendary
Activity: 1512
Merit: 1036
November 01, 2012, 09:42:01 PM
#7
Because coding iz phun: I made a revision to this silly game with some awful python code where you can choose any number of bits when you generate your "grid", and can specify how many 1 bits you want in it. Less 1's = harder odds, and guess-the-bit is more like playing battleship.

import random, hashlib
numberOfBits = 192  # edit this: how many bits (max 65536, slow above 4096)
numberOfOnes = 4  # edit this: how many 1's in the bit list
numberOfOnesFound = 0
while numberOfOnesFound != numberOfOnes:
    secret = 0
    bitIndex = 0
    while bitIndex < numberOfBits:
        randomBit = int(random.uniform((float(numberOfOnes)/float(numberOfBits)),(1+(float(numberOfOnes)/float(numberOfBits)))))
        secret = secret + (randomBit) * 2**(numberOfBits-bitIndex-1)
        bitIndex +=1
    binsecret = bin(secret)[2:].zfill(numberOfBits)
    numberOfOnesFound = binsecret.count('1')
#    print 'checking: number-of-ones-found: ' + str(numberOfOnesFound) + ' (need ' + str(numberOfOnes) + ')'
hexsecret = hex(secret)[2:-1].zfill((numberOfBits+3)/4)  # was 64
print '\nsecret: ' + hexsecret
print 'SHA256: ' + hashlib.sha256(hexsecret).hexdigest()
print '\n       01234567 89ABCDEF\n       -------- --------'
linprt = 0
while linprt <= numberOfBits-1:
    print hex(linprt)[2:].zfill(4) + 'h: ' + str(binsecret[linprt:linprt+8]) + ' ' + str(binsecret[linprt+8:linprt+16])
    linprt += 16


secret: 800000001000000000000000000000080000000000010000
SHA256: b97f4dfd717c877a8bbbc84b7eb7e569fcd9c8618846e3fcecc4aa5ed93bb81d

       01234567 89ABCDEF
       -------- --------
0000h: 10000000 00000000
0010h: 00000000 00000000
0020h: 00010000 00000000
0030h: 00000000 00000000
0040h: 00000000 00000000
0050h: 00000000 00000000
0060h: 00000000 00000000
0070h: 00000000 00001000
0080h: 00000000 00000000
0090h: 00000000 00000000
00a0h: 00000000 00000001
00b0h: 00000000 00000000
legendary
Activity: 1512
Merit: 1036
November 01, 2012, 08:28:40 AM
#6
No need for images or Excel:

python example:

import random
import hashlib
num1s = 0
while num1s != 128:
    secret = random.randint(0,2**(16*16)-1)
    binsecret = bin(secret)[2:].zfill(256)
    num1s = binsecret.count('1')
hexsecret = hex(secret)[2:-1].zfill(64)    
print 'secret: ' + hexsecret
print 'SHA256: ' + hashlib.sha256(hexsecret).hexdigest()
print '\n    ABCDEFGHIJKLMNOP\n    ----------------'
linprt = 0
while linprt < 16:
    print str(linprt).zfill(2) + ': ' + str(binsecret[linprt*16:linprt*16+16])
    linprt += 1
    


secret: 095d89f44b28976bc3fc65eab15241ed9a86ad19654564f4382a7bdb13ba839c
SHA256: 35a72c21c86e21e3797614424ed98d649b2bdeddd6ec0acb5190b1db741f499d

    ABCDEFGHIJKLMNOP
    ----------------
00: 0000100101011101
01: 1000100111110100
02: 0100101100101000
03: 1001011101101011
04: 1100001111111100
05: 0110010111101010
06: 1011000101010010
07: 0100000111101101
08: 1001101010000110
09: 1010110100011001
10: 0110010101000101
11: 0110010011110100
12: 0011100000101010
13: 0111101111011011
14: 0001001110111010
15: 1000001110011100


I tweaked the code so only a secret grid with an equal number of 0 and 1 bits will be used (only about 1 in 20 will have an equal number). Otherwise the operator may search for one with bias.

You post the SHA256 now so we can later verify the real secret "grid" was used.
To play: Pick a bit 0-255. If operator says it's 1, you double yer money.

If only there was some way of automating the betting on a number between 0-65536 with hashes and secrets combined with user-generated random data unique to each bet....
hero member
Activity: 728
Merit: 540
November 01, 2012, 04:33:46 AM
#5
To make it more related to bitcoins :

Create a bitcoin address and its private key (with no money in it)

Publish the address and assign the first 256 bits of the private key to the grid bits, keep that secret of course.

At the end of the game, publish the private key so everyone can check that you didn't cheat with defining the 16x16 grid.

my 0.02BTC
Pages:
Jump to: