\[ALPHA\] FTC dice / coinflip game
-
[quote name=“UKMark” post=“46410” timestamp=“1387534335”]
[quote author=slavco link=topic=5931.msg46025#msg46025 date=1387416717]
Yup on small amount of bets I can easy find the secret ( with given formula ) that will satisfy the games outcomes e.g. prove that system is fair. For x number of bets probability for me to generate secret key that will prove that game is fair is 0.5^x. For example if we have 10 bets and I want to generate secret that will satisfy the outcomes probability for me to find that secret is 0.000976562 ;)The only fair situation is the following: to reveal before the bet hash of the secret and after the bet to reveal the secret.
Do you want to make an experiment:
- I’ll reveal the formula
- I’ll create special address for you
- You place 5 bets x 10 FTC ( you will loose them all )
- I’ll give you secret that will satisfy the formula and the outcome
What do you think? :)
[/quote]
Yes I don’t dispute this is a viable scam if you only have a very small amount of bets eg: 5 bets and produce the secret for a formula to coincide with the given result of only 32 possibilities (ie: Heads/Tails ^ 5), but start introducing more bets (Also more possibilities) and this will become exponentially more difficult and require some serious computational power and time, time that would/could exceed the given time frame of releasing the secret. To put this in perspective @ only 30 bets (2 ^ 30) the possibilities would increase to 1073741824.
I suppose the operator of such a scam would be taking the biggest gamble of anyone and betting (hoping) they have no more than x amount of bets before this scam would be totally exposed.
[/quote]Hmm but there are strategies to calculate the “scam” all the time plus not all bets are wins => if operator calculates 30% chances and promote 50% chances he will have very small amount for processing. Extra with sha256 ASIC chips this is quite easy. I’m still waiting to see server secret hash created with scrypt, bmw or some another function :)
Also another approach is to fake first X bets and after that ( enough profit ) to continue to be fair.
As Kevlar note for this reasons to be fair you must reveal the hash of the secret before bet and after bets to reveal the secret. In this way users would know that secret wasn’t changed and can check fairness via published formula for bet calculation.
-
[quote name=“slavco” post=“46419” timestamp=“1387536944”]
As Kevlar note for this reasons to be fair you must reveal the hash of the secret before bet and after bets to reveal the secret. In this way users would know that secret wasn’t changed and can check fairness via published formula for bet calculation.
[/quote]Now I understand, revealing the secret is not enough to fully show provability…Because of this I have since updated both Heads/Tails & Lucky7 games so that the [i]sha256 hash[/i] of the SecretSalt currently in use is displayed clearly, obviously the un-hashed SecretSalt (the one used to calculate the bets) will be revealed at the end of each day as usual.
[url=http://www.ftcgames.eu/]http://www.ftcgames.eu/[/url]
-
[quote name=“UKMark” post=“46725” timestamp=“1387660070”]
[quote author=slavco link=topic=5931.msg46419#msg46419 date=1387536944]
As Kevlar note for this reasons to be fair you must reveal the hash of the secret before bet and after bets to reveal the secret. In this way users would know that secret wasn’t changed and can check fairness via published formula for bet calculation.
[/quote]Now I understand, revealing the secret is not enough to fully show provability…Because of this I have since updated both Heads/Tails & Lucky7 games so that the [i]sha256 hash[/i] of the SecretSalt currently in use is displayed clearly, obviously the un-hashed SecretSalt (the one used to calculate the bets) will be revealed at the end of each day as usual.
[url=http://www.ftcgames.eu/]http://www.ftcgames.eu/[/url]
[/quote]+1 dude. Nicely done.
-
[quote name=“Kevlar” post=“46756” timestamp=“1387669654”]
[quote author=UKMark link=topic=5931.msg46725#msg46725 date=1387660070]
[quote author=slavco link=topic=5931.msg46419#msg46419 date=1387536944]
As Kevlar note for this reasons to be fair you must reveal the hash of the secret before bet and after bets to reveal the secret. In this way users would know that secret wasn’t changed and can check fairness via published formula for bet calculation.
[/quote]Now I understand, revealing the secret is not enough to fully show provability…Because of this I have since updated both Heads/Tails & Lucky7 games so that the [i]sha256 hash[/i] of the SecretSalt currently in use is displayed clearly, obviously the un-hashed SecretSalt (the one used to calculate the bets) will be revealed at the end of each day as usual.
[url=http://www.ftcgames.eu/]http://www.ftcgames.eu/[/url]
[/quote]+1 dude. Nicely done.
[/quote]Its the only way Kevlar, had I realised sooner I would of implemented sooner, it was literally a 10min job (if that) to make the additions so no excuse not to offer this, it has certainly made me look at a large percentage of Crypto gambling sites currently out there in a totally different light. :-\
-
[quote name=“Kevlar” post=“46756” timestamp=“1387669654”]
[quote author=UKMark link=topic=5931.msg46725#msg46725 date=1387660070]
[quote author=slavco link=topic=5931.msg46419#msg46419 date=1387536944]
As Kevlar note for this reasons to be fair you must reveal the hash of the secret before bet and after bets to reveal the secret. In this way users would know that secret wasn’t changed and can check fairness via published formula for bet calculation.
[/quote]Now I understand, revealing the secret is not enough to fully show provability…Because of this I have since updated both Heads/Tails & Lucky7 games so that the [i]sha256 hash[/i] of the SecretSalt currently in use is displayed clearly, obviously the un-hashed SecretSalt (the one used to calculate the bets) will be revealed at the end of each day as usual.
[url=http://www.ftcgames.eu/]http://www.ftcgames.eu/[/url]
[/quote]+1 dude. Nicely done.
[/quote]+1 It was easy because you was honest all the time.
-
[quote name=“iawgoM” post=“43766” timestamp=“1386936729”]
Btw. there is already something similar here: [url=http://www.ftcgames.eu/]http://www.ftcgames.eu/[/url]Pozdrav! :)
[/quote]Thanks for that! Ive made a tonne in winnings on the lucky 7 :D
-
So I noticed the page is kinda refreshing constantly. That can’t be good for server load.
Have you considered using WebSockets for the updates, so the server can push when there’s a change? socket.io makes this really trivial to do.
-
[quote name=“FTClover” post=“47166” timestamp=“1387832960”]
[quote author=iawgoM link=topic=5931.msg43766#msg43766 date=1386936729]
Btw. there is already something similar here: [url=http://www.ftcgames.eu/]http://www.ftcgames.eu/[/url]Pozdrav! :)
[/quote]Thanks for that! Ive made a tonne in winnings on the lucky 7 :D
[/quote]:o But I still need to buy a turkey. :‘( :’( :'(
[quote author=Kevlar link=topic=5931.msg47176#msg47176 date=1387834036]
So I noticed the page is kinda refreshing constantly. That can’t be good for server load.Have you considered using WebSockets for the updates, so the server can push when there’s a change? socket.io makes this really trivial to do.
[/quote]As you can see this was my ‘roll your own’ approach :D
I looked at (and even started) something called comet? (I think that was the name) but I got lost as it seemed overly complex for what I wanted to achieve (quickly) and had other things I wanted to prioritize.If you recommend sockets.io I will certainly take a look in the new year and yes CPU is @ 102% most of the time :o
Thanks!
-
It’s good start to implement:
- some sleep in your while true php code
- split the game handlers into different processes
- execute async tasks in the background via exec
Refreshing the site on ~5 sec. it’s annoying only for the user for server is nothing on small load :)
-
[quote name=“UKMark” post=“47196” timestamp=“1387837794”]
[quote author=FTClover link=topic=5931.msg47166#msg47166 date=1387832960]
[quote author=iawgoM link=topic=5931.msg43766#msg43766 date=1386936729]
Btw. there is already something similar here: [url=http://www.ftcgames.eu/]http://www.ftcgames.eu/[/url]Pozdrav! :)
[/quote]Thanks for that! Ive made a tonne in winnings on the lucky 7 :D
[/quote]:o But I still need to buy a turkey. :‘( :’( :'(
[quote author=Kevlar link=topic=5931.msg47176#msg47176 date=1387834036]
So I noticed the page is kinda refreshing constantly. That can’t be good for server load.Have you considered using WebSockets for the updates, so the server can push when there’s a change? socket.io makes this really trivial to do.
[/quote]As you can see this was my ‘roll your own’ approach :D
I looked at (and even started) something called comet? (I think that was the name) but I got lost as it seemed overly complex for what I wanted to achieve (quickly) and had other things I wanted to prioritize.If you recommend sockets.io I will certainly take a look in the new year and yes CPU is @ 102% most of the time :o
Thanks!
[/quote]Comet is an umbrella term for HTTP Streaming technologies. I’m not sure which framework you were looking into, but sockets.io couldn’t be simpler:
Server side:
io.sockets.emit(“newBet”, “{betData:…}”);Client side:
io.on(“connect”, function(socket){
socket.on(“newBet”, function(newBet){
//insert page rendering code here.
};
});
io.connect(“http://serverUrl.com”) -
[quote name=“slavco” post=“47199” timestamp=“1387838347”]
It’s good start to implement:- some sleep in your while true php code
- split the game handlers into different processes
- execute async tasks in the background via exec
Refreshing the site on ~5 sec. it’s annoying only for the user for server is nothing on small load :)
[/quote]Yes sleep works well to stop the constant polling BUT when testing we found it would fail on multiple bets in a single TX. :( (system can currently handle 3 at the minute, 5 if spread accross both games)
I already run separate processes for each game, maybe I will split for each address also.
Will look into exec.I have thought about redesigning the whole game engines to use a DB and then maybe just poll once every 10 seconds, verify tx in db add/remove it - run game or quit etc…Not sure whether users would appreciate that sort of delay with a dice game though. Plus it would probably cause other issues too. :-\
-
[quote name=“Kevlar” post=“47200” timestamp=“1387838612”]
[quote author=UKMark link=topic=5931.msg47196#msg47196 date=1387837794]
[quote author=Kevlar link=topic=5931.msg47176#msg47176 date=1387834036]
So I noticed the page is kinda refreshing constantly. That can’t be good for server load.
Have you considered using WebSockets for the updates, so the server can push when there’s a change? socket.io makes this really trivial to do.
[/quote]As you can see this was my ‘roll your own’ approach :D
I looked at (and even started) something called comet? (I think that was the name) but I got lost as it seemed overly complex for what I wanted to achieve (quickly) and had other things I wanted to prioritize.If you recommend sockets.io I will certainly take a look in the new year and yes CPU is @ 102% most of the time :o
Thanks!
[/quote]Comet is an umbrella term for HTTP Streaming technologies. I’m not sure which framework you were looking into, but sockets.io couldn’t be simpler:
Server side:
io.sockets.emit(“newBet”, “{betData:…}”);Client side:
io.on(“connect”, function(socket){
socket.on(“newBet”, function(newBet){
//insert page rendering code here.
};
});
io.connect(“http://serverUrl.com”)
[/quote]Seems very simple, will look into it cheers.
-
There you go gringo :) https://github.com/Slavco/dicestart you can use it on raspberry pi as game calculator and have separate site for the play addresses anouncement ( shared hosting is too much for it ;) )
-
[quote name=“slavco” post=“47322” timestamp=“1387898026”]
There you go gringo :) https://github.com/Slavco/dicestart you can use it on raspberry pi as game calculator and have separate site for the play addresses anouncement ( shared hosting is too much for it ;) )
[/quote]Nice work gringo! 8)
-
[quote name=“slavco” post=“47322” timestamp=“1387898026”]
There you go gringo :) https://github.com/Slavco/dicestart you can use it on raspberry pi as game calculator and have separate site for the play addresses anouncement ( shared hosting is too much for it ;) )
[/quote]You write VERY good code. It’s clean, easy to read, and easy to understand. As one experienced coder to another who takes great pride in his art, the highest compliment I could pay you is that it’s indistinguishable from something I would write. Very nicely done.
I have but one criticism: Your heads/tails scripts have entirely too much in common (namely practically their entire contents), and should be refactored to a common include with only the part that changes in separate files, so both heads.php and tails.php would start with an include of common functions.
Other than that, it’s solid work and you should be proud. Keep it up!
-
[quote name=“Kevlar” post=“47354” timestamp=“1387909764”]
[quote author=slavco link=topic=5931.msg47322#msg47322 date=1387898026]
There you go gringo :) https://github.com/Slavco/dicestart you can use it on raspberry pi as game calculator and have separate site for the play addresses anouncement ( shared hosting is too much for it ;) )
[/quote]You write VERY good code. It’s clean, easy to read, and easy to understand. As one experienced coder to another who takes great pride in his art, the highest compliment I could pay you is that it’s indistinguishable from something I would write. Very nicely done.
I have but one criticism: Your heads/tails scripts have entirely too much in common (namely practically their entire contents), and should be refactored to a common include with only the part that changes in separate files, so both heads.php and tails.php would start with an include of common functions.
Other than that, it’s solid work and you should be proud. Keep it up!
[/quote]Thanks a lot Kevlar. I keep the code most simple only because I want everyone to understand it and ofc. used some tricks to make project easy to scale ( exec change to gearman/rabbitmq/something similar call ).
Good notice about duplicate code at head / tail script ( only senior could point at that from first code check ) but I have put it for reason also. I have put the code that only because to give example how anyone in easy way could create it’s own game and to find the logic how to add all the needed settings in the configuration file.
From Readme.md
[quote author=slavco]
How to create your game: If you can’t figure out from play/coinflip/head.php or tail.php manual soon
[/quote]Anyway good thing is that now I’ll have some free time and I’ll use it on Link project ( yup I’m updated and very big fan of the protocol ) :) . I know everything about it but haven’t try it and that’s why I was off discussion.
Also, thanks UKMark and wish you luck optimizing your project
-
[quote name=“slavco” post=“47374” timestamp=“1387916061”]
Also, thanks UKMark and wish you luck optimizing your project
[/quote]And you also:
[code]foreach ($ftc->listtransactions($key,1) as $transaction) {
if ($transaction[‘category’] == ‘receive’) {
$info[‘account’] = $transaction[‘account’];
$info[‘address’] = $transaction[‘address’];
$info[‘amount’] = $transaction[‘amount’];
$info[‘txid’] = $transaction[‘txid’];
$txdetails = $ftc->getrawtransaction($transaction[‘txid’],1);
$getvin = $txdetails[‘vin’][‘0’][‘txid’];
$sender = $txdetails[‘vin’][‘0’][‘vout’];
$txdetails = $ftc->getrawtransaction($getvin,1);
$address = $txdetails[‘vout’][$sender][‘scriptPubKey’][‘addresses’][‘0’];
}
}[/code] -
[quote name=“iawgoM” post=“43766” timestamp=“1386936729”]
Btw. there is already something similar here: [url=http://www.ftcgames.eu/]http://www.ftcgames.eu/[/url]Pozdrav! :)
[/quote]Who made ftcgames.eu?
-
[quote name=“FTClover” post=“47412” timestamp=“1387928132”]
[quote author=iawgoM link=topic=5931.msg43766#msg43766 date=1386936729]
Btw. there is already something similar here: [url=http://www.ftcgames.eu/]http://www.ftcgames.eu/[/url]Pozdrav! :)
[/quote]Who made ftcgames.eu?
[/quote]IawgoM made the front end, I made the back end.