Matricies, internal math and variable size
Hello! Obviously im new here, but my project is not.
I have been working on a "universal machine" and now i am in the final stages of its coding.
A universal machine requires a rule, and for that rule to run a lot.
http://en.wikipedia.org/wiki/Turing_machine
My rule is slightly confusing so i will explain it the best way i can.
What you will want to do is get a piece of graph paper (and a calculator). Start in the middle, top of the paper (while leaving a row) and place a 1 in the square. Now pretend that all the blanks are 0's, but dont put any anywhere. Now go strait down once and add, (0+1=1) then start back at the original 1 and add diagonally (down 1, over left 1) (0+1=1). Now do the same for the other side diagonal (down 1, over right 1), (0+1=1). Now go back to the top, and add along that diagonal into the blank square. Then go to the blank next to the one you just added (right 1), and look up 1, there should be a 1. Now look at the 2 diagonals, there should be another 1, and a blank. Add these 3 values (1+1+0=2) into that blank square. Now go to the blank square next to that (over right 1). Look vertically, there should be a 1, and another 1 above that. Then look at the 2 diagonals, there should be a 1 on upper left and upper right. Now add ALL those values (1+1+1+1=4). Then go to the next blank square, and the next one, and the next one...
http://www.bertolacciprod.com/rule.bmp
SO now the question is how do i do it?
I am fairly good at math, i get A's and B's in Algebra 2 and Geometry.
Here is the current Rule code (and some variables)
Code:
//Variables
int row; //Used for placing rows in matrix
int col; //col number
int next; //used as another portion to the rule
int pre = 0;
int row_size; //numbers of rows ( -- )
int col_size; //Number or colums ( | )
int matrix[6][11]; //Matrix, row_size x col_size
void rule()
{
//Here is where the Matrix addition code will be
matrix[0][0] = 1;
for( row = 1; row != row_size; row++ )
{
for(next = 0; next != 0; next--)
{
pre = (matrix[next][col]+pre);
}
for(next = 0; next != 0; next--)
{
for( col = 0; col != 0; col++)
pre = (matrix[next][col]
}
}
}
Any Ideas?
Thanks in advance!
Re: Matricies, internal math and variable size
Here is a better example, just 2 lines, animated
http://www.bertolacciprod.com/Rule_animated.gif
If you want to see more lines, just ask
Re: Matricies, internal math and variable size
Code:
for(next = 0; next != 0; next--)
{
pre = (matrix[next][col]+pre);
}
for(next = 0; next != 0; next--)
{
for( col = 0; col != 0; col++)
pre = (matrix[next][col]
}
You initialize loop start at zero and test if not zero, the loop will never get executed.
Re: Matricies, internal math and variable size
oh right haha, thats the thing, if the matrix data is trianglar and starts at the top middle. what size is it?
Im thinking that i could do like matrix width/2 to get middle, the 0 for top.
Re: Matricies, internal math and variable size