Marie Day

Greenhorn

Posts: 29

1

posted 2 years ago

I've written a game, and I'm trying to figure out if I'm using a data structure, or if not, exactly how one would describe the way I'm using data. Here's how it works:

I conceptualize the following set of 81 integers as being organized in a grid:

11 12 13 14 15 16 17 18 19

21 22 23 24 25 26 27 28 29

etc.

91 92 93 94 95 96 97 98 99

I flip a coin, and if it's heads, I can use any one column of numbers, for instance, 6, 16, 26, 36, 46, etc., or 1, 11, 21, etc. Which column I use is decided randomly, after the coin is flipped.

If it's tails, I can use one row: 91-99, etc., or 41-49, etc.

I'm wondering if the number grid is a data structure, because 1) I'm not loading anything into memory, and 2) the "data" is just natural numbers, as opposed to file names, phone numbers, product prices, etc. that are created and deliberately stored for retrieval.

It feels like a data structure, because 1) with each coin flip, the integers are structured in a certain way for that coin flip, and I can only access it in a certain way --- either a column of numbers or a row of numbers, and 2) although there are an infinite number of integers, I only have possible access to 81 of them.

So, if there's a name for this approach, I'd be grateful to know what it is. Maybe I actually am using a data structure.

I conceptualize the following set of 81 integers as being organized in a grid:

11 12 13 14 15 16 17 18 19

21 22 23 24 25 26 27 28 29

etc.

91 92 93 94 95 96 97 98 99

I flip a coin, and if it's heads, I can use any one column of numbers, for instance, 6, 16, 26, 36, 46, etc., or 1, 11, 21, etc. Which column I use is decided randomly, after the coin is flipped.

If it's tails, I can use one row: 91-99, etc., or 41-49, etc.

I'm wondering if the number grid is a data structure, because 1) I'm not loading anything into memory, and 2) the "data" is just natural numbers, as opposed to file names, phone numbers, product prices, etc. that are created and deliberately stored for retrieval.

It feels like a data structure, because 1) with each coin flip, the integers are structured in a certain way for that coin flip, and I can only access it in a certain way --- either a column of numbers or a row of numbers, and 2) although there are an infinite number of integers, I only have possible access to 81 of them.

So, if there's a name for this approach, I'd be grateful to know what it is. Maybe I actually am using a data structure.

Act boldly, and unforseen forces will come to your aid.

posted 2 years ago

- 1

Natural numbers can be stored in data structures, too. But as far as I can see you aren't storing any numbers anywhere, you're just returning numbers in response to a request.

To me that sounds like a "function". Think of the square-root function, for example: if I give the function 1936 then it returns 44. The function doesn't look in a table to do that, it does a calculation. Similarly there's a geometric interpretation of what the function does, you might think of it as running its finger along the graph of y = x squared until it gets to y = 1936 and then going down to the x-axis to find x = 36, but that isn't actually what it does. That graph isn't stored anywhere either.

To me that sounds like a "function". Think of the square-root function, for example: if I give the function 1936 then it returns 44. The function doesn't look in a table to do that, it does a calculation. Similarly there's a geometric interpretation of what the function does, you might think of it as running its finger along the graph of y = x squared until it gets to y = 1936 and then going down to the x-axis to find x = 36, but that isn't actually what it does. That graph isn't stored anywhere either.

Marie Day

Greenhorn

Posts: 29

1

posted 2 years ago

I have a different take on it anyway Your rows and columns, are they stored somewhere? My impression is they are. I would call it a matrix and as far as a good place to store it, a 2-D array would work nicely...

I like your tag line...

Marie Day wrote:Thank you, that makes a lot of sense.

I have a different take on it anyway Your rows and columns, are they stored somewhere? My impression is they are. I would call it a matrix and as far as a good place to store it, a 2-D array would work nicely...

I like your tag line...