Author Topic: BitShares Dice Game Smart Contract  (Read 4044 times)

0 Members and 1 Guest are viewing this topic.

Offline GeraldShoug

  • Newbie
  • *
  • Posts: 9
    • View Profile
FFG forums just added a new forum for:  Star Wars: DestinyA collectible dice and card game of saga-spanning duels

Offline iamredbar


Offline iamredbar

Contract is running again.

Offline iamredbar

Game is currently down for maintenance.


Offline Victor118

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

Offline 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.

Offline iamredbar

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.

Offline sschiessl

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

Offline 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.

Offline iamredbar

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.
« Last Edit: February 02, 2019, 02:21:21 pm by iamredbar »

Offline 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.

Offline 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!

Offline iamredbar

Code: [Select]
#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.
« Last Edit: February 01, 2019, 02:14:14 pm by iamredbar »

Offline iamredbar

Code: [Select]
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?!  ;)