Está en la página 1de 16

SOFTWARE PARA INGENIERÍA

FASE 6: CONSTRUCCIÓN COLABORATIVA

ESTUDIANTES:

NELSON JOSÉ ACOSTA

SERGIO ANDRÉS GUERRERO

TUTOR:

DIEGO FERNANDO VASCO

UNIVERSIDAD ABIERTA Y A DISTANCIA

ESCUELA DE CIENCIAS BÁSICAS, TECNOLOGÍA E INGENIERÍA

MAYO 2020
DIAGRAMA DE FLUJO
CODIGO

%NELSON ACOSTA FASE 6

%UBICAR EMBARCACIONES

dim=10;

tla=3;

tac=4;

tpa=5;

laup=1;%lancha NO derribada

acup=1; %ACORAZDADO NO DERRIBADO

paup=1;%porta aviones NO derribado

play=1;%para jugar

ren=-1;%numero para rendirme

disparos=0;

aciertos=0;

fallos=0;

rep=0;

puntos=0;

ladn=0;

acdn=0;

padn=0;

contadorprueba=0;

m=zeros(dim,dim);

M=zeros(dim,dim)

%% ASIGNACIÓN DE PORTA AVIONES

v= randi([1,dim],1);

c= randi([1,dim-tpa+1],1);

for i=0:tpa-1 ;
M(c+i,v)=tpa;

endfor

%% ASIGNAR ACORAZADO

h= randi([1,dim]);

if v<=4 %si el porta aviones esta entre la horizontal 1 y 4

s= randi([v+1,dim+1-tac]); %posición inicial del acorazado

elseif v>=7

s= randi([1,v-tac]);

elseif v>4 && v<7

s= randi([v+1,dim+1-tac]);3

endif

%ASIGNAR LA LANCHA

nn=1;

while nn==1

fi=rand([1,dim]);

if fi ~=h

nn=0;

endif

endwhile

if v<=4

z=randi([v+1,dim+1-tla]);

elseif v>=7
z=randi([1,v-tla]);

elseif v>4 && v<7

z=randi([1,v-tla]);

endif

disp(M); %muestra la matriz

%%%%%%%%%%%%%%%INICIO DE JUEGO%%%%%%%%%%%%%%%%%%%%%%%%

%...............DISPAROS........................

fprintf("Ingrese un número en el cual deseas rendirte, \n")

fprintf("debe ser un número diferente al rango de la matriz \n")

fprintf(" n!=[1,",dim,"]\n");

ren=input("Número para rendirse: ");

while ren >=1 && ren <=dim

ren=input("El número NO debe ser el mismo del rango de la matriz")

endwhile

while play==1

fprintf("\n")

x=input("¿desea salir del juego?\n Entonces presiona: ",ren)

while x~=ren && x<1 || x~=ren && x>10

x=input("ingrese la FILA de disparo: ");

endwhile

%..................RENDIRSE...................

if x==ren
fprintf("\n")

disp("----Te has rendido----");

play=0;

endif

if play==0 %si sigue jugando

else

y=input("Columna a Disparar: ");

while y~=ren && y<1 || y~=ren && y>10

y=input("Ingrese la COLUMNA de disparo: ");

endwhile

%.............RENDIRSE......................

if y==ren

fprintf("\n")

disp("--------------Te has rendido---------");

play=0;

else

fprintf("\n")

disp(m);

%........Disparos Realizados...........

for i=1:1

disparos=disparos+1

endfor

tiro=M(x,y); %Listar Coordenadas de disparo

%.........Mencionar disparo...........

%.........Disparos Fallidos...........

if tiro==0
disp("####DISPARO AL AGUA#####");

m(x,y)=8;

disp(m);

for i=1:1

fallos=fallos+1;

endfor

%.............DISPAROS REPETIDOS.........

elseif tiro==10

fprintf("............Ya había disparado antes en estas coordenadas")

for i=1:1

rep=rep+1;

endfor

else

M(x,y)=10

disp(".........Has impactado un barco......");

m(x,y)=1;

disp(m);

%..........CONTAR ACIERTOS............

for i=1:1

aciertos=aciertos+1;

endfor

endif

%...................LANCHA DERRIBADA...........

if laup==1

[j,l]=find(M==tla);
[lancha,o]=size(j);

if lancha==0

disp("*********DERRIBASTE UNA LANCHA**********");

disp(".....5 puntos adicionales......");

ladn=5;

laup=0;

endif

endif

%............ACORAZADO DERRIBADO............

if acup==1

[j,l]=find(M==tac);

[ACORAZADO,o]=size(j);

if ACORAZADO==0

disp("*******DERRIBASTE UN ACORAZADO*********");

disp("......10 puntos adicionales.......");

acdn=10;

acup=0;

endif

endif

%................PORTA AVIONES DERRIBADOS.............

if paup==1

[j,l]=find(M==tpa);

[Portaviones,o]=size(j);

if Portaviones==0
disp("****************DERRIBASTE UN PORTA AVIONES*********");

disp("..... 15 Puntos adicionales......");

padn=15;

paup=0;

endif

disp("")

endif

%................CUANDO DERRIBEN TODOS...........

if laup==0 && acup==0 && paup==0

play=0;

