rendered paste body#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <time.h>
/*
David Sanda
with help from hammer123
p1 [#m]
udela cube.cfg s #m permutacema. Pro cube system na Endoru
perm 1{
ScrollRooms {1,5,6,100,25,8}
Perm {1,2,5,1... proste ta permutace}
}
*/
void perm(int p[217])//udela tu permutaci, nahodne
{
int a,b,c;
for(int i=1;i<=216;i++)p[i]=i;
for(int i=0;i<1000;i++)
{
a=1+random()%216;
b=1+random()%216;
c=p[a];
p[a]=p[b];
p[b]=c;
}
}
void rooms(int r[12])//udela ty mistnosti, min 5, max 10, r[0] je pocet
{
int a=5+random()%6;
r[0]=a;
for(int i=1;i<=a;i++)
r[i]=1+random()%216;
}
int main(int argc, char *argv[])
{
int count=1;
if(argc==2)count=atoi(argv[1]);
if(count > 1000)count=1000;
if(count <1)count=1;
srand( (unsigned)time( NULL ) );
int a[217],b[12],j;
FILE *f=fopen("cube.cfg","wt");
for(int i=0;i<count;i++)
{
rooms(b);
perm(a);
fprintf(f,"cubeperm %d\n",i);
fprintf(f,"{\n");
fprintf(f," ScrollRooms {");
for(j=0;j<b[0];j++)
fprintf(f,"%d, ",b[j]);
fprintf(f,"%d}\n",b[b[0]]);
fprintf(f," Perm {0,");
for(j=1;j<216;j++)
fprintf(f,"%d, ",a[j]);
fprintf(f,"%d}\n}\n\n",a[216]);
}
fclose(f);
}