Author Topic: General Programming Megathread - New OP  (Read 29778 times)

what do you mean by it being a sort of container?
Think of how Torque runs in TGE. Torque runs on top of TGE, so it can't modify anything it's not supposed to. TGE contains it. When you're using C++ code, you're interfacing directly with the engine code in a way where it's easy to mess up the engine or access things you're not supposed to. It gives you more powerful, but is much more dangerous.

so is torque 2d a viable option or should I go for canvas + js
because canvas is just a rendering engine and I don't know where to go from there

If you've got 200 bucks to blow then yeah, T2D is a viable option. You already know the language (I think) and you can get help from us for stuff you don't know. I can help you with canvas, because it's really not that hard. Really, rendering is the hardest part.

I like the idea of using a visual IDE.
So is Torquescript just C++ with Torque functions, like GML?

No... TorqueScript is torquescript.
The Torque Game Engine is made in C++.

No... TorqueScript is torquescript.
The Torque Game Engine is made in C++.
oooo00000oohhhhhhh.
I see.
So I'm not really working with C++, in a sense.

Loading a large part of the Alicebot AIML set onto the modified Ruby AIML interpreter. I'm hoping there won't be any parse errors which can cause the program to crash since there are no rescues.

two bigass problems with titanium
1: super-loving-long compile time for one dinkyass application - we're talking 5-10 minutes for a one-screen application! probably just my computer, but it's still a problem
2: it's 8 loving megabytes big! fortunately it doesn't get much bigger nor much smaller than that, but it's still big!
3: i can't get this goddamned thing down. node.js just /worked!/ this crap is giving me errors all over the place. can you believe console isn't an object, despite being in the documentation? I couldn't either!
I'm thinking learning java might be easier than this.

I'm going to port this recursive hash calculation algorithm over to torquescript and see what kinds of speed I get out of it. Who wants to place bets on an average hashes per second in comparison to the other languages?
results from other languages:
Node.js: 30000
php: 8000 +/- 500
Code: (node.js) [Select]
var crypto = require('crypto');
var HASH = "d5ec41e0a1a7771771037f27ae222827f36ef6d4";
var HASH_ALGO = 'sha1';
var PASSWORD_MAX_LENGTH = '8'
var charset = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j",
  "k", "l", "m", "n", "o", "p", "q", "r", "s", "t",
  "u", "v", "w", "x", "y", "z"];

var charset_length = charset.length;

var hashcount = 0;
var hashtotal = 0;
var ticks = 0;
var logtime = new Date().getSeconds();

function hash(algo, str) {
hashcount++;
hashtotal++;

if(logtime < new Date().getSeconds()) {
logtime = new Date().getSeconds();
if(logtime == 59) { logtime = 0; }
if(logtime != 0) {
ticks++;
console.log(hashcount + "\t" + hashtotal + "\t" + logtime + "\t" + ticks);
hashcount = 0;
}
}

return crypto.createHash(algo).update(str).digest('hex');
}
 
function check(password) {
    if (hash(HASH_ALGO, password) == HASH) {
        console.log('FOUND MATCH, password: ' + password);
        process.exit();
    }
}
 
 
function recurse(width, position, base_string) {
    for (var i = 0; i < charset_length; i++) {
        if (position < width - 1) {
            recurse(width, position + 1, base_string + charset[i]);
        }
        check(base_string + charset[i]);
    }
}

console.log("target hash: " + HASH);
recurse(PASSWORD_MAX_LENGTH, 0, '');
 
console.log("Execution complete, no password found");
I'll also be slightly modifying it so it doesn't kill the main thread. forget that stuff, i'd actually have to think
turns out it was a stuffty benchmark cause i'm using c++ functions :(
torquescript came out at 35k though
Code: (torquescript) [Select]
$HASH = "d5ec41e0a1a7771771037f27ae222827f36ef6d4";

$PASSWORD_MAX_LENGTH = "8";
$charset = "abcdefghijklmnopqrstuvwxyz";

$charset_length = strLen($charset);

$hashcount = 0;
$hashtotal = 0;
$ticks = 0;
$logtime = getRealTime();

function hash(%str) {
$hashcount++;
$hashtotal++;

if($logtime < getRealTime() - 1000) {
$logtime = getRealTime();
$ticks++;
echo($hashcount @ "\t" @ $hashtotal @ "\t" @ $logtime @ "\t" @ $ticks);
$hashcount = 0;
}

return sha1(%str);
}

function recurse(%width, %position, %base_string) {
for (%i = 0; %i < $charset_length; %i++) {
if (%position < %width - 1) {
recurse(%width, %position + 1, %base_string @ getSubStr($charset, %i, 1));
}
hash(%base_string @ getSubStr($charset, %i, 1));
}
}

echo("target hash: " @ $HASH);
recurse($PASSWORD_MAX_LENGTH, 0, "");
 
echo("Execution complete, no password found");

SL4A does support networking if you use the php module and stuff
this is good
« Last Edit: November 23, 2012, 08:33:32 PM by Lugnut »

guys I need to figure out who the winner is in this setup:

water, fire, grass, earth
where the preceding element beats the next one
water beats fire, earth beats water, etc

i found this: winner = (3 + player1 - player2) % 3; for rock-paper-scissors, but I'm not positive it'll translate cleanly to 4 items...
I'm trying it now.

yep it always returns 3.
any help?

trying this:
Code: (php) [Select]
$winrow = array("Water God", "Fire God", "Forest God", "Earth God");
if($b == $a + 1 || ($b == 0 && $a == 3)){
return true;
}
else {
return false;
}
« Last Edit: November 24, 2012, 12:46:32 AM by Lugnut »

What do the asterisks mean?

What do the asterisks mean?
i see no asterisks on the entire page what are you referring too

yay torque2d dropped in price
128 bucks now? pfft, so down
gotta get back into torquescript. lately I've been swept up into python and ruby

i see no asterisks on the entire page what are you referring too

The OP

The OP
actually this
I saw it but never asked for some reason

those are Trinick's favorites i think

Brian stole his list

Yeah, those are my favorites. I don't know why Brian didn't remove them, but whatever.

Also, full time linux now. This means time to get my dev face on.

You probably can compile it via the terminal if you know how, but it's also probably a huge loving pain hence Eclipse handling it being the recommended option.
maven/sbt/gradle/ant/gant/make?