I'm trying to create a C program that emulates the Itunes app store game light paths.

Basically what it does is it creates a grid with numbers on the sides (top, bottom, left, right). All those numbers emit lights. Those number emitting light has to bounce off a mirror at an angle to hit another light perpendicular to it, depending on the angle. The goal of the game is to get all the numbers to shine light with their corresponding numbers using mirrors at angle / , 45 degrees, or how I've labeled it the program 1. Or using angle \ or 2.

A picture of the game.

http://img.wareseeker.com/software/i..._115200562.jpg

What I have so far is this. I'm having trouble generating numbers on the sides that correspond to the randomly generated mirrors on the top. Any ideas?

Code:

#include <stdio.h>
#include <ctype.h>
#include <time.h>
main()
{
int a[7][7], y, D, x, i, j, temp, count;
x=time(NULL);
srand(x);
for(i=0;i<8;i++)
{
for(j=0;j<8;j++)
{
a[i][j]=0;
}
}
count=0;
while(count<7)
{
i=(rand()%6)+1;
j=(rand()%6)+1;
a[i][j]=(rand()%2)+1;
count++;
}
for(j=1;j<7;j++)
{
a[0][j]=(rand()%12)+1;
}
while(i=0)
{
D=1;
for(j=1;j<9;j++)
{
a[i][j]=y;
while((i<9)&&(j<9))
{
switch(a[i][j])
{
case 0:
if(a[i][j]==0)
break;
case 1:
if(a[i][j]==13);
D=(D*2)%3;
break;
case 2:
if(a[i][j]==14);
D=(D*-2)%3;
break;
if(D==1)
i++;
if(D==-1)
i--;
if(D==2)
j++;
if(D==-2)
j--;
}
}
}
if((i==8)||(i==0)||(j==0)||(j==8))
y=a[i][j];
}
for(i=0;i<8;i++)
{
printf("\n\n");
{
for(j=0;j<8;j++)
printf("%d ", a[i][j]);
}
}
printf("\n\n");
}