Skip to content

Instantly share code, notes, and snippets.

View proflong's full-sized avatar

Andrew Long proflong

  • Baton Rouge, LA
View GitHub Profile
# The file contains 2 methods for predicting power stone chance outcomes
# The first gives the expected value. This is the average number of crystals you can expect from any particular map clearing.
# Of course, you may end up getting above or below the average. To give a sense of this, I programmed a simulator (since calculating the joint variance is tough and most probably wouldn't know how to interpret the value).
# The simulator acts like it clears the same map setup a lot of time (default=10,000), and stores every outcome.
# This will give you a sense of how often you'll be very unlucky (e.g. clear your map and receive nothing) and very lucky (e.g. receive 10 crystals in one map clear).
# Note that results don't include the guarenteed stones from Dr. Terror.
# If you just want to know how many crystals to expect on Terror days add the following to your totals
# 2.2245 for tropical terror days and
# 2.3469 for volcano terror days
# The file contains 2 methods for predicting power stone chance outcomes
# The first gives the expected value. This is the average number of crystals you can expect from any particular map clearing.
# Of course, you may end up getting above or below the average. To give a sense of this, I programmed a simulator (since calculating the joint variance is tough and most probably wouldn't know how to interpret the value).
# The simulator acts like it clears the same map setup a lot of time (default=10,000), and stores every outcome.
# This will give you a sense of how often you'll be very unlucky (e.g. clear your map and receive nothing) and very lucky (e.g. receive 10 crystals in one map clear).
# Note that results don't include the guarenteed stones from Dr. Terror.
# If you just want to know how many crystals to expect on Terror days add the following to your totals
# 2.2245 for tropical terror days and
# 2.3469 for volcano terror days
function shuffle(array) {
for (var i = array.length - 1; i > 0; i--) {
var j = Math.floor(Math.random() * (i + 1));
var temp = array[i];
array[i] = array[j];
array[j] = temp;
}
return array;
}
<script src="https://code.jquery.com/jquery-1.10.1.min.js"></script>
<script type="text/javascript">
//this code assumes jQuery is implemented, though it would not be difficult to do this with straight javascript. .ready() assures the code runs after the submit button is added
$(document).ready(function () {
var studyName="dm102513";//replace this value with a unique, acceptable cookie name... no spaces and stick with alphanumerics and underscores
$("#submitButton").click(function(){
var exdate=new Date();
exdate.setDate(exdate.getDate() + 365);
document.cookie=studyName+"=1; expires="+exdate.toUTCString()+"; domain=mturkcontent.com; path=/";//When the user clicks the Submit button, it creates a cookie that you can read later as having already completed this survey
});
<h1>TITLE - change this</h1>
<p>INSTRUCTIONS - change this</p>
<div id="idcheck"><p>To see if you have completed this survey already, enter worker ID below and click 'Check ID'</p><p><textarea rows="1" cols="20" id="idinput"></textarea></p><div id="ok" onclick="check(false)" style="border: 3px solid black;cursor: hand; cursor: pointer; background-color:gray;color:white;width:70px;height:20px;text-align:center;margin-left:10px;">Check ID</div></div>
<p><textarea cols="80" name="comment" rows="3"></textarea></p>
<script type="text/javascript">
var url="URL GOES HERE";//The URL that the user will go to after they are checked (i.e. the survey url). Change this.
var workers=new Array("test1","test1","test3");//This is your white list. Change this. All IDs must be enclosed in quoation marks (single or double), and separated by a comma
@proflong
proflong / Mturk blacklist
Created September 30, 2013 22:05
Using a black list to exclude certain mturk workers from HITs (especially surveys).
<h1>TITLE - change this</h1>
<p>INSTRUCTIONS - change this</p>
<div id="idcheck">&nbsp;</div>
<p><textarea cols="80" name="comment" rows="3"></textarea></p>
<script type='text/javascript'>
var url="URL GOES HERE";//The URL that the user will go to after they are checked (i.e. the survey url). Change this.
var workers=new Array("test1","test1","test3");//This is your black list. Change this. All IDs must be enclosed in quoation marks (single or double), and separated by a comma