Created
February 11, 2016 17:06
-
-
Save betahikaru/7cc390b79229ca9f655e to your computer and use it in GitHub Desktop.
Mac版で0.282secのコード。http://gigazine.net/news/20160208-working-clicker/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var names = [ | |
'shikaku', | |
'affiliate', | |
'kabu', | |
'tochi', | |
'programming' | |
]; | |
function main() { | |
var i; | |
var currentJob = 1; | |
var workCount = 40;/* Record 0.282s when '40' */ | |
start(); | |
for (;;) { | |
for (i = 0;i < workCount;i++) { | |
work(); | |
} | |
if (cash > getPrice(currentJob)) { | |
purchase(currentJob); | |
currentJob = updateJob(currentJob); | |
} | |
if (cash > 100000000) { | |
print("Finish!"); | |
break; | |
} | |
} | |
} | |
function getPrice(index) { | |
var name = names[index]; | |
// print(index + "," + names[index] + "," + name + "," + prices[name]); | |
return prices[name]; | |
} | |
function updateJob(current) { | |
var minPrice = prices[0]; | |
var minJob = 0; | |
for (var i=1;i<=3;i++) { | |
if (minPrice > prices[i]) { | |
minPrice = prices[names[i]]; | |
minJob = i; | |
} | |
} | |
return minJob; | |
} | |
main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment