Hello Cemetech user.

I got into programming a Sudoku game and wanted to use a matrix. I have already looked in the Docummentation but have found nothing really. I only saw that you can create a matrix with the OpenVar( function. I don't know how to work them, though. If there are matrixes in Ice, I would ask how to use them and if not, if there is another way. Sorry if my English isn't perfect.

Have a nice day. Smile
Though I suggest learning how to use OpenVar(), there are some alternatives. Chiefly, you can simply allocate a segment of memory that would fit the size of matrix you want (for instance, a 9x9 matrix of one byte per element required 81 bytes) and pretend that your one dimensional memory is actually an array. You can store your Sudoku values at the pointer POINTER+remainder(X,9)+9*Y where X and Y are your coordinates on the sudoku, from 0 to 8.
Okay, thanks for your answer. Smile I just don't quite understand what you mean by one dimensional memory.
Yan-Nick wrote:
Okay, thanks for your answer. Smile I just don't quite understand what you mean by one dimensional memory.

How you want to access your data (2D):

[{10, 10, 10},
{10, 10, 10},
{10, 10, 10}]

How data is stored in memory (1D):

{10,10,10,10,10,10,10,10,10}

You have to deal with the fact that its just a series of bytes by yourself because ICE won't do it for you. The formula Sam provided allows you to convert from X-Y coordinates which are easy to work with to an index in a 1D "array".
Is 10 just an example?
My big problem is to create, display and edit the Sudoku.
Please try to avoid double-posting.
Those are some pretty significant problems for a sudoku program Laughing
You should take a look at the file I/O section of the ICE Commands page
As stated above, to create the sudoku "grid", you will want to allocate 81 bytes (1 byte per cell since your values won't exceed 255) with the Open command. Then you can write the values with the Write command and the formula above. You can display it on the screen by reading with the Read command... You shouldn't really have any issues if you take 5 minutes to read through a bit of documentation.
No need to get into file I/O for this. Just use one of the lists L₁-L₆. So you'd access cell (X, Y) (0-indexed, so each ranges from 0-8) with something like {Y*9+X+L₁}.
mr womp womp wrote:
Please try to avoid double-posting.

Ok sorry Sad
mr womp womp wrote:
Those are some pretty significant problems for a sudoku program Laughing
You should take a look at the file I/O section of the ICE Commands page
As stated above, to create the sudoku "grid", you will want to allocate 81 bytes (1 byte per cell since your values won't exceed 255) with the Open command. Then you can write the values with the Write command and the formula above. You can display it on the screen by reading with the Read command... You shouldn't really have any issues if you take 5 minutes to read through a bit of documentation.

What should I assign 81 bytes to and how? I often looked at the documentation that was included in the download of ICE, but I didn't really find anything.
Sorry for the many questions, I'm not so familiar with the file I/O commands yet.
Runer112 wrote:
No need to get into file I/O for this. Just use one of the lists L₁-L₆. So you'd access cell (X, Y) (0-indexed, so each ranges from 0-Cool with something like {Y*9+X+L₁}.

Do you think I should make two lists? One for X and one for Y?
Yan-Nick wrote:
Runer112 wrote:
No need to get into file I/O for this. Just use one of the lists L₁-L₆. So you'd access cell (X, Y) (0-indexed, so each ranges from 0-Cool with something like {Y*9+X+L₁}.

Do you think I should make two lists? One for X and one for Y?

No. The list is emulating a matrix. You'd only need one matrix to represent the board state, so you only need one list.
Runer112 wrote:
Yan-Nick wrote:
Runer112 wrote:
No need to get into file I/O for this. Just use one of the lists L₁-L₆. So you'd access cell (X, Y) (0-indexed, so each ranges from 0-Cool with something like {Y*9+X+L₁}.

Do you think I should make two lists? One for X and one for Y?

No. The list is emulating a matrix. You'd only need one matrix to represent the board state, so you only need one list.

Ok,thanks Smile
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement