program juegovida; procedure menuinicial (var menu:integer); begin writeln('MENU:'); writeln('1 Generar mundo aleatorio'); writeln('2 Ejecucion'); writeln('3 Cargar Estado inicial'); writeln('4 Salir'); writeln ('para comenzar a jugar elige una opcion'); readln(menu); end; procedure reglasdeljuego (var x,a,b,c:integer;var porcentaje:real); var reglas: integer; begin writeln('dame las dimensiones del mundo(lado): '); readln(x); writeln(' dame un porcentaje de celulas vivas'); readln(porcentaje); write('si qieres cambiar las reglas del juego pulsa 1,'); writeln('si no pulsa otro numero'); readln (reglas); if (reglas=1) then begin repeat writeln ('dame un valor para la a'); readln(a); writeln ('dame un valor para la b'); readln(b); writeln ('dame un valor para la c'); readln(c); until (((a+b)+c)=8) and (b=porcentaje) or(celda[i][j]=0) then write('| ') else write('| @'); end; write('|'); writeln; end; for i:=1 to x do write('+--'); write('+'); for i:=1 to x do for j:=1 to x do if(celda[i][j]>=porcentaje)or(celda[i][j]=0) then celda[i][j]:=0 else celda[i][j]:=1; readln; writeln ('Ahora elige otra opcion del menu'); readln; menuinicial (menu); end; end; {---------------------------------------------------------} {--------MODIFICAR EL MUNDO DEPENDIENDO DEL ESTADO INICIAL-------------- {------------------COMIENZA EL BUCLE PARA EL TABLERO------------------------} if menu=2 then begin writeln('Has elejido ejecutar el juego'); writeln ('Elije cuantas veces quieres que se ejecute el juego'); readln(fin); for i:=1 to x do for j:=1 to x do suma[i][j]:=0; repeat begin for i:=2 to x-1 do for j:=2 to x-1 do begin suma[i][j]:=celda[i-1][j-1]+celda[i][j-1]+celda[i+1][j-1] +celda[i-1][j]+celda[i+1][j]+celda[i-1][j+1]+celda[i][j+1] +celda[i+1][j+1]; if celda[i][j]=0 then if suma[i][j]=a then celda[i][j]:=1 else celda[i][j]:=0; if celda[i][j]=1 then if (suma[i][j]>=b)and(suma[i][j]<=c) then celda[i][j]:=1 else celda[i][j]:=0; end; for j:=1 to x do begin for i:=1 to x do write('+--'); write('+ '); writeln; for i:=1 to x do begin if celda[i][j]=1 then write('| @') else begin write('| '); celda[i][j]:=0; end; end; write('|'); writeln; end; for i:=1 to x do write('+--'); write('+'); readln; end; veces:=veces+1; until veces=fin; end; if menu=3 then begin for i:=1 to 10 do for j:=1 to 10 do mundo[i][j]:=0; mundo[2][4]:=1;mundo[6][4]:=1; mundo[2][5]:=1;mundo[6][5]:=1; mundo[5][4]:=1;mundo[8][7]:=1; mundo[5][5]:=1;mundo[8][8]:=1; mundo[5][9]:=1;mundo[8][9]:=1; for j:=1 to 10 do begin for i:=1 to 10 do write('+--'); write('+ '); writeln; for i:=1 to 10 do begin if mundo[i][j]=1 then write('| @') else write('| '); end; write('|'); writeln; end; for i:=1 to 10 do write('+--'); write('+'); repeat begin for i:=2 to x-1 do for j:=2 to x-1 do begin suma[i][j]:=mundo[i-1][j-1]+mundo[i][j-1]+mundo[i+1][j-1] +mundo[i-1][j]+mundo[i+1][j]+mundo[i-1][j+1]+mundo[i][j+1] +mundo[i+1][j+1]; if mundo[i][j]=0 then if suma[i][j]=a then mundo[i][j]:=1 else mundo[i][j]:=0; if mundo[i][j]=1 then if (suma[i][j]>=b)and(suma[i][j]<=c) then mundo[i][j]:=1 else mundo[i][j]:=0; end; for j:=1 to 10 do begin for i:=1 to 10 do write('+--'); write('+ '); writeln; for i:=1 to 10 do begin if mundo[i][j]=1 then write('| @') else write('| '); end; write('|'); writeln; end; for i:=1 to 10 do write('+--'); write('+'); readln; end; veces:=veces+1; until veces=fin; end; end; until menu=4; writeln('juego finalizado gracias por jugar') end. ---------------------------- (aņadido tras someter) ---------------------------- 00:06:11 12/12/09 -> Segun los datos introducidos los ficheros son: G06P09D2 -> Los autores del trabajo son: EMBID PEREZ , RUBEN GIL SANCHEZ, TERESA Nombres originales de los archivos entregados -> PRUEBA15.PAS, PRUEBA15text.txt