This commit is contained in:
Shoofle 2013-09-12 01:41:58 -04:00
parent 0e7ebc5c1f
commit 679274de2f
7 changed files with 8894 additions and 17 deletions

View File

@ -4,7 +4,7 @@
{% block head %} {% block head %}
<meta charset="utf-8"> <meta charset="utf-8">
<title>{% block title %}Writings by Shoofle{% endblock %}</title> <title>{% block title %}Writings by Shoofle{% endblock %}</title>
<script src="/static/jquery.min.js" type="text/javascript"></script> <script src="/static/jquery-2.0.3.js" type="text/javascript"></script>
<link href="/static/bootstrap/css/bootstrap.css" rel="stylesheet" type="text/css"> <link href="/static/bootstrap/css/bootstrap.css" rel="stylesheet" type="text/css">
<link href="/static/bootstrap/css/bootstrap-responsive.css" rel="stylesheet" type="text/css"> <link href="/static/bootstrap/css/bootstrap-responsive.css" rel="stylesheet" type="text/css">
<link href="/static/shoofle.css" rel="stylesheet" type="text/css"> <link href="/static/shoofle.css" rel="stylesheet" type="text/css">

View File

@ -3,6 +3,7 @@
<script type="text/javascript" src="/static/flot/jquery.flot.js"></script> <script type="text/javascript" src="/static/flot/jquery.flot.js"></script>
<script type="text/javascript" src="/static/flot/jquery.flot.resize.js"></script> <script type="text/javascript" src="/static/flot/jquery.flot.resize.js"></script>
<script type="text/javascript" src="engine.js"></script> <script type="text/javascript" src="engine.js"></script>
<script type="text/javascript" src="supporting_math.js"></script>
<h1>Dynamic Systems in Games</h1> <h1>Dynamic Systems in Games</h1>
<p>Here, take a look at this simple game I coded up. Your task is to keep an engine's temperature as high as possible, to maximize power output, without dmaaging the engine. The threshhold for damage is at <span data-var="damage_threshhold">10</span> degrees, and the engine will stop burning and deignite if it goes under <span data-var="ignition_threshhold">2</span> degrees.</p> <p>Here, take a look at this simple game I coded up. Your task is to keep an engine's temperature as high as possible, to maximize power output, without dmaaging the engine. The threshhold for damage is at <span data-var="damage_threshhold">10</span> degrees, and the engine will stop burning and deignite if it goes under <span data-var="ignition_threshhold">2</span> degrees.</p>
<div class="row-fluid"> <div class="row-fluid">
@ -97,18 +98,17 @@
<div id="fuel-management-4" class="span4 offset4"> <div id="fuel-management-4" class="span4 offset4">
<script type="text/javascript"> <script type="text/javascript">
// describe a better potential graph // describe a better potential graph
var e4=engine($('#fuel-management-4'), function (sq) { var f, t, i;
if (sq.temperature.value < sq.ignition_threshhold.value) { var e4=alt_engine($('#fuel-management-4'), function (sq) {
return 0; f = sq.fuel_flow_rate.value;
} t = sq.temperature.value;
var y = 0; i = sq.ignition_threshhold.value;
y += 10*recenter(dgauss, return -5*(
10*sq.fuel_flow_rate.value + sq.ignition_threshhold.value, exp_decay(0.5, 0.3) (t) +
Math.sqrt(10*sq.fuel_flow_rate.value)) (sq.temperature.value); exp_growth(0.5, 10) (t) +
y -= 5*recenter(dgauss, Math.sqrt(1+60*f)*(make_bell(10*f+i, Math.sqrt(10*f+1)) (t)) +
10*sq.fuel_flow_rate.value + sq.ignition_threshhold.value, -1*Math.sqrt(1+10*f)*(make_bell(10*f+i, Math.sqrt(f+1)) (t))
Math.sqrt(2*sq.fuel_flow_rate.value)) (sq.temperature.value); );
return y;
}); });
</script> </script>
<div class="flow_rate"> <div class="flow_rate">

View File

@ -1,7 +1,14 @@
var cfg = {
xaxis: { min:0, max:15, tickSize: 3 },
yaxis: { min:-20, max:20, show: false },
series: { lines: { lineWidth: 4, }, points: { radius: 0.1, } },
colors: ['gray'],
};
function engine(element, reaction_rate_function) { function engine(element, reaction_rate_function) {
var e = {}; // the engine object! var e = {}; // the engine object!
e.container = $(element); e.container = $(element);
var q = {}; var q = {};
e.reaction_rate_function = reaction_rate_function;
e.quantities = q; e.quantities = q;
q.temperature = { q.temperature = {
"update": function () { "update": function () {
@ -25,7 +32,7 @@ function engine(element, reaction_rate_function) {
}, },
"value": 0, "value": 0,
"graph_data": { "graph_data": {
data: [[0,10],[0,0],[0,-10]], data: [[0,cfg.yaxis.max+2],[0,0],[0,cfg.yaxis.min-2]],
lines: {show: true, lineWidth: 1}, lines: {show: true, lineWidth: 1},
points: {show: true, radius: 3}, points: {show: true, radius: 3},
color: 'red', color: 'red',
@ -57,7 +64,7 @@ function engine(element, reaction_rate_function) {
q.ignition_threshhold = { q.ignition_threshhold = {
"update": function () {}, "update": function () {},
"out": function() { "out": function() {
this.graph_data.data = [[this.value, 10], [this.value, -10], [-this.value, -10], [-this.value, 10], [this.value, 10]]; this.graph_data.data = [[this.value, cfg.yaxis.max+2], [this.value, cfg.yaxis.min-2], [-this.value, cfg.yaxis.min-2], [-this.value, cfg.yaxis.max+2], [this.value, cfg.yaxis.max+2]];
}, },
"value": 2, "value": 2,
"graph_data": { "graph_data": {
@ -70,7 +77,7 @@ function engine(element, reaction_rate_function) {
q.damage_threshhold = { q.damage_threshhold = {
"update": function () {}, "update": function () {},
"out": function() { "out": function() {
this.graph_data.data = [[this.value, -10], [this.value, 10], [20*this.value, 10], [20*this.value, -10], [this.value, -10]]; this.graph_data.data = [[this.value, cfg.yaxis.min-2], [this.value, cfg.yaxis.max+2], [20*this.value, cfg.yaxis.max+2], [20*this.value, cfg.yaxis.min-2], [this.value, cfg.yaxis.min-2]];
}, },
"value": 10, "value": 10,
"graph_data": { "graph_data": {
@ -105,7 +112,7 @@ function engine(element, reaction_rate_function) {
e.graph_config = { e.graph_config = {
xaxis: { min:0, max:15, tickSize: 3 }, xaxis: { min:0, max:15, tickSize: 3 },
yaxis: { min:-8, max:8, show: false }, yaxis: { min:-20, max:20, show: false },
series: { lines: { lineWidth: 4, }, points: { radius: 0.1, } }, series: { lines: { lineWidth: 4, }, points: { radius: 0.1, } },
colors: ['gray'], colors: ['gray'],
}; };
@ -158,3 +165,15 @@ function engine(element, reaction_rate_function) {
}); });
return e; return e;
} }
function temperature_derivative (fn, step) {
return function (quantities) {
var next_input = $.extend({}, quantities);
next_input.temperature = {"value": quantities.temperature.value + step};
return (fn(next_input) - fn(quantities))/step;
};
};
var step = 0.005;
function alt_engine(element, reaction_rate_potential_function) {
return engine(element, temperature_derivative(reaction_rate_potential_function, step));
}

View File

@ -0,0 +1,20 @@
function make_gaussian(mean, standard_deviation) {
return function (x) {
return Math.exp(-Math.pow((x-mean)/standard_deviation, 2))/(standard_deviation * Math.sqrt(2*Math.PI));
};
}
function make_bell(mean, standard_deviation) {
return function (x) {
return Math.exp(-Math.pow((x-mean)/standard_deviation, 2));
};
}
function exp_decay(height, width) {
return function (x) {
return height*Math.exp(-x/width);
};
}
function exp_growth(height, width) {
return function (x) {
return height*Math.exp(x/width);
};
}

View File

@ -134,6 +134,7 @@
<span class="achievement normal">Beat the Elite Four</span> <span class="achievement normal">Beat the Elite Four</span>
</div> </div>
</li> </li>
<li>Prince of Persia (1989)</li>
<li>Prince of Persia: Sands of Time</li> <li>Prince of Persia: Sands of Time</li>
<li>Prince of Persia (2008)</li> <li>Prince of Persia (2008)</li>
<li>Super Smash Brothers: Melee <li>Super Smash Brothers: Melee
@ -167,6 +168,8 @@
<p class="thoughts">I think this might be my #1 pick for best Zelda game.</p> <p class="thoughts">I think this might be my #1 pick for best Zelda game.</p>
</li> </li>
<li>Legend of Zelda: Ocarina of Time</li> <li>Legend of Zelda: Ocarina of Time</li>
<li>Legend of Zelda: Majora's Mask</li>
<li>Legend of Zelda: The Wind Waker</li>
<li>Legend of Zelda: Twilight Princess</li> <li>Legend of Zelda: Twilight Princess</li>
<li>Super Mario 64</li> <li>Super Mario 64</li>
<li>Super Mario Sunshine</li> <li>Super Mario Sunshine</li>
@ -234,6 +237,11 @@
<span class="achievement normal">Discovered all the particles</span> <span class="achievement normal">Discovered all the particles</span>
</div> </div>
</li> </li>
<li>Guns of Icarus
<div class="accolades">
<span class="achievement bad">unfinished</span>
</div>
</li>
</ul> </ul>
</section> </section>
<section> <section>

8829
static/jquery-2.0.3.js vendored Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long