YOUR IDEAS ARE WORTH MONEY! : "bulk processing" using unconventional methods?

Started by Monsieur OUXX, Fri 09/07/2010 17:12:36

Previous topic - Next topic

Monsieur OUXX

Hi,
OK, I lied, there's no money involved. But there's eternal fame for you in there.

The idea is simple :
1/ What kind of processing are we talking about?
When you code a script, you need to process some data.
Basic, common tasks include :
- calculations (e.g. multiply 2 variables)
- swap values (e.g. swap the values of var1 and var2)
- binary processing (e.g. var3 = var1 XOR var2)
etc.
The examples are countless.

2/ What do I call "bulk processing?
It's when you have to perform any basic task many times in a row, and you know pretty much everything about the countext
All you want is to have the script perform the actual calculation, repeatedly...
E.g. : Perform 1,000,000 XOR operations in order to encrypt some data.

What do I call "unconventional methods"?
In order to perform an XOR operation, you'd normally do:  var3 = var2 ^ var1;
If you have to do it 1,000,000 times, then you'll write the instruction above in a loop.

Now, imagine you'd proceed completely differently : You'd create 2 DynamicSprites, each with dimensions 1,000,000px x 1px. The first sprite contains all the "var1" values, and the second sprite would contain all the "var2" values.
Then you'd blit sprite 2 onto sprite 1 with an XOR operator. It's not possible in AGS, but it is in many drawing APIs, that's why I'm taking this example. And BOOM, you'd have a massive XOR, performed hundreds (thousands) of times faster than if you had done it with the script.

So, now, the question:  Can you think of any similar idea to perfom massive processing of information (inside of AGS) by cleverly using other AGS functions that were apparently not designed for that in the first place ???

the craziest the idea, the better!

I'm very serious here!!!

[EDIT after Wyz's post] : Of course, I'm always talking in the context of AGS: the goal is to replace any type of slow AGS' script instruction by another (set of) AGS instructions.

Also, I'm not talking about code optimization (like "avoid calling too many procedures, etc."). Once again, I'm strictly talking about replacing some code with a function that was designed for something completely different.
 

Wyz

It really depends on what you're trying to do. :)
But two methods that I would like to mention: Matrix operations (like intel's MMX or any GPU) when you need to do the same operations on a large bulk of data and Fourier transforms when you're dealing with a large bulk of data that has patterns in it.

But still, I have no idea which way you're heading. ;)

edit:
Ow right, I'll have another think about it :)
Life is like an adventure without the pixel hunts.

Monsieur OUXX

Quote from: Wyz on Fri 09/07/2010 17:24:02
2 methods that I would like to mention: (...)

See my edit. Of course, I'm asking in the context of AGS!  :)
 

Wyz

Ok, thought about it again, but I couldn't really come up with anything except for the one you already know about: using midi or mp3 play routines for timing.

Or maybe a little hack I use often; Using the fact that a boolean expression will result in integers 1 or 0.
Code: ags

bool button_state;

oButton.Graphic = 42 + button_state;

// or even dirtier:
oButton.Graphic = 42 + (oButton.Graphic == 42)
Life is like an adventure without the pixel hunts.

Monsieur OUXX

Quote from: Wyz on Sun 11/07/2010 01:22:18
Using midi/mp3 play routines as accurate timers.

Quote from: Wyz on Sun 11/07/2010 01:22:18
Using booleans as  integers (1 or 0) for fast "button state<-->button graphic" conversion.


Interesting.
Come one guys, use your brains!!! I'm hungry now.
 

Kweepa

I've been using dynamic sprites for collision detection in a shoot-em-up.
I draw the ships on a dynamic sprite, in a single colour that represents the index of the ship.
Then to test for a bullet collision, I just check what colour is at the bullet's x/y and use that as a lookup to the enemy/player.
For player/enemy collision, I just scan over the pixels where the player is and see if any match an enemy ship colour.

(I did it at half scale to speed things up a bit for the player/enemy collisions.)

If you didn't care about indices, you could use the colour for other effects such as the surface normal in (for example) a pinball game - with 15 bits of precision.
Still waiting for Purity of the Surf II

Monsieur OUXX

Quote from: SteveMcCrea on Tue 13/07/2010 01:31:03
I've been using dynamic sprites for collision detection in a shoot-em-up.

for that I intend to use binary trees or octrees, I believe it might be faster (to be tested - now I can't trrust anything after the brilliant demonstration you made with you antialising algorithm  :()

Quote from: SteveMcCrea on Tue 13/07/2010 01:31:03
use the colour for other effects such as the surface normal in (for example) a pinball game

That's clever! I actually sometimes wondered how they were doing - never thought of that.




MORE IDEAS! MORE IDEAS!
 

SMF spam blocked by CleanTalk