Pascal/Turbo Pascal - Ayuda con este programa

 
Vista:
sin imagen de perfil

Ayuda con este programa

Publicado por Luis (14 intervenciones) el 13/07/2015 20:03:48
buenas amigos necesito hacer un juego que es La vieja necesito saber como se haria o quiero tener mas o menos una idea de como hacerlo con funciones y procedimientos
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

Ayuda con este programa

Publicado por ramon (2158 intervenciones) el 24/07/2015 21:47:56
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
{Terminarlo a tu modo y espero sirva de ayuda   }
 
program juego_de_la_vieja;
 uses
    crt;
  const
     eljugador1 = 'O';
     eljugador2 = 'X';
  type
    tablero = array[1..3,1..3] of char;
  var
    tab : tablero;
    x, y : integer;
 
 
   procedure eltablero;
   begin
      gotoxy(10,4);write('Ú');
      gotoxy(11,4);write('ÄÂÄÂÄ');
      gotoxy(16,4);write('¿');
      gotoxy(10,5);write('³ ³ ³ ³');
      gotoxy(10,6);write('Ã');
      gotoxy(11,6);write('ÄÅÄÅÄ');
      gotoxy(16,6);write('´');
      gotoxy(10,7);write('³ ³ ³ ³');
      gotoxy(10,8);write('Ã');
      gotoxy(11,8);write('ÄÅÄÅÄ');
      gotoxy(16,8);write('´');
      gotoxy(10,9);write('³ ³ ³ ³');
      gotoxy(10,10);write('À');
      gotoxy(11,10);write('ÄÁÄÁÄ');
      gotoxy(16,10);write('Ù');
      gotoxy(10,12);write('Jugador 1 = ',eljugador1);
      gotoxy(10,13);write('Jugador 2 = ',eljugador2);
   end;
 
   procedure fichas(xn, yn : integer;jugador : char);
   var
      posx, posy : integer;
   begin
   case xn of
   11 : posx := 1;
   13 : posx := 2;
   15 : posx := 3;
    end;
   case yn of
   5 : posy := 1;
   7 : posy := 2;
   9 : posy := 3;
    end;
      if tab[posx,posy] = ' ' then
      begin
       gotoxy(xn,yn);write(jugador);
       tab[posx,posy] := jugador;
      end
   else
      begin
       gotoxy(10,15);write('Casilla Ocupada');
      end;
   end;
 
   procedure posiciones;
   begin
      gotoxy(18,5);write('11x5 ',' 13x5 ',' 15x5');
      gotoxy(18,7);write('11x7 ',' 13x7 ',' 15x7');
      gotoxy(18,9);write('11x9 ',' 13x9 ',' 15x9');
   end;
 
   procedure entradascordenadas(juga : char);
   var
      posx, posy, x1, y1 : integer;
   begin
      gotoxy(10,15);write('entre posicion x :     el jugador = ',juga);
      gotoxy(29,15);
      repeat
         {$I-} readln(x1); {$I+}
         if ioresult <> 0 then
         begin
         x1 := 0;
         gotoxy(29,15);
         end;
      until x1 in[11,13,15];
         gotoxy(10,16);write('entre posicion y :    el jugador = ',juga);
         gotoxy(29,16);
         repeat
            {$I-} readln(y1); {$I+}
         if ioresult <> 0 then
         begin
         y1 := 0;
         gotoxy(29,16);
         end;
         until y1 in[5,7,9];
         fichas(x1,y1,juga);
         gotoxy(10,15);clreol;
         gotoxy(10,16);clreol;
    end;
 
  function verificaposicioncolumna(h : char) : boolean;
  var
     ss : boolean;
  begin
     verificaposicioncolumna := false;
     ss := false;
     if (tab[1,1] = h) and (tab[1,2] = h) and
                    (tab[1,3] = h) and (ss = false) then
     begin
     verificaposicioncolumna := true;
     ss := true;
     end;
     if (tab[2,1] = h) and (tab[2,2] = h) and
                    (tab[2,3] = h) and (ss = false )then
     begin
     verificaposicioncolumna := true;
     ss := true;
     end;
     if (tab[3,1] = h) and (tab[3,2] = h) and
                    (tab[3,3] = h) and (ss = false) then
     begin
     verificaposicioncolumna := true;
     ss := true;
     end;
  end;
 
  function verificaposicionlinea(h : char) : boolean;
  var
     ss : boolean;
  begin
     verificaposicionlinea := false;
     ss := false;
     if (tab[1,1] = h) and (tab[2,1] = h) and
                    (tab[3,1] = h) and (ss = false) then
     begin
     verificaposicionlinea := true;
     ss := true;
     end;
     if (tab[1,2] = h) and (tab[2,2] = h) and
                    (tab[3,2] = h) and (ss = false )then
     begin
     verificaposicionlinea := true;
     ss := true;
     end;
     if (tab[1,3] = h) and (tab[2,3] = h) and
                    (tab[3,3] = h) and (ss = false) then
     begin
     verificaposicionlinea := true;
     ss := true;
     end;
  end;
 
  function verificaposicioninclider(h : char) : boolean;
  var
    ss : boolean;
    begin
        verificaposicioninclider := false;
     ss := false;
     if (tab[3,1] = h) and (tab[2,2] = h) and
                    (tab[1,3] = h) and (ss = false) then
     begin
       verificaposicioninclider := true;
     end;
    end;
 
  function verificaposicionincliizq(h : char) : boolean;
  var
    ss : boolean;
    begin
       verificaposicionincliizq := false;
     ss := false;
     if (tab[1,1] = h) and (tab[2,2] = h) and
                    (tab[3,3] = h) and (ss = false) then
     begin
       verificaposicionincliizq := true;
     end;
    end;
 
  procedure inicio_partida;
  var
    posx, posy, p1, p2, z, n, emp : integer;
    fin, resuelto : boolean;
    ju : char;
   begin
      randomize;
      eltablero;
      posiciones;
      resuelto := false;
    emp := random(60) + 1;
    if emp mod 2 = 0 then
    n := 1
  else
    n := 2;
     if n = 1 then
     begin
      entradascordenadas('O');
      entradascordenadas('X');
      entradascordenadas('O');
      entradascordenadas('X');
      entradascordenadas('O');
      entradascordenadas('X');
     end;
     if n = 2 then
     begin
      entradascordenadas('X');
      entradascordenadas('O');
      entradascordenadas('X');
      entradascordenadas('O');
      entradascordenadas('X');
      entradascordenadas('O');
     end;
     if verificaposicioncolumna('O') = true then
     begin
     gotoxy(12,18);write('Gana El Jugador [O]');
     resuelto := true;
     end;
     if verificaposicioncolumna('X') = true then
     begin
     gotoxy(12,18);write('Gana El Jugador [X]');
     resuelto := true;
     end;
     if verificaposicionlinea('O') = true then
     begin
     gotoxy(12,18);write('Gana El Jugador [O]');
     resuelto := true;
     end;
     if verificaposicionlinea('X') = true then
     begin
     gotoxy(12,18);write('Gana El Jugador [X]');
     resuelto := true;
     end;
     if verificaposicioninclider('O') then
     begin
      gotoxy(12,18);write('Gana El Jugador [O]');
      resuelto := true;
     end;
     if verificaposicioninclider('X') then
     begin
      gotoxy(12,18);write('Gana El Jugador [X]');
      resuelto := true;
     end;
     if verificaposicionincliizq('O') then
     begin
      gotoxy(12,18);write('Gana El Jugador [O]');
      resuelto := true;
     end;
     if verificaposicionincliizq('X') then
     begin
      gotoxy(12,18);write('Gana El Jugador [X]');
      resuelto := true;
     end;
   if resuelto = false then
   begin
      z := n;
      gotoxy(10,19);write('Termina entrando valor 27');
      repeat
        case z of
   1 : ju := 'O';
   2 : ju := 'X';
      end;
         gotoxy(10,20);write('juega el jugador ',ju);
         gotoxy(10,15);write('tomamos posicion x :     el jugador = ',ju);
         gotoxy(31,15);
         fin := false;
      repeat
         {$I-} readln(p1); {$I+}
         if ioresult <> 0 then
         begin
         p1 := 0;
         gotoxy(29,15);
         end;
      until p1 in[11,13,15,27];
      if p1 <> 27 then
      begin
      gotoxy(10,16);write('tomamos posicion y :    el jugador = ',ju);
       gotoxy(31,16);
         repeat
            {$I-} readln(p2); {$I+}
         if ioresult <> 0 then
         begin
         p2 := 0;
         gotoxy(29,16);
         end;
         until p2 in[5,7,9,27];
       end;
        if (p1 <> 27) and (p2 <> 27) then
        begin
           gotoxy(p1,p2);write(' ');
    case p1 of
   11 : posx := 1;
   13 : posx := 2;
   15 : posx := 3;
    end;
   case p2 of
   5 : posy := 1;
   7 : posy := 2;
   9 : posy := 3;
    end;
    if tab[posx,posy] = ' ' then
      begin
       tab[posx,posy] := ' ';
      end
   else
      begin
       gotoxy(10,15);write('Casilla Ocupada');
      end;
        entradascordenadas(ju);
        end;
       if (p1 <> 27) and (p2 <> 27) then
       begin
          inc(z);
          if z > 2 then
          z := 1;
          case z of
       1 : ju := 'O';
       2 : ju := 'X';
         end;
       end;
      until (p1 = 27) or (p2 = 27) or (fin = true);
   end;
  end;
 
 
   begin
      clrscr;
      fillchar(tab,sizeof(tab),' ');
      inicio_partida;
   end.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar