LoginLogin
Nintendo shutting down 3DS + Wii U online services, see our post

Mock Library

Root / Submissions / [.]

MZ952Created:
Version:1.0Size:
This library contains a series of functions that allow you to manipulate strings in such a way that they act as multidimensional arrays. There's a few benefits with using this data structure.
  • Elements in a mock can be both integer or string simultaneously.
  • A mock array can be expanded to any nth dimension.
  • Unlike arrays, mocks can be detected and anticipated. This is useful for passing arrays smoothly in and out of functions.
  • Mock arrays can be 'jagged,' and contain various dimensions simultaneously. For example, GET(A$,0) may be a single element, while GET(A$,1) may be an entire 2D array.
However, there's also a few downsides.
  • The data structure relies heavily on string manipulation, possibly making it difficult to repeatedly use frame by frame.
  • Manipulating higher dimensions can be tricky (to the mind), especially since a mock array can have multiple dimensions simultaneously.
  • The limit for an element that is an integer is 2^16-1, meaning it can't store the whole spectrum of integers.
  • It doesn't store floats (yet).
  • If you're not careful, you could accidentally pass the wrong data type. For example, you may accidentally assign a string variable an integer value, which would cause an error.
If you try it out, let me know what you think, and what features you'd like to see! I'd be delighted to see what kinds of functionality I can add to this thing. The purpose of this was to have a way to manipulate higher dimensional arrays with a good deal of flexibility, which SB doesn't offer. As this is version 1.0, there isn't a great deal of flexibility, but there is flexibility nonetheless. In future versions, I'd like to include precision adjustments to multidimensional arrays.

Instructions:

Instructions and syntax all located and thoroughly described in the program.

So, I have done some benchmarks for this library in the O3DS, and here are the results: Creating 2D arrays: 64x64 - 81 ms 128x128 - 330 ms 256x256 - 1658 ms Creating 1D arrays: 64 - 1 ms 128 - 3 ms 256 - 4 ms Filling 2D arrays: 64x64 - 4197 ms 128x128 - 29790 ms 256x256 - 883 ms (what!) Filling 1D arrays: 64 - 63 ms 128 - 229 ms 256 - 845 ms Every operation was made with the provided functions and with LIM() returning 65536

Replying to:hakke
So, I have done some benchmarks for this library in the O3DS, and here are the results: Creating 2D arrays: 64x64 - 81 ms 128x128 - 330 ms 256x256 - 1658 ms Creating 1D arrays: 64 - 1 ms 128 - 3 ms 256 - 4 ms Filling 2D arrays: 64x64 - 4197 ms 128x128 - 29790 ms 256x256 - 883 ms (what!) Filling 1D arrays: 64 - 63 ms 128 - 229 ms 256 - 845 ms Every operation was made with the provided functions and with LIM() returning 65536
You must have an O3DS, which makes for a good perspective because I didn't test it on the O3DS. Here's what I got on the N3DS: Dimensioning 1D arrays: Length 1-512 — 1-2 ms Length 512-1024 — 2 ms Length 1024-2048 — 8 Ms Dimensioning 2D arrays: Length 64, 64 — 21 ms Length 128, 128 — 84 ms Length 256, 256 — 387 Dimensioning 3D arrays: Length 64, 64, 64 — 22 Ms Length 128,128,128 — 84 ms Length 256, 256, 256 — 389 ms Dimensioning 4D arrays: Length 64 ... 64 — 41 ms Length 128 ... 128 — 161 ms Length 256 ... 256 — 781 ms Dimensioning 8D arrays (one, two, skip a few): Length 64 ... 64 — 83 ms Length 128 ... 128 — 331 ms Length 256 ... 256 — 1551 ms Dimensioning the array is one of the most effortless tasks in this library (just after checking the length), so these results should say a lot about the runtime consumption for the rest of the functions. I mean, like I said, this probably isn't something you would want to call every frame inside a program. It's bent more towards storing complex data in complex (costly) ways. It's mass string manipulation for chrissake lol. I'm glad to see you put the effort into timing these functions. Hadn't quite thought of it myself, I just knew it could be slow. I think that 883 ms one might be an error in the testing. Edit: I would just like to note that the only reason why Dimensioning the 8D array is so quick is because all elements share the same value. The only thing the Dimensioning function has to do is set up the metadata for referencing any 256^8 elements. If you were to individualize each element, you would quickly run out of memory.

Replying to:hakke
So, I have done some benchmarks for this library in the O3DS, and here are the results: Creating 2D arrays: 64x64 - 81 ms 128x128 - 330 ms 256x256 - 1658 ms Creating 1D arrays: 64 - 1 ms 128 - 3 ms 256 - 4 ms Filling 2D arrays: 64x64 - 4197 ms 128x128 - 29790 ms 256x256 - 883 ms (what!) Filling 1D arrays: 64 - 63 ms 128 - 229 ms 256 - 845 ms Every operation was made with the provided functions and with LIM() returning 65536
I have tested the line S$ = ONLY2D(S$,"") with S$ being a 256x256 2D mock and giving similar results to 883 ms