BitShares Dice Game Smart Contract

Started by iamredbar, February 01, 2019, 03:43:47 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

GeraldShoug

FFG forums just added a new forum for:  Star Wars: DestinyA collectible dice and card game of saga-spanning duels

iamredbar


iamredbar


iamredbar

Game is currently down for maintenance.


Victor118

Interesting
May be it's a good idea to think about to implement a game of dice in bitshares core?

iamredbar

I now have the contract running with an autoreboot if it crashes. The contract should be up all the time! When I take it down, I will post it here.

iamredbar

Quote from: sschiessl on February 03, 2019, 08:46:20 AM
You can add the expected transfer fee as deduction to payout, no reason to stop due to that

I know I could, but I want to keep the fees as low as possible to incentivize. Making the contract address a LTM is a good place to start.

sschiessl

You can add the expected transfer fee as deduction to payout, no reason to stop due to that

iamredbar

Alright, I am turning it back online. I added type checking when parsing the memo, and it now also checks for correct guessing amount.

I will update the Github when I have a chance.

iamredbar

#11
It looks like one or two people have tried! (thank you DL and "lzr") Also looks like it went down while I was sleeping. It is gonna stay down for a bit! I'll post here when its back up.

iamredbar

Here is the Github repo for it: https://github.com/iamredbar/bts-dice-game

Like I said, its still super sloppy and needs improvements.

iamredbar

Also, if the new fee schedule is approved, I will not be able to afford the fees for this game. So hopefully at least one or two people try it before it changes!

iamredbar

#8
#get head block number, better than irreversible
  blockNum = blockchain.get_current_block_num()
  print('Block number: {}'.format(blockNum))

  userGuess = userRoll
  seed(blockNum * (userGuess + 1))
 
  diceRatios = btsDiceRatios
  winRatio = diceRatios.get_ratio(userGuess)

  value = randint(1, 100)
  correctGuess = value < int(userGuess)


If everyone would prefer, I can post the code to github but I am embarrassed by it right now, it is very sloppy. The random number logic is above. The only thing that the rest of the code does is interface with the chain.

I would gladly have someone audit the code if they want.

iamredbar

Quote from: sschiessl on February 01, 2019, 10:13:00 AM

If profit(this_month) < limited_only_by_my_greed
  return user_guess + random
else
  return random


;) jk, no clue. Of course important question!

Haha! How did you get my code?!  ;)