Skip to content

Instantly share code, notes, and snippets.

@alsotang
Created January 13, 2016 13:00
Show Gist options
  • Select an option

  • Save alsotang/d18096230d087e2ea742 to your computer and use it in GitHub Desktop.

Select an option

Save alsotang/d18096230d087e2ea742 to your computer and use it in GitHub Desktop.
var _ = require('lodash')
var base = 10000;
function win() {
return ~~(Math.random() * 10000 % 2)
}
function bet(num) {
var isWin = win()
if (isWin) {
return num * 0.9
} else {
return 0;
}
}
function bet2(num) {
base -= num
if (base <= 0) {
console.log('输完了')
process.exit(0)
}
console.log('下注:', num, ',余额:', base)
var winNum = bet(num)
if (!winNum) {
num *= 3
bet2(num)
} else {
base += num + winNum
}
}
_.range(1000).forEach(function () {
bet2(1)
})
console.log('base', base)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment