From f3b535afb23e9357f1683a324f4a53af9cb53c12 Mon Sep 17 00:00:00 2001 From: Shoofle Munroe Date: Tue, 3 Sep 2013 14:27:29 -0400 Subject: [PATCH] engine.js improved, dynamic-systems-in-games improving. --- .../dynamic_systems_in_games.article.html | 38 +++++++++++++++---- articles/dynamic_systems_in_games/engine.js | 12 +++--- 2 files changed, 36 insertions(+), 14 deletions(-) diff --git a/articles/dynamic_systems_in_games.article.html b/articles/dynamic_systems_in_games.article.html index d348f65..bd94237 100644 --- a/articles/dynamic_systems_in_games.article.html +++ b/articles/dynamic_systems_in_games.article.html @@ -16,21 +16,43 @@ } engine($('#fuel-management-1'), heyo); -
+
- 0 degrees - No ignition - DAMAGE! -
+ 0 degrees + No ignition + DAMAGE! +

It's interesting! Or maybe it's not. I threw this together trying to think of what an interesting way for an engine to work might be. The fundamental relationship here is:

\[\frac{\partial T}{\partial t} = c_F T F - c_T (T - T_0)\]

That is, at any given moment, the temperature is changing (\(\frac{\partial T}{\partial t}\)) by increasing proportional to the temperature times the fuel flow rate (\(c_F T F\)) and decreasing proportional to the difference between the chamber temperature and the ambient temperature (\(c_T (T - T_0)\)). The deignition isn't described in this formula, but it's pretty simple - the \(c_F T F\) factor becomes zero when the temperature is less than 2 degrees.

As it turns out, (surprise of surprises!) that description in a formula is pretty useless for actually understanding how this feels. The key was to look at it as a function of the temperature. See, the player changes \(F\), and I want to get a feel for how the temperature's going to change. So I made a graph with respect to \(T\) where the slope is given by \(\frac{\partial T}{\partial t}\). Note that this is not just going to undo the partial derivative. In this graph, we're integrating against \(T\), not \(t\). Roughly, this graph should be thought of as one where the temperature would slide down hills. Anyway.

-

You can feel free to slide around the fuel flow rate slider to play with this. When the graph is flat, that temperature is stable. (Remember: temperature is on the x-axis.)

-

Well. This is terrible. There aren't any stable points! - +

You can feel free to slide around the fuel flow rate slider to play with this. When the graph is flat, that temperature is stable. (Remember: temperature is on the x-axis.)

+

Well. This is terrible. There aren't any stable points! +

+
+ +
+ + +
+ + 0 degrees + No ignition + DAMAGE! +
+
+
+ diff --git a/articles/dynamic_systems_in_games/engine.js b/articles/dynamic_systems_in_games/engine.js index e26f9d0..005e7b6 100644 --- a/articles/dynamic_systems_in_games/engine.js +++ b/articles/dynamic_systems_in_games/engine.js @@ -8,11 +8,11 @@ function engine(element, reaction_rate_function) { if (this.value < 0) { this.value = 0; } }, "out": function () { - container.find('#temp-out').html(this.value.toFixed(2)); - if (this.value > damage_threshhold) { container.find('#damage').show();} - else { container.find('#damage').hide(); } - if (this.value < q.ignition_threshhold.value) { container.find('#noignition').show(); } - else { container.find('#noignition').hide(); } + container.find('.temp-out').html(this.value.toFixed(2)); + if (this.value > damage_threshhold) { container.find('.damage').show();} + else { container.find('.damage').hide(); } + if (this.value < q.ignition_threshhold.value) { container.find('.noignition').show(); } + else { container.find('.noignition').hide(); } }, "value": 0, }; @@ -55,7 +55,7 @@ function engine(element, reaction_rate_function) { container.find('[name=ignition]').on('click', function() { q.temperature.value += ignition_boost; }); a = setInterval(jQuery.each, timestep, q, function(name, x) { x.update(); }); b = setInterval(jQuery.each, timestep, q, function(name, x) { x.out(); }); - graph = container.find('#potential_plot'); + graph = container.find('.potential_plot'); graph_plot = $.plot(graph, [[]], graph_config); }); return {