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
public static void WriteVariableUint64(this BinaryWriter writer, UInt64 value) | |
{ | |
for (int i = 0; i < sizeof(UInt64); i++) | |
{ | |
byte writeByte = (byte)(value & 127); | |
value >>= 7; | |
if (value != 0) | |
writeByte |= 128; |
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
void write(entity e, BinaryWriter w) | |
{ | |
w.write(e.Template.Id); | |
foreach (Component c in e.Components) //e.Components is ordered in a specific way when it's constructed | |
{ | |
Assert(e.Template.Contains(c)); | |
c.Write(w); //Component writes out the data it needs | |
} | |
} |
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
--Tags:[ui, message box] | |
--Author:Martin Evans | |
function Initialize(owner, initialisationData) | |
Scene.LoadService("UI.UiService"); | |
local chatPipe = Pipes.GetPipe("General Chat", "String", true, true); | |
Ui.AddCallback("SendChatMessage", function(msg) | |
chatPipe.Send(msg); |
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
//Use an object as a set | |
var set = {} | |
//Create an object, give it some property | |
var item = {} | |
item.Foo = function() {}; | |
set[item] = item; | |
for (key in set} | |
{ |
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
for (stuff in things) | |
{ | |
var foo = stuff.thing; | |
stuff.bar = function() | |
{ | |
foo.bash(); //Probably not what you wanted! | |
}; | |
//because all life problems can be solved with a little less readability | |
function() |
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
int qlpShiftDivisor = 1 << qlpShift; | |
for (int i = order; i < sample.Length; i++) | |
{ | |
int sum = 0; | |
for (int j = 0; j < order; j++) | |
sum += predictorCoefficients[j] * sample[i - j - 1]; | |
sum /= qlpShiftDivisor; | |
sum += residuals[i - order]; | |
sample[i] = sum; | |
} |
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
// File: entry.c | |
// Version: 1.0.0 | |
// Author: Martin | |
// | |
int* screen = 0x8000; | |
int main() | |
{ | |
print("Hello"); |
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
function try(f, catch_f, ...) | |
local status, exception = pcall(f, unpack(arg)) | |
if not status then | |
catch_f(exception) | |
end | |
end | |
function foo(a, b) | |
return a < b; | |
end |
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
switch (thingy): | |
case typeof(foo): | |
stuff(); | |
break; | |
case typeof(bar): | |
stuff2(); | |
break; |
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 newRoutes = Stars | |
.SelectMany(sink => Stars | |
.Where(s => Distance(s, sink) < DISTANCE_THRESHOLD) //Eliminate stars too far away | |
.Where(s => s.Desirability < sink.Desirability) //Ignore routes along a negative profitability gradient | |
.Where(s => !IsThereARouteAlreadyBetween(sink, s)) //Don't reconsider routes which already exist | |
.Where(s => RandomFloat(0, 1) > SomeValue) //Arbitrarily eliminate half the routes | |
.Select(source => new { Source = source, Sink = sink }) | |
) | |
.Select(route => new { route.Source, route.Sink, Path = Pathfind(route.Source, route.Sink) } //We can precompute paths from every star to every other star, making this quite cheap | |
.Select(route => new { DeltaDesirability = route.Sink.Desirability - route.Source.Desirability, route.Source, route.Sink. route.Path }) |
OlderNewer