fprintf(" \n")

fprintf("**************FELICITACIONES**********");

endif

endif

endif

endwhile

%::::::::::::::::::PUNTUACIONES::::::::::::::::

fprintf("\n")

puntos=ladn+acdn+padn+aciertos;

disp("Disparos Acertados:..."+aciertos)

disp("Disparos Fallidos:..."+fallos)

disp("Disparos Repetidos:..."+rep)

disp("Disparos Realizados:.."+disparos);

disp("PUNTOS OBTENIDOS:....."+puntos)
%MOSTRAR BARCOS DERRIBADOS......

fprintf("Barcos Derribados: ");

if laup==1 && acup==1 && paup==1

fprintf("No derribaste ningún barco!!\n");

endif

if laup==0

fprintf("Lancha, ");

endif

if acup==0

fprintf("Acorazado, ");

endif

if paup==0

fprintf("Porta Aviones. \n");

endif

PANTALLAZOS
RESPUESTA DEL PROGRAMA A UN DISPARO FALLIDO, CUANDO UN DISPARO NO DA EN ALGUNA
EMBARCACIÓN, LA MATRIZ MARCA UN NUMERO 8 DONDE FUE EL IMPACTO FALLIDO
CUANDO UN DISPARO IMPACTA UN BARCO, SE MARCA LA MATRIZ CON UN 1 EN DONDE FUE
IMPACTADO EL BARCO E INDICA AL USUARIO QUE SU DISPARO HA IMPACTADO EN EL BLANCO.

CUANDO EL USUARIO HA IMPACTADO LAS VECES REQUIDAS EN UN EMBARCACIÓN PARA HUNDIRLO, EL


PROGRAMA OTORGA LOS PUNTOS OBTENIDOS POR HABER DERRIBADO UN BARCO, DICE EL TIPO DE
BARCO QUE DERRUMBÓ Y LOS PUNTOS GANADOS.
CUANDO EL USUARIO DECIDE NO SEGUIR JUGANDO SOLO DEBE DARLE LA OPCIÓN DEL NUMERO QUE
DESIGNÓ COMO NÚMERO DE SALIDA.
CONCLUSIONES

Del anterior trabajo pudimos resuelve problemas del campo de la ingeniería que involucran el
uso de arreglos y gráficas, a través de programas desarrollados en software de modelamiento
matemático, además comprendimos el manejo de algoritmo que dé solución al problema
planteado en la actividad ,desarrollamos el código que da solución al problema planteado en el
curso
BIBLIOGRAFÍA

 https://www.youtube.com/watch?v=TdtQky2MqXM
 https://web.microsoftstream.com/video/0537f665-31ab-4c41-ba5a-08a7e6da68be
 Hahn, B. D., & Valentine, D. T. (2013). Essential MATLAB for Engineers and Scientists
(Vol. Fifth edition). Waltham, MA: Academic Press. Capítulo 6. Pág. 129-160.
Recuperado de
http://bibliotecavirtual.unad.edu.co/login?url=http://search.ebscohost.com/login.asp
x?direct=true&db=nlebk&AN=485981&lang=es&site=eds-live
 Gil, R. M. (2003). Introducción rápida a Matlab y Simulink para ciencia e ingeniería.
Madrid, ES: Ediciones Díaz de Santos. Capítulo 4. pág. 41-50. Recuperado de
http://bibliotecavirtual.unad.edu.co:2077/lib/unadsp/reader.action?ppg=1&docID=11
059428&tm=1479848795401
Bibliografía

 Hahn, B. D., & Valentine, D. T. (2013). Essential MATLAB for Engineers and Scientists (Vol. Fifth
edition). Waltham, MA: Academic Press. Capítulo 6. Pág. 129-160. Recuperado
de http://bibliotecavirtual.unad.edu.co/login?url=http://search.ebscohost.com/login.aspx?direct
=true&db=nlebk&AN=485981&lang=es&site=eds-live

 Gil, R. M. (2003). Introducción rápida a Matlab y Simulink para ciencia e ingeniería. Madrid, ES:
Ediciones Díaz de Santos. Capítulo 4. pág. 41-50. Recuperado
de http://bibliotecavirtual.unad.edu.co:2077/lib/unadsp/reader.action?ppg=1&docID=11059428
&tm=1479848795401

 Scilab for very beginners. (2013). Capítulos 1-3. pág. 18-33. Recuperado
de https://www.scilab.org/tutorials/scilab-beginners-%E2%80%93-tutorial

 MathWorks. (2009). TheMathworks. Recuperado


de http://www.mathworks.com/help/pdf_doc/matlab/getstart.pdf

 Eike Rietsch. (2010). An Introduction to Scilab from a Matlab User's Point of View. Version 5.2.
Recuperado
de https://wiki.scilab.org/Tutorials?action=AttachFile&do=get&target=Scilab4Matlab.pdf

 Hunt Brian R. (2001), A guide to Matlab for beginners and experienced users. Cambridge
University: Press. Recuperado
de: http://bibliotecavirtual.unad.edu.co/login?url=http://search.ebscohost.com/login.aspx?direc
t=true&db=edshlc&AN=edshlc.009017307.4&lang=es&site=eds-live&scope=site

También podría gustarte