Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Quick Question - Multi Dimensional Arrays

Featured Replies

Sorry if this is the wrong place to put this I couldn't really find any other suitable area.  I tried posting this question on another site but it was ignored, probably because it's a dumb question to someone who knows what they're talking about.

 

Any ways, I've gotten stuck in my Intro level Java class, we are going over arrays and we just started on Multi dimensional arrays.

 

I fucking hate multi dimensional arrays.  

 

So my question is: Are they used very often in scripting?  I'm aware single-dimensional arrays are, but anything past that?

Not used particularly often in high-level scripts I reckon;

But its used on occasion in games and graphical/mathematical programs I suppose

You don't have to use them, if you don't want to.  I just don't understand how understanding multi-dimensional arrays would be harder than single-dimensional.

Multi dimmensional arrays are using for storing data in data.

 

For example:

Imagine if you wanted data for an x y coordinate in a game, you could have:

mapData[x][y]

 

So if we had:

int[][] multi = new int[][] {

{1,2,3,4}

{5,6,7,8}

{9,10,11,12}

};

 

row 0 or multi[0] = a single array of int[]{1,2,3,4}

and row 0 column 2 would equal 3, multi[0][2] = 3 ( int[]{1,2,3,4} )

So really multidimmensional arrays are an array of arrays, if that makes sense wink.png.

 

As for scripting, unless you plan on making collision path detection(finding a path to some position and consider collisions when determining the path) or something similar(which I think OSBot 2 will provide anyways), you most likely won't use it.

 

Enums would be more efficient in storing data for a particular script(for example, agility obstacles in an agility script, or potion creation data in a herblore script).

 

If I went wrong anywhere, please someone correct me ;P.

Edited by Allen

  • Author

Multi dimmensional arrays are using for storing data in data.

 

For example:

Imagine if you wanted data for an x y coordinate in a game, you could have:

mapData[x][y]

 

So if we had:

int[][] multi = new int[][] {

{1,2,3,4}

{5,6,7,8}

{9,10,11,12}

};

 

row 0 or multi[0] = a single array of int[]{1,2,3,4}

and row 0 column 2 would equal 3, multi[0][2] = 3 ( int[]{1,2,3,4} )

So really multidimmensional arrays are an array of arrays, if that makes sense wink.png.

 

As for scripting, unless you plan on making collision path detection(finding a path to some position and consider collisions when determining the path) or something similar(which I think OSBot 2 will provide anyways), you most likely won't use it.

 

Enums would be more efficient in storing data for a particular script(for example, agility obstacles in an agility script, or potion creation data in a herblore script).

 

If I went wrong anywhere, please someone correct me ;P.

Actually this helped a LOT.  I think my teacher was making it seem harder than it was, because explained like this it makes perfect sense.  

 

I really appreciate the help!

You don't have to use them, if you don't want to.  I just don't understand how understanding multi-dimensional arrays would be harder than single-dimensional.

I just got a little tripped up with the examples I was being shown in class.

In terms of scripting its unlikely that you have to use them.

If you're wanting to actually learn Java then multi-dimensional arrays are very useful and easy when you get the hang of them

Multi dimmensional arrays are using for storing data in data.

 

For example:

Imagine if you wanted data for an x y coordinate in a game, you could have:

mapData[x][y]

 

So if we had:

int[][] multi = new int[][] {

{1,2,3,4}

{5,6,7,8}

{9,10,11,12}

};

 

row 0 or multi[0] = a single array of int[]{1,2,3,4}

and row 0 column 2 would equal 3, multi[0][2] = 3 ( int[]{1,2,3,4} )

So really multidimmensional arrays are an array of arrays, if that makes sense wink.png.

 

As for scripting, unless you plan on making collision path detection(finding a path to some position and consider collisions when determining the path) or something similar(which I think OSBot 2 will provide anyways), you most likely won't use it.

 

Enums would be more efficient in storing data for a particular script(for example, agility obstacles in an agility script, or potion creation data in a herblore script).

 

If I went wrong anywhere, please someone correct me ;P.

 

It would really be better to store it like this

 

Assuming mapWidth and mapHeight are defined variables

 

int[][] mapStuff = new int[mapHeight][mapHeight] { ... init stuff ... } ;

 

Because remember, mapStuff is actually an array in itself. What you need to understand is that an array is always an array. The concept of multidimensional arrays is just that, a concept... In fact, an array can store any item, be it primitives, (int, double, etc) or objects (classes)

For a multidimensional array the item in question being stored is simply another array. To rephrase, you are storing an array... of arrays.

 

That brings me back to why you would store the height (y position) then width (x position). I feel it's best to show it as an example

 

Let's take this for example

int[][] mapStuff = new int[3][2] {

    new int[] { 0, 1 },

    new int[] { 3, 1},

    new int[] { 0, 3 }

}

 

It looks as a traditional coordinate system should... left to right is x, bottom to top is y. However, the array containing arrays is defined first To rephrase, mapStuff is an array of values containing x-coordinates. So, mapStuff[0] is an array of all x-coordinates when y is 0, and mapStuff[1] is an array of all x-coordinates when y is 1, and so on and so forth. So, to access an element, you would do mapStuff[y][x], rather than the traditional x and y.

 

I know it's a but weird to understand, so if you have any questions feel free to ask

Edited by fireswap

It would really be better to store it like this

Assuming mapWidth and mapHeight are defined variables

int[][] mapStuff = new int[mapHeight][mapHeight] { ... init stuff ... } ;

Because remember, mapStuff is actually an array in itself. What you need to understand is that an array is always an array. The concept of multidimensional arrays is just that, a concept... In fact, an array can store any item, be it primitives, (int, double, etc) or objects (classes)

For a multidimensional array the item in question being stored is simply another array. To rephrase, you are storing an array... of arrays.

That brings me back to why you would store the height (y position) then width (x position). I feel it's best to show it as an example

Let's take this for example

int[][] mapStuff = new int[3][2] {

new int[] { 0, 1 },

new int[] { 3, 1},

new int[] { 0, 3 }

}

It looks as a traditional coordinate system should... left to right is x, bottom to top is y. However, the array containing arrays is defined first To rephrase, mapStuff is an array of values containing x-coordinates. So, mapStuff[0] is an array of all x-coordinates when y is 0, and mapStuff[1] is an array of all x-coordinates when y is 1, and so on and so forth. So, to access an element, you would do mapStuff[y][x], rather than the traditional x and y.

I know it's a but weird to understand, so if you have any questions feel free to ask

"So really multidimmensional arrays are an array of arrays, if that makes sense ;)"

The map data multidimensional array was merely an example. I wasn't attempting to tutor him in how map data would be stored, rather how to utilize multidimensional arrays.

I see that I left out my "new int[]"'s in my mapData multi array so I see where you thought I went wrong. I'm typing all these replies on mobile so not exactly easy to type them out.

Edited by Allen

Guest
This topic is now closed to further replies.

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.