├── build.xml
├── manifest.mf
├── nbproject
├── build-impl.xml
├── genfiles.properties
├── project.properties
└── project.xml
└── src
├── Controlador
└── Controlador.java
├── Imagenes
├── Alfil.png
├── AlfilNegro.png
├── Caballo.png
├── CaballoNegro.png
├── Ficha Peon.png
├── Ficha PeonNegra.png
├── Reina.png
├── ReinaNegra.png
├── Rey.png
├── ReyNegro.png
├── Torre.png
└── TorreNegra.png
├── Main
└── Main.java
├── Modelo
├── Bot.java
└── Movimientos.java
└── Vista
├── MateHaciaBlancas.form
├── MateHaciaBlancas.java
├── MateHaciaNegras.form
├── MateHaciaNegras.java
├── VentanaEleccionFicha.form
├── VentanaEleccionFicha.java
├── VistaTablero.form
└── VistaTablero.java
/build.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | Builds, tests, and runs the project Proyecto_Ajedrez.
12 |
13 |
73 |
74 |
--------------------------------------------------------------------------------
/manifest.mf:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | X-COMMENT: Main-Class will be added automatically by build
3 |
4 |
--------------------------------------------------------------------------------
/nbproject/genfiles.properties:
--------------------------------------------------------------------------------
1 | build.xml.data.CRC32=98af3026
2 | build.xml.script.CRC32=b9075019
3 | build.xml.stylesheet.CRC32=8064a381@1.80.1.48
4 | # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
5 | # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
6 | nbproject/build-impl.xml.data.CRC32=98af3026
7 | nbproject/build-impl.xml.script.CRC32=6b2f4520
8 | nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48
9 |
--------------------------------------------------------------------------------
/nbproject/project.properties:
--------------------------------------------------------------------------------
1 | annotation.processing.enabled=true
2 | annotation.processing.enabled.in.editor=false
3 | annotation.processing.processors.list=
4 | annotation.processing.run.all.processors=true
5 | annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
6 | application.title=Proyecto_Ajedrez
7 | application.vendor=Dani
8 | build.classes.dir=${build.dir}/classes
9 | build.classes.excludes=**/*.java,**/*.form
10 | # This directory is removed when the project is cleaned:
11 | build.dir=build
12 | build.generated.dir=${build.dir}/generated
13 | build.generated.sources.dir=${build.dir}/generated-sources
14 | # Only compile against the classpath explicitly listed here:
15 | build.sysclasspath=ignore
16 | build.test.classes.dir=${build.dir}/test/classes
17 | build.test.results.dir=${build.dir}/test/results
18 | # Uncomment to specify the preferred debugger connection transport:
19 | #debug.transport=dt_socket
20 | debug.classpath=\
21 | ${run.classpath}
22 | debug.test.classpath=\
23 | ${run.test.classpath}
24 | # Files in build.classes.dir which should be excluded from distribution jar
25 | dist.archive.excludes=
26 | # This directory is removed when the project is cleaned:
27 | dist.dir=dist
28 | dist.jar=${dist.dir}/Proyecto_Ajedrez.jar
29 | dist.javadoc.dir=${dist.dir}/javadoc
30 | endorsed.classpath=
31 | excludes=
32 | includes=**
33 | jar.compress=false
34 | javac.classpath=
35 | # Space-separated list of extra javac options
36 | javac.compilerargs=
37 | javac.deprecation=false
38 | javac.external.vm=true
39 | javac.processorpath=\
40 | ${javac.classpath}
41 | javac.source=1.8
42 | javac.target=1.8
43 | javac.test.classpath=\
44 | ${javac.classpath}:\
45 | ${build.classes.dir}
46 | javac.test.processorpath=\
47 | ${javac.test.classpath}
48 | javadoc.additionalparam=
49 | javadoc.author=false
50 | javadoc.encoding=${source.encoding}
51 | javadoc.noindex=false
52 | javadoc.nonavbar=false
53 | javadoc.notree=false
54 | javadoc.private=false
55 | javadoc.splitindex=true
56 | javadoc.use=true
57 | javadoc.version=false
58 | javadoc.windowtitle=
59 | main.class=Main.Main
60 | manifest.file=manifest.mf
61 | meta.inf.dir=${src.dir}/META-INF
62 | mkdist.disabled=false
63 | platform.active=default_platform
64 | run.classpath=\
65 | ${javac.classpath}:\
66 | ${build.classes.dir}
67 | # Space-separated list of JVM arguments used when running the project.
68 | # You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
69 | # To set system properties for unit tests define test-sys-prop.name=value:
70 | run.jvmargs=
71 | run.test.classpath=\
72 | ${javac.test.classpath}:\
73 | ${build.test.classes.dir}
74 | source.encoding=UTF-8
75 | src.dir=src
76 | test.src.dir=test
77 |
--------------------------------------------------------------------------------
/nbproject/project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.netbeans.modules.java.j2seproject
4 |
5 |
6 | Proyecto_Ajedrez
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/Controlador/Controlador.java:
--------------------------------------------------------------------------------
1 | package Controlador;
2 |
3 | import Modelo.Bot;
4 | import Modelo.Movimientos;
5 | import Vista.MateHaciaBlancas;
6 | import Vista.VentanaEleccionFicha;
7 | import Vista.VistaTablero;
8 | import java.awt.event.ActionEvent;
9 | import java.awt.event.ActionListener;
10 | import javax.swing.ImageIcon;
11 | import javax.swing.JButton;
12 |
13 | public class Controlador implements ActionListener {
14 |
15 | public static boolean enrroqueReyA = true;
16 | public static boolean enrroqueTorreIzquierdaA = true;
17 | public static boolean enrroqueTorreDerechaA = true;
18 | public static boolean enrroqueReyB = true;
19 | public static boolean enrroqueTorreIzquierdaB = true;
20 | public static boolean enrroqueTorreDerechaB = true;
21 |
22 | public static String[][] tablero = new String[8][8];
23 | private char turnoJugador = 'A';
24 | private String posicionAntigua = null;
25 | private String posicionNueva = null;
26 | private String posicionActual;
27 | public static String fichaElegida;
28 | public static ImageIcon imagenElegida;
29 | Movimientos movimientos;
30 | Bot bot = new Bot();
31 |
32 | public Controlador() {
33 | iniciarTablero();
34 | VistaTablero vista = new VistaTablero();
35 | vista.setVisible(true);
36 | añadirActionEvents();
37 | movimientos = new Movimientos();
38 | }
39 |
40 | private void iniciarTablero() {
41 | for (int i = 0; i < 8; i++) {
42 | for (int j = 0; j < 8; j++) {
43 | tablero[i][j] = "";
44 | }
45 | }
46 |
47 | for (int i = 0; i < 8; i++) {
48 | tablero[1][i] = "B_peon";
49 | tablero[6][i] = "A_peon";
50 | }
51 |
52 | tablero[0][0] = "B_torre";
53 | tablero[0][1] = "B_caballo";
54 | tablero[0][2] = "B_alfil";
55 | tablero[0][3] = "B_reina";
56 | tablero[0][4] = "B_rey";
57 | tablero[0][5] = "B_alfil";
58 | tablero[0][6] = "B_caballo";
59 | tablero[0][7] = "B_torre";
60 |
61 | tablero[7][0] = "A_torre";
62 | tablero[7][1] = "A_caballo";
63 | tablero[7][2] = "A_alfil";
64 | tablero[7][3] = "A_reina";
65 | tablero[7][4] = "A_rey";
66 | tablero[7][5] = "A_alfil";
67 | tablero[7][6] = "A_caballo";
68 | tablero[7][7] = "A_torre";
69 | }
70 |
71 | private void añadirActionEvents() {
72 | VistaTablero.c00.addActionListener(this);
73 | VistaTablero.c01.addActionListener(this);
74 | VistaTablero.c02.addActionListener(this);
75 | VistaTablero.c03.addActionListener(this);
76 | VistaTablero.c04.addActionListener(this);
77 | VistaTablero.c05.addActionListener(this);
78 | VistaTablero.c06.addActionListener(this);
79 | VistaTablero.c07.addActionListener(this);
80 |
81 | VistaTablero.c10.addActionListener(this);
82 | VistaTablero.c11.addActionListener(this);
83 | VistaTablero.c12.addActionListener(this);
84 | VistaTablero.c13.addActionListener(this);
85 | VistaTablero.c14.addActionListener(this);
86 | VistaTablero.c15.addActionListener(this);
87 | VistaTablero.c16.addActionListener(this);
88 | VistaTablero.c17.addActionListener(this);
89 |
90 | VistaTablero.c20.addActionListener(this);
91 | VistaTablero.c21.addActionListener(this);
92 | VistaTablero.c22.addActionListener(this);
93 | VistaTablero.c23.addActionListener(this);
94 | VistaTablero.c24.addActionListener(this);
95 | VistaTablero.c25.addActionListener(this);
96 | VistaTablero.c26.addActionListener(this);
97 | VistaTablero.c27.addActionListener(this);
98 |
99 | VistaTablero.c30.addActionListener(this);
100 | VistaTablero.c31.addActionListener(this);
101 | VistaTablero.c32.addActionListener(this);
102 | VistaTablero.c33.addActionListener(this);
103 | VistaTablero.c34.addActionListener(this);
104 | VistaTablero.c35.addActionListener(this);
105 | VistaTablero.c36.addActionListener(this);
106 | VistaTablero.c37.addActionListener(this);
107 |
108 | VistaTablero.c40.addActionListener(this);
109 | VistaTablero.c41.addActionListener(this);
110 | VistaTablero.c42.addActionListener(this);
111 | VistaTablero.c43.addActionListener(this);
112 | VistaTablero.c44.addActionListener(this);
113 | VistaTablero.c45.addActionListener(this);
114 | VistaTablero.c46.addActionListener(this);
115 | VistaTablero.c47.addActionListener(this);
116 |
117 | VistaTablero.c50.addActionListener(this);
118 | VistaTablero.c51.addActionListener(this);
119 | VistaTablero.c52.addActionListener(this);
120 | VistaTablero.c53.addActionListener(this);
121 | VistaTablero.c54.addActionListener(this);
122 | VistaTablero.c55.addActionListener(this);
123 | VistaTablero.c56.addActionListener(this);
124 | VistaTablero.c57.addActionListener(this);
125 |
126 | VistaTablero.c60.addActionListener(this);
127 | VistaTablero.c61.addActionListener(this);
128 | VistaTablero.c62.addActionListener(this);
129 | VistaTablero.c63.addActionListener(this);
130 | VistaTablero.c64.addActionListener(this);
131 | VistaTablero.c65.addActionListener(this);
132 | VistaTablero.c66.addActionListener(this);
133 | VistaTablero.c67.addActionListener(this);
134 |
135 | VistaTablero.c70.addActionListener(this);
136 | VistaTablero.c71.addActionListener(this);
137 | VistaTablero.c72.addActionListener(this);
138 | VistaTablero.c73.addActionListener(this);
139 | VistaTablero.c74.addActionListener(this);
140 | VistaTablero.c75.addActionListener(this);
141 | VistaTablero.c76.addActionListener(this);
142 | VistaTablero.c77.addActionListener(this);
143 | }
144 |
145 | @Override
146 | public void actionPerformed(ActionEvent ae) {
147 | if (turnoJugador == 'A') {
148 | posicionActual = getBotonPosicionString(ae.getSource());
149 |
150 | if (comprobarSiLaFichaEsBlanca(posicionActual)) {
151 | posicionAntigua = posicionActual;
152 | } else if (posicionAntigua != null) {
153 | posicionNueva = posicionActual;
154 | if (movimientos.esPosibleEsteMovimiento(tablero, posicionAntigua, posicionNueva)){
155 | cambiarFichas(posicionAntigua, posicionNueva);
156 | posicionNueva = null;
157 | posicionAntigua = null;
158 | turnoMaquina();
159 | comprobarJaqueMateHaciaBlancas();
160 | }
161 | }
162 | }
163 | }
164 |
165 | private void comprobarJaqueMateHaciaBlancas(){
166 | boolean jaqueMate = true;
167 | for(int i = 0;i<8;i++){
168 | for(int j = 0;j<8;j++){
169 | String posicion = ""+i+""+j;
170 | if(comprobarSiLaFichaEsBlanca(posicion)){
171 | String[] movimientosF = movimientos.movimientosAmodificados(tablero, posicion);
172 | if(!movimientosF[0].equals("")){
173 | jaqueMate = false;
174 | break;
175 | }
176 | }
177 | }
178 | }
179 |
180 | if(jaqueMate == true){
181 | MateHaciaBlancas ventana = new MateHaciaBlancas(null, true);
182 | ventana.setVisible(true);
183 | }
184 |
185 | }
186 |
187 | private void turnoMaquina(){
188 | String[] movimientos = bot.movimientoBot(tablero);
189 | cambiarFichas(movimientos[0], movimientos[1]);
190 | }
191 |
192 |
193 | private void cambiarFichas(String posAntigua, String posNueva) {
194 | cambiarEnString(posAntigua, posNueva);
195 | cambiarEnPantalla(posAntigua, posNueva);
196 | comprobarPeonEnUltimaFila();
197 | comprobarEnrroque(posAntigua, posNueva);
198 | }
199 |
200 | private void cambiarEnString(String posAntigua, String posNueva) {
201 | int xA = Character.getNumericValue(posAntigua.charAt(1));
202 | int yA = Character.getNumericValue(posAntigua.charAt(0));
203 |
204 | int xN = Character.getNumericValue(posNueva.charAt(1));
205 | int yN = Character.getNumericValue(posNueva.charAt(0));
206 |
207 | tablero[yN][xN] = tablero[yA][xA];
208 | tablero[yA][xA] = "";
209 | }
210 |
211 | private void cambiarEnPantalla(String posAntigua, String posNueva) {
212 | boton(posNueva).setIcon(boton(posAntigua).getIcon());
213 | boton(posAntigua).setIcon(null);
214 | }
215 |
216 | private void comprobarPeonEnUltimaFila() {
217 | for (int i = 0; i < 8; i++) {
218 | if (tablero[0][i].equals("A_peon")) {
219 | //Se mostrara la tabla de eleccion de ficha
220 | eleccionDePeon();
221 | tablero[0][i] = fichaElegida;
222 | String posicion = "0" + i;
223 | boton(posicion).setIcon(imagenElegida);
224 | }
225 |
226 | if (tablero[7][i].equals("B_peon")) {
227 | tablero[7][i] = "B_reina";
228 | String posicion = "7" + i;
229 | boton(posicion).setIcon(new ImageIcon(getClass().getResource("/Imagenes/ReinaNegra.png")));
230 | }
231 | }
232 | }
233 |
234 | private void eleccionDePeon() {
235 | VentanaEleccionFicha ventanaElec = new VentanaEleccionFicha(null, true);
236 | ventanaElec.setVisible(true);
237 | }
238 |
239 | private void comprobarEnrroque(String posAntigua, String posNueva) {
240 | int xN = Character.getNumericValue(posNueva.charAt(1));
241 | int yN = Character.getNumericValue(posNueva.charAt(0));
242 |
243 | int xA = Character.getNumericValue(posAntigua.charAt(1));
244 | int yA = Character.getNumericValue(posAntigua.charAt(0));
245 |
246 | if (tablero[yN][xN].equals("A_rey") || tablero[yN][xN].equals("B_rey")) {
247 | if (xA + 2 == xN) {
248 | //Derecha
249 | tablero[yN][xN - 1] = tablero[yN][7];
250 | tablero[yN][xN + 1] = "";
251 |
252 | String posicionTorreAntigua = "" + yN + 7;
253 | String posicionTorreNueva = "" + yN + (xN - 1);
254 |
255 | boton(posicionTorreNueva).setIcon(boton(posicionTorreAntigua).getIcon());
256 | boton(posicionTorreAntigua).setIcon(null);
257 | } else if (xA - 2 == xN) {
258 | //Izquierda
259 | tablero[yN][xA - 1] = tablero[yN][0];
260 | tablero[yN][0] = "";
261 |
262 | String posicionTorreAntigua = "" + yN + 0;
263 | String posicionTorreNueva = "" + yN + (xA - 1);
264 |
265 | boton(posicionTorreNueva).setIcon(boton(posicionTorreAntigua).getIcon());
266 | boton(posicionTorreAntigua).setIcon(null);
267 | }
268 | }
269 | }
270 |
271 | private JButton boton(String posicion) {
272 | if (posicion.equals("00")) {
273 | return VistaTablero.c00;
274 | } else if (posicion.equals("01")) {
275 | return VistaTablero.c01;
276 | } else if (posicion.equals("02")) {
277 | return VistaTablero.c02;
278 | } else if (posicion.equals("03")) {
279 | return VistaTablero.c03;
280 | } else if (posicion.equals("04")) {
281 | return VistaTablero.c04;
282 | } else if (posicion.equals("05")) {
283 | return VistaTablero.c05;
284 | } else if (posicion.equals("06")) {
285 | return VistaTablero.c06;
286 | } else if (posicion.equals("07")) {
287 | return VistaTablero.c07;
288 | } else if (posicion.equals("10")) {
289 | return VistaTablero.c10;
290 | } else if (posicion.equals("11")) {
291 | return VistaTablero.c11;
292 | } else if (posicion.equals("12")) {
293 | return VistaTablero.c12;
294 | } else if (posicion.equals("13")) {
295 | return VistaTablero.c13;
296 | } else if (posicion.equals("14")) {
297 | return VistaTablero.c14;
298 | } else if (posicion.equals("15")) {
299 | return VistaTablero.c15;
300 | } else if (posicion.equals("16")) {
301 | return VistaTablero.c16;
302 | } else if (posicion.equals("17")) {
303 | return VistaTablero.c17;
304 | } else if (posicion.equals("20")) {
305 | return VistaTablero.c20;
306 | } else if (posicion.equals("21")) {
307 | return VistaTablero.c21;
308 | } else if (posicion.equals("22")) {
309 | return VistaTablero.c22;
310 | } else if (posicion.equals("23")) {
311 | return VistaTablero.c23;
312 | } else if (posicion.equals("24")) {
313 | return VistaTablero.c24;
314 | } else if (posicion.equals("25")) {
315 | return VistaTablero.c25;
316 | } else if (posicion.equals("26")) {
317 | return VistaTablero.c26;
318 | } else if (posicion.equals("27")) {
319 | return VistaTablero.c27;
320 | } else if (posicion.equals("30")) {
321 | return VistaTablero.c30;
322 | } else if (posicion.equals("31")) {
323 | return VistaTablero.c31;
324 | } else if (posicion.equals("32")) {
325 | return VistaTablero.c32;
326 | } else if (posicion.equals("33")) {
327 | return VistaTablero.c33;
328 | } else if (posicion.equals("34")) {
329 | return VistaTablero.c34;
330 | } else if (posicion.equals("35")) {
331 | return VistaTablero.c35;
332 | } else if (posicion.equals("36")) {
333 | return VistaTablero.c36;
334 | } else if (posicion.equals("37")) {
335 | return VistaTablero.c37;
336 | } else if (posicion.equals("40")) {
337 | return VistaTablero.c40;
338 | } else if (posicion.equals("41")) {
339 | return VistaTablero.c41;
340 | } else if (posicion.equals("42")) {
341 | return VistaTablero.c42;
342 | } else if (posicion.equals("43")) {
343 | return VistaTablero.c43;
344 | } else if (posicion.equals("44")) {
345 | return VistaTablero.c44;
346 | } else if (posicion.equals("45")) {
347 | return VistaTablero.c45;
348 | } else if (posicion.equals("46")) {
349 | return VistaTablero.c46;
350 | } else if (posicion.equals("47")) {
351 | return VistaTablero.c47;
352 | } else if (posicion.equals("50")) {
353 | return VistaTablero.c50;
354 | } else if (posicion.equals("51")) {
355 | return VistaTablero.c51;
356 | } else if (posicion.equals("52")) {
357 | return VistaTablero.c52;
358 | } else if (posicion.equals("53")) {
359 | return VistaTablero.c53;
360 | } else if (posicion.equals("54")) {
361 | return VistaTablero.c54;
362 | } else if (posicion.equals("55")) {
363 | return VistaTablero.c55;
364 | } else if (posicion.equals("56")) {
365 | return VistaTablero.c56;
366 | } else if (posicion.equals("57")) {
367 | return VistaTablero.c57;
368 | } else if (posicion.equals("60")) {
369 | return VistaTablero.c60;
370 | } else if (posicion.equals("61")) {
371 | return VistaTablero.c61;
372 | } else if (posicion.equals("62")) {
373 | return VistaTablero.c62;
374 | } else if (posicion.equals("63")) {
375 | return VistaTablero.c63;
376 | } else if (posicion.equals("64")) {
377 | return VistaTablero.c64;
378 | } else if (posicion.equals("65")) {
379 | return VistaTablero.c65;
380 | } else if (posicion.equals("66")) {
381 | return VistaTablero.c66;
382 | } else if (posicion.equals("67")) {
383 | return VistaTablero.c67;
384 | } else if (posicion.equals("70")) {
385 | return VistaTablero.c70;
386 | } else if (posicion.equals("71")) {
387 | return VistaTablero.c71;
388 | } else if (posicion.equals("72")) {
389 | return VistaTablero.c72;
390 | } else if (posicion.equals("73")) {
391 | return VistaTablero.c73;
392 | } else if (posicion.equals("74")) {
393 | return VistaTablero.c74;
394 | } else if (posicion.equals("75")) {
395 | return VistaTablero.c75;
396 | } else if (posicion.equals("76")) {
397 | return VistaTablero.c76;
398 | } else if (posicion.equals("77")) {
399 | return VistaTablero.c77;
400 | }
401 | return null;
402 | }
403 |
404 | private String getBotonPosicionString(Object boton) {
405 | if (boton == VistaTablero.c00) {
406 | return "00";
407 | } else if (boton == VistaTablero.c01) {
408 | return "01";
409 | } else if (boton == VistaTablero.c02) {
410 | return "02";
411 | } else if (boton == VistaTablero.c03) {
412 | return "03";
413 | } else if (boton == VistaTablero.c04) {
414 | return "04";
415 | } else if (boton == VistaTablero.c05) {
416 | return "05";
417 | } else if (boton == VistaTablero.c06) {
418 | return "06";
419 | } else if (boton == VistaTablero.c07) {
420 | return "07";
421 | } else if (boton == VistaTablero.c10) {
422 | return "10";
423 | } else if (boton == VistaTablero.c11) {
424 | return "11";
425 | } else if (boton == VistaTablero.c12) {
426 | return "12";
427 | } else if (boton == VistaTablero.c13) {
428 | return "13";
429 | } else if (boton == VistaTablero.c14) {
430 | return "14";
431 | } else if (boton == VistaTablero.c15) {
432 | return "15";
433 | } else if (boton == VistaTablero.c16) {
434 | return "16";
435 | } else if (boton == VistaTablero.c17) {
436 | return "17";
437 | } else if (boton == VistaTablero.c20) {
438 | return "20";
439 | } else if (boton == VistaTablero.c21) {
440 | return "21";
441 | } else if (boton == VistaTablero.c22) {
442 | return "22";
443 | } else if (boton == VistaTablero.c23) {
444 | return "23";
445 | } else if (boton == VistaTablero.c24) {
446 | return "24";
447 | } else if (boton == VistaTablero.c25) {
448 | return "25";
449 | } else if (boton == VistaTablero.c26) {
450 | return "26";
451 | } else if (boton == VistaTablero.c27) {
452 | return "27";
453 | } else if (boton == VistaTablero.c30) {
454 | return "30";
455 | } else if (boton == VistaTablero.c31) {
456 | return "31";
457 | } else if (boton == VistaTablero.c32) {
458 | return "32";
459 | } else if (boton == VistaTablero.c33) {
460 | return "33";
461 | } else if (boton == VistaTablero.c34) {
462 | return "34";
463 | } else if (boton == VistaTablero.c35) {
464 | return "35";
465 | } else if (boton == VistaTablero.c36) {
466 | return "36";
467 | } else if (boton == VistaTablero.c37) {
468 | return "37";
469 | } else if (boton == VistaTablero.c40) {
470 | return "40";
471 | } else if (boton == VistaTablero.c41) {
472 | return "41";
473 | } else if (boton == VistaTablero.c42) {
474 | return "42";
475 | } else if (boton == VistaTablero.c43) {
476 | return "43";
477 | } else if (boton == VistaTablero.c44) {
478 | return "44";
479 | } else if (boton == VistaTablero.c45) {
480 | return "45";
481 | } else if (boton == VistaTablero.c46) {
482 | return "46";
483 | } else if (boton == VistaTablero.c47) {
484 | return "47";
485 | } else if (boton == VistaTablero.c50) {
486 | return "50";
487 | } else if (boton == VistaTablero.c51) {
488 | return "51";
489 | } else if (boton == VistaTablero.c52) {
490 | return "52";
491 | } else if (boton == VistaTablero.c53) {
492 | return "53";
493 | } else if (boton == VistaTablero.c54) {
494 | return "54";
495 | } else if (boton == VistaTablero.c55) {
496 | return "55";
497 | } else if (boton == VistaTablero.c56) {
498 | return "56";
499 | } else if (boton == VistaTablero.c57) {
500 | return "57";
501 | } else if (boton == VistaTablero.c60) {
502 | return "60";
503 | } else if (boton == VistaTablero.c61) {
504 | return "61";
505 | } else if (boton == VistaTablero.c62) {
506 | return "62";
507 | } else if (boton == VistaTablero.c63) {
508 | return "63";
509 | } else if (boton == VistaTablero.c64) {
510 | return "64";
511 | } else if (boton == VistaTablero.c65) {
512 | return "65";
513 | } else if (boton == VistaTablero.c66) {
514 | return "66";
515 | } else if (boton == VistaTablero.c67) {
516 | return "67";
517 | } else if (boton == VistaTablero.c70) {
518 | return "70";
519 | } else if (boton == VistaTablero.c71) {
520 | return "71";
521 | } else if (boton == VistaTablero.c72) {
522 | return "72";
523 | } else if (boton == VistaTablero.c73) {
524 | return "73";
525 | } else if (boton == VistaTablero.c74) {
526 | return "74";
527 | } else if (boton == VistaTablero.c75) {
528 | return "75";
529 | } else if (boton == VistaTablero.c76) {
530 | return "76";
531 | } else if (boton == VistaTablero.c77) {
532 | return "77";
533 | }
534 | return null;
535 | }
536 |
537 | private boolean comprobarSiLaFichaEsBlanca(String posicion) {
538 | int x = Character.getNumericValue(posicion.charAt(1));
539 | int y = Character.getNumericValue(posicion.charAt(0));
540 | if (!tablero[y][x].equals("")) {
541 | return (tablero[y][x].charAt(0) == 'A') ? true : false;
542 | }
543 | return false;
544 | }
545 |
546 | }
547 |
--------------------------------------------------------------------------------
/src/Imagenes/Alfil.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Programamcion-DAM/Ajedrez-Bot/158b7c831151f13a8450e16103485afc35707a18/src/Imagenes/Alfil.png
--------------------------------------------------------------------------------
/src/Imagenes/AlfilNegro.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Programamcion-DAM/Ajedrez-Bot/158b7c831151f13a8450e16103485afc35707a18/src/Imagenes/AlfilNegro.png
--------------------------------------------------------------------------------
/src/Imagenes/Caballo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Programamcion-DAM/Ajedrez-Bot/158b7c831151f13a8450e16103485afc35707a18/src/Imagenes/Caballo.png
--------------------------------------------------------------------------------
/src/Imagenes/CaballoNegro.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Programamcion-DAM/Ajedrez-Bot/158b7c831151f13a8450e16103485afc35707a18/src/Imagenes/CaballoNegro.png
--------------------------------------------------------------------------------
/src/Imagenes/Ficha Peon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Programamcion-DAM/Ajedrez-Bot/158b7c831151f13a8450e16103485afc35707a18/src/Imagenes/Ficha Peon.png
--------------------------------------------------------------------------------
/src/Imagenes/Ficha PeonNegra.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Programamcion-DAM/Ajedrez-Bot/158b7c831151f13a8450e16103485afc35707a18/src/Imagenes/Ficha PeonNegra.png
--------------------------------------------------------------------------------
/src/Imagenes/Reina.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Programamcion-DAM/Ajedrez-Bot/158b7c831151f13a8450e16103485afc35707a18/src/Imagenes/Reina.png
--------------------------------------------------------------------------------
/src/Imagenes/ReinaNegra.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Programamcion-DAM/Ajedrez-Bot/158b7c831151f13a8450e16103485afc35707a18/src/Imagenes/ReinaNegra.png
--------------------------------------------------------------------------------
/src/Imagenes/Rey.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Programamcion-DAM/Ajedrez-Bot/158b7c831151f13a8450e16103485afc35707a18/src/Imagenes/Rey.png
--------------------------------------------------------------------------------
/src/Imagenes/ReyNegro.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Programamcion-DAM/Ajedrez-Bot/158b7c831151f13a8450e16103485afc35707a18/src/Imagenes/ReyNegro.png
--------------------------------------------------------------------------------
/src/Imagenes/Torre.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Programamcion-DAM/Ajedrez-Bot/158b7c831151f13a8450e16103485afc35707a18/src/Imagenes/Torre.png
--------------------------------------------------------------------------------
/src/Imagenes/TorreNegra.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Programamcion-DAM/Ajedrez-Bot/158b7c831151f13a8450e16103485afc35707a18/src/Imagenes/TorreNegra.png
--------------------------------------------------------------------------------
/src/Main/Main.java:
--------------------------------------------------------------------------------
1 |
2 | package Main;
3 |
4 | import Controlador.Controlador;
5 |
6 |
7 | public class Main {
8 | public static void main(String[] args) {
9 | Controlador controlador = new Controlador();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/Modelo/Bot.java:
--------------------------------------------------------------------------------
1 | package Modelo;
2 |
3 | import Vista.MateHaciaNegras;
4 |
5 | public class Bot {
6 |
7 | String[][] tablero;
8 | Movimientos movimientos = new Movimientos();
9 | boolean primerMovimiento = true;
10 | int[][] puntuacionesPosiciones = new int[8][8];
11 |
12 | //Te retorna las posicion antigua[0] y la posicion nueva[1]
13 | public String[] movimientoBot(String[][] tablero) {
14 | this.tablero = tablero;
15 | examinarLasCasillasAtacadasAlInicio();
16 | return arregloFinal();
17 | }
18 |
19 | private String[] arregloFinal() {
20 | int puntuacionMaxima = -600;
21 | int yInicial = 1;
22 | int xInicial = 4;
23 | int yFinal = 3;
24 | int xFinal = 4;
25 | boolean jaqueMate = true;
26 |
27 | for (int i = 0; i < 8; i++) {
28 | for (int j = 0; j < 8; j++) {
29 | if (comprobarSiLaFichaEsnegra(tablero, i, j)) {
30 | String posicionInicial = "" + i + "" + j;
31 | String[] movimientosPosibles = movimientos.movimientosFichas(tablero, posicionInicial);
32 |
33 | String ficha = tablero[i][j];
34 |
35 | for (int k = 0; k < movimientosPosibles.length; k++) {
36 | String posicionFinal = movimientosPosibles[k];
37 | try {
38 | char ejeY = posicionFinal.charAt(0);
39 | char ejeX = posicionFinal.charAt(1);
40 | int intEjeY = Integer.parseInt(String.valueOf(ejeY));
41 | int intEjeX = Integer.parseInt(String.valueOf(ejeX));
42 | System.out.println(ficha + " : " + posicionFinal);
43 | int puntuacionPosicionEspecifica = punutacionMovimiento(i, j, intEjeY, intEjeX);
44 | System.out.println(puntuacionPosicionEspecifica);
45 | if (puntuacionMaxima <= puntuacionPosicionEspecifica) {
46 | yInicial = i;
47 | xInicial = j;
48 | yFinal = intEjeY;
49 | xFinal = intEjeX;
50 | puntuacionMaxima = puntuacionPosicionEspecifica;
51 | }
52 |
53 | if (puntuacionPosicionEspecifica > -600) {
54 | jaqueMate = false;
55 | }
56 |
57 | } catch (Exception ex) {
58 | }
59 | }
60 | }
61 | }
62 | }
63 |
64 | String posicionAntigua = "" + yInicial + "" + xInicial;
65 | String posicionNueva = "" + yFinal + "" + xFinal;
66 |
67 | if (primerMovimiento) {
68 | posicionAntigua = "14";
69 | posicionNueva = "34";
70 | primerMovimiento = false;
71 | }
72 | System.out.println("Fin turno");
73 |
74 | if (jaqueMate == true) {
75 | MateHaciaNegras ventana = new MateHaciaNegras(null, true);
76 | ventana.setVisible(true);
77 | }
78 | String arrayPosiciones[] = {posicionAntigua, posicionNueva};
79 | return arrayPosiciones;
80 |
81 | }
82 |
83 | private int punutacionMovimiento(int yInicial, int xInicial, int yFinal, int xFinal) {
84 | int puntuacion = 0;
85 | puntuacion += puntuacionEnCasoDeFichaAtaque(yInicial, xInicial, yFinal, xFinal);
86 | puntuacion += puntuacionesPosiciones[yInicial][xInicial];
87 | puntuacion += puntuacionSiEstaDefendiendo(yInicial, xInicial);
88 | puntuacion += puntuacionCasillaSegura(yFinal, xFinal);
89 | puntuacion += puntuacionMovimientosEnFuturo(yInicial, xInicial, yFinal, xFinal);
90 | puntuacion += puntuacionParaDefenderComiendo(tablero, yInicial, xInicial, yFinal, xFinal);
91 | return puntuacion;
92 | }
93 |
94 | private int puntuacionMovimientosEnFuturo(int yInicial, int xInicial, int yFinal, int xFinal) {
95 | int puntuacion = 0;
96 | String tableroFuturo[][] = new String[8][8];
97 | copiarTablero(tableroFuturo);
98 | tableroFuturo[yFinal][xFinal] = tableroFuturo[yInicial][xInicial];
99 | tableroFuturo[yInicial][xInicial] = "";
100 |
101 | if (miReyEnJaque(tableroFuturo)) {
102 | return -2000;
103 | } else if (jaqueMateHaciaEl(tableroFuturo)) {
104 | return 1000;
105 | } else if (podriaHacerJaqueMate(tableroFuturo)) {
106 | return -2000;
107 | } else {
108 | puntuacion += fichaQuePuedeDefender(tableroFuturo, yFinal, xFinal);
109 | puntuacion += fichaQuePuedeAtacar(tableroFuturo, yFinal, xFinal);
110 | return puntuacion;
111 | }
112 | }
113 |
114 | private int fichaQuePuedeDefender(String[][] tableroM, int y, int x) {
115 | String[] ataquesEsaFicha = movimientos.movimientoAtaqueFichaB(tableroM, y, x);
116 | int valor = 0;
117 | for (int i = 0; i < ataquesEsaFicha.length; ++i) {
118 | int yAtaque = Integer.parseInt(String.valueOf(ataquesEsaFicha[i].charAt(0)));
119 | int xAtaque = Integer.parseInt(String.valueOf(ataquesEsaFicha[i].charAt(1)));
120 |
121 | if (comprobarSiLaFichaEsnegra(tableroM, yAtaque, xAtaque)) {
122 | valor += 2;
123 | }
124 |
125 | }
126 | return valor;
127 | }
128 |
129 | private int fichaQuePuedeAtacar(String[][] tableroM, int y, int x) {
130 | String[] ataquesEsaFicha = movimientos.movimientoAtaqueFichaB(tableroM, y, x);
131 | int valor = 0;
132 | for (int i = 0; i < ataquesEsaFicha.length; ++i) {
133 | int yAtaque = Integer.parseInt(String.valueOf(ataquesEsaFicha[i].charAt(0)));
134 | int xAtaque = Integer.parseInt(String.valueOf(ataquesEsaFicha[i].charAt(1)));
135 |
136 | if (comprobarSiLaFichaEsBlanca(tableroM, yAtaque, xAtaque)) {
137 | valor += 2;
138 | }
139 |
140 | }
141 | return valor;
142 | }
143 |
144 | private boolean podriaHacerJaqueMate(String[][] tableroFuturo) {
145 | for (int i = 0; i < 8; i++) {
146 | for (int j = 0; j < 8; j++) {
147 | if (comprobarSiLaFichaEsBlanca(tablero, i, j)) {
148 | String posicion = "" + i + "" + j;
149 | String[] movimientosBlanca = movimientos.movimientosAmodificados(tableroFuturo, posicion);
150 | if (!movimientosBlanca[0].equals("")) {
151 | for (int k = 0; k < movimientosBlanca.length; k++) {
152 |
153 | int iF = Integer.parseInt(String.valueOf(movimientosBlanca[k].charAt(0)));
154 | int jF = Integer.parseInt(String.valueOf(movimientosBlanca[k].charAt(1)));
155 |
156 | String[][] tableroFichaCambiada = new String[8][8];
157 | copiarTablero(tableroFuturo, tableroFichaCambiada);
158 |
159 | tableroFichaCambiada[iF][jF] = tableroFichaCambiada[i][j];
160 | tableroFichaCambiada[i][j] = "";
161 | if (miReyEnJaqueMate(tableroFichaCambiada)) {
162 | return true;
163 | }
164 | }
165 | }
166 |
167 | }
168 | }
169 | }
170 | return false;
171 | }
172 |
173 | private boolean miReyEnJaqueMate(String[][] tableroM) {
174 | for (int i = 0; i < 8; i++) {
175 | for (int j = 0; j < 8; j++) {
176 | if (comprobarSiLaFichaEsnegra(tableroM, i, j)) {
177 | String posicion = "" + i + "" + j;
178 | String[] movimientosNegra = movimientos.movimientosBmodificados(tableroM, posicion);
179 | if (movimientosNegra != null) {
180 | if (!movimientosNegra[0].equals("")) {
181 | return false;
182 | }
183 | }
184 |
185 | }
186 | }
187 | }
188 | return true;
189 | }
190 |
191 | private int puntuacionParaDefenderComiendo(String[][] tableroM, int yInicial, int xInicial, int yFinal, int xFinal) {
192 | String posicionFichaQueAtacaValiosa = posicionFichaQueAtacaAlaMasValiosa(tableroM);
193 | if (!posicionFichaQueAtacaValiosa.equals("ninguna")) {
194 | if (comprobarSiLaPosicionDeAtaqueCoincideConLaQueAtaca(yFinal, xFinal, posicionFichaQueAtacaValiosa)) {
195 | int valorFichaMasValiosa = valorFichaMasValiosaAtacadaEnElTablero(tableroM);
196 | if (estaLaFichaDefendidaPorA(tableroM, posicionFichaQueAtacaValiosa) == false) {
197 | return valorFichaMasValiosa * 3;
198 | } else {
199 | if (fichaQueAtacaValiosaEsMayorOigualQueLaQueLaAtaca(tableroM, yInicial, xInicial, yFinal, xFinal)) {
200 | return valorFichaMasValiosa * 2;
201 | }
202 | }
203 | }
204 | }
205 | return 0;
206 | }
207 |
208 | private boolean fichaQueAtacaValiosaEsMayorOigualQueLaQueLaAtaca(String[][] tableroM, int yInicial, int xInicial, int yFinal, int xFinal) {
209 | String fichaQueAtacaMasValiosa = tableroM[yFinal][xFinal];
210 | String fichaQueLaAtaca = tableroM[yInicial][xInicial];
211 |
212 | int valorAtacaMasValiosa = valorDeLaFicha(fichaQueAtacaMasValiosa);
213 | int valorQueLaAtaca = valorDeLaFicha(fichaQueLaAtaca);
214 |
215 | return (valorAtacaMasValiosa >= valorQueLaAtaca) ? true : false;
216 |
217 | }
218 |
219 | private String buscarFichaQueLaDefiende(String[][] tableroM, String posicion) {
220 | for (int i = 0; i < 8; i++) {
221 | for (int j = 0; j < 8; j++) {
222 | if (comprobarSiLaFichaEsBlanca(tableroM, i, j)) {
223 | String[] movimientosAtaque = movimientos.movimientoAtaqueFichaA(tableroM, i, j);
224 | for (int k = 0; k < movimientosAtaque.length; k++) {
225 | if (movimientosAtaque[k].equals(posicion)) {
226 | return tableroM[i][j];
227 | }
228 | }
229 | }
230 | }
231 | }
232 | return null;
233 | }
234 |
235 | private boolean comprobarSiLaPosicionDeAtaqueCoincideConLaQueAtaca(int yFinal, int xFinal, String posAtaque) {
236 | String posicionAtaca = "" + yFinal + "" + xFinal;
237 | return (posicionAtaca.equals(posAtaque)) ? true : false;
238 | }
239 |
240 | private int valorFichaMasValiosaAtacadaEnElTablero(String[][] tableroM) {
241 | String[] movimientosFichasA = movimientos.todosLosMovimientosFichasA(tableroM);
242 | int valorMayor = 0;
243 | if (!movimientosFichasA[0].equals("")) {
244 | for (int i = 0; i < movimientosFichasA.length; i++) {
245 | int y = Integer.parseInt(String.valueOf(movimientosFichasA[i].charAt(0)));
246 | int x = Integer.parseInt(String.valueOf(movimientosFichasA[i].charAt(1)));
247 | if (comprobarSiLaFichaEsnegra(tableroM, y, x)) {
248 | String ficha = tableroM[y][x];
249 | int valorTemporal = valorDeLaFicha(ficha);
250 | if (valorTemporal > valorMayor) {
251 | valorMayor = valorTemporal;
252 | }
253 |
254 | }
255 |
256 | }
257 | }
258 | return valorMayor;
259 | }
260 |
261 | private String posicionFichaQueAtacaAlaMasValiosa(String[][] tableroM) {
262 | String posicionAtacanteMasValiosa = "ninguna";
263 | int valorMayor = 0;
264 | for (int i = 0; i < 8; i++) {
265 | for (int j = 0; j < 8; j++) {
266 | if (comprobarSiLaFichaEsBlanca(tableroM, i, j)) {
267 | String[] movimientosFichaBlanca = movimientos.movimientoAtaqueFichaA(tableroM, i, j);
268 | if (!movimientosFichaBlanca[0].equals("")) {
269 | for (int k = 0; k < movimientosFichaBlanca.length; k++) {
270 | int y = Integer.parseInt(String.valueOf(movimientosFichaBlanca[k].charAt(0)));
271 | int x = Integer.parseInt(String.valueOf(movimientosFichaBlanca[k].charAt(1)));
272 | if (comprobarSiLaFichaEsnegra(tableroM, y, x)) {
273 | String ficha = tableroM[y][x];
274 | int valorTemporal = valorDeLaFicha(ficha);
275 | if (valorTemporal > valorMayor) {
276 | posicionAtacanteMasValiosa = "" + i + "" + j;
277 | valorMayor = valorTemporal;
278 | }
279 |
280 | }
281 | }
282 | }
283 |
284 | }
285 | }
286 | }
287 | return posicionAtacanteMasValiosa;
288 | }
289 |
290 | private boolean jaqueMateHaciaEl(String[][] tableroM) {
291 | for (int i = 0; i < 8; i++) {
292 | for (int j = 0; j < 8; j++) {
293 | String posicion = "" + i + "" + j;
294 | if (comprobarSiLaFichaEsBlanca(tableroM, i, j)) {
295 | String[] movimientosBlancos = movimientos.movimientosAmodificados(tableroM, posicion);
296 | if (!movimientosBlancos[0].equals("")) {
297 | return false;
298 | }
299 | }
300 | }
301 | }
302 | return true;
303 | }
304 |
305 | private boolean miReyEnJaque(String[][] tableroM) {
306 | //Buscamos primero al rey y luego vemos todas los movimientos posibles de A
307 | for (int i = 0; i < 8; i++) {
308 | for (int j = 0; j < 8; j++) {
309 | if (tableroM[i][j].equals("B_rey")) {
310 | String posicionRey = "" + i + "" + j;
311 | String[] movimientosBlancas = movimientos.todosLosMovimientosFichasA(tableroM);
312 | for (int k = 0; k < movimientosBlancas.length; k++) {
313 | if (posicionRey.equals(movimientosBlancas[k])) {
314 | return true;
315 | }
316 | }
317 | return false;
318 | }
319 | }
320 | }
321 | return false;
322 | }
323 |
324 | private void copiarTablero(String[][] tableroM) {
325 | for (int i = 0; i < 8; i++) {
326 | for (int j = 0; j < 8; j++) {
327 | tableroM[i][j] = tablero[i][j];
328 | }
329 | }
330 | }
331 |
332 | private void copiarTablero(String[][] tableroOriginal, String[][] tableroCopia) {
333 | for (int i = 0; i < 8; i++) {
334 | for (int j = 0; j < 8; j++) {
335 | tableroCopia[i][j] = tableroOriginal[i][j];
336 | }
337 | }
338 | }
339 |
340 | private int puntuacionCasillaSegura(int y, int x) {
341 | String posicionFinal = "" + y + "" + x;
342 | String movimientosAtaqueA[] = movimientos.todosLosMovimientosFichasA(tablero);
343 | for (int i = 0; i < movimientosAtaqueA.length; i++) {
344 | if (posicionFinal.equals(movimientosAtaqueA[i])) {
345 | return -8;
346 | }
347 | }
348 | return 3;
349 | }
350 |
351 | private int puntuacionSiEstaDefendiendo(int y, int x) {
352 | int puntuacion = 0;
353 | String[] movimientosDefensora = movimientos.movimientoAtaqueFichaB(tablero, y, x);
354 | for (int i = 0; i < movimientosDefensora.length; i++) {
355 | int ejeY = Integer.parseInt(String.valueOf(movimientosDefensora[i].charAt(0)));
356 | int ejeX = Integer.parseInt(String.valueOf(movimientosDefensora[i].charAt(1)));
357 | String fichaDefendida = tablero[ejeY][ejeX];
358 | if (!fichaDefendida.equals("")) {
359 | if (fichaDefendida.charAt(0) == 'B') {
360 | puntuacion -= valorDeLaFicha(fichaDefendida) / 4;
361 | }
362 | }
363 | }
364 | return puntuacion;
365 | }
366 |
367 | private int puntuacionEnCasoDeFichaAtaque(int yInicial, int xInicial, int yFinal, int xFinal) {
368 | String fichaInicial = fichaDeLaCasilla(tablero, yInicial, xInicial);
369 | if (comprobarSiLaFichaEsBlanca(tablero, yFinal, xFinal)) {
370 |
371 | String fichaFinal = fichaDeLaCasilla(tablero, yFinal, xFinal);
372 |
373 | String posicionFinal = "" + yFinal + "" + xFinal;
374 |
375 | if (estaLaFichaDefendidaPorA(tablero, posicionFinal) == false) {
376 | return valorDeLaFicha(fichaFinal) * 3;
377 | } else if (valeMasLaPrimera(fichaFinal, fichaInicial)) {
378 | return valorDeLaFicha(fichaFinal) * 3;
379 | } else if (valenIgual(fichaFinal, fichaFinal)) {
380 | return valorDeLaFicha(fichaFinal) * 2;
381 | } else {
382 | return 0;
383 | }
384 | }
385 |
386 | if (fichaInicial.equals("B_rey")) {
387 | return -10;
388 | }
389 |
390 | return 0;
391 | }
392 |
393 | private String devolverFichaSintetizada(String ficha) {
394 | String[] array = ficha.split("_");
395 | return array[1];
396 | }
397 |
398 | private void examinarLasCasillasAtacadasAlInicio() {
399 | ajustarPuntuacion0();
400 | for (int i = 0; i < 8; i++) {
401 | for (int j = 0; j < 8; j++) {
402 | if (comprobarSiLaFichaEsBlanca(tablero, i, j)) {
403 | String posicion = "" + i + "" + j;
404 | String fichaAtacante = tablero[i][j];
405 | String[] movimientosPosibles = movimientos.movimientosFichas(tablero, posicion);
406 | try {
407 | for (int k = 0; k < movimientosPosibles.length; k++) {
408 | int yM = Character.getNumericValue(movimientosPosibles[k].charAt(0));
409 | int xM = Character.getNumericValue(movimientosPosibles[k].charAt(1));
410 | String fichaAtacada = tablero[yM][xM];
411 | if (comprobarSiLaFichaEsnegra(tablero, yM, xM)) {
412 | String posicionFichaAtacada = "" + yM + "" + xM;
413 | if (valeMasLaPrimera(fichaAtacada, fichaAtacante)) {
414 | puntuacionesPosiciones[yM][xM] += valorDeLaFichaSinRey(fichaAtacada);
415 | } else if (estaLaFichaDefendidaPorB(tablero, posicionFichaAtacada) == false) {
416 | puntuacionesPosiciones[yM][xM] += valorDeLaFichaSinRey(fichaAtacada);
417 | }
418 | }
419 | }
420 | } catch (Exception ex) {
421 | }
422 | }
423 | }
424 | }
425 | }
426 |
427 | private boolean estaLaFichaDefendidaPorA(String[][] tableroM, String posicionFicha) {
428 | String[] movimientosVariables = movimientos.todosLosMovimientosFichasA(tableroM);
429 | for (int k = 0; k < movimientosVariables.length; k++) {
430 | if (posicionFicha.equals(movimientosVariables[k])) {
431 | return true;
432 | }
433 | }
434 | return false;
435 | }
436 |
437 | private boolean estaLaFichaDefendidaPorB(String[][] tableroM, String posicionFicha) {
438 | String[] movimientosVariables = movimientos.todosLosMovimientosFichasB(tableroM);
439 | for (int k = 0; k < movimientosVariables.length; k++) {
440 | if (posicionFicha.equals(movimientosVariables[k])) {
441 | return true;
442 | }
443 | }
444 | return false;
445 | }
446 |
447 | private boolean comprobarSiLaFichaEsBlanca(String[][] tableroM, int y, int x) {
448 | if (!tableroM[y][x].equals("")) {
449 | return (tableroM[y][x].charAt(0) == 'A') ? true : false;
450 | }
451 | return false;
452 | }
453 |
454 | private boolean comprobarSiLaFichaEsnegra(String[][] tableroM, int y, int x) {
455 | if (!tableroM[y][x].equals("")) {
456 | return (tableroM[y][x].charAt(0) == 'B') ? true : false;
457 | }
458 | return false;
459 | }
460 |
461 | private String fichaDeLaCasilla(String[][] tableroM, int y, int x) {
462 | String ficha = tableroM[y][x];
463 | return ficha;
464 | }
465 |
466 | private String fichaDeLaCasilla(String[][] tableroM, String posicion) {
467 | char ejeY = posicion.charAt(0);
468 | char ejeX = posicion.charAt(1);
469 | int y = Integer.parseInt(String.valueOf(ejeY));
470 | int x = Integer.parseInt(String.valueOf(ejeX));
471 | String ficha = tableroM[y][x];
472 | return ficha;
473 | }
474 |
475 | private void ajustarPuntuacion0() {
476 | for (int i = 0; i < 8; i++) {
477 | for (int j = 0; j < 8; j++) {
478 | puntuacionesPosiciones[i][j] = 0;
479 | }
480 | }
481 | }
482 |
483 | private boolean valeMasLaPrimera(String ficha1, String ficha2) {
484 | String[] ficha1Split = ficha1.split("_");
485 | String[] ficha2Split = ficha2.split("_");
486 |
487 | int valor1 = valorDeLaFicha(ficha1Split[1]);
488 | int valor2 = valorDeLaFicha(ficha2Split[1]);
489 |
490 | return (valor1 > valor2) ? true : false;
491 | }
492 |
493 | private boolean valenIgual(String ficha1, String ficha2) {
494 | String[] ficha1Split = ficha1.split("_");
495 | String[] ficha2Split = ficha2.split("_");
496 |
497 | int valor1 = valorDeLaFicha(ficha1Split[1]);
498 | int valor2 = valorDeLaFicha(ficha2Split[1]);
499 |
500 | return (valor1 == valor2) ? true : false;
501 | }
502 |
503 | private int valorDeLaFicha(String ficha) {
504 | String ficha1 = ficha;
505 | if (ficha.charAt(0) == 'A' || ficha.charAt(0) == 'B') {
506 | ficha1 = devolverFichaSintetizada(ficha);
507 | }
508 |
509 | int valor = 0;
510 | if (ficha1.equals("peon")) {
511 | valor = 1;
512 | } else if (ficha1.equals("alfil")) {
513 | valor = 8;
514 | } else if (ficha1.equals("torre")) {
515 | valor = 12;
516 | } else if (ficha1.equals("caballo")) {
517 | valor = 12;
518 | } else if (ficha1.equals("reina")) {
519 | valor = 18;
520 | } else if (ficha1.equals("rey")) {
521 | valor = 20;
522 | }
523 | return valor;
524 | }
525 |
526 | private int valorDeLaFichaSinRey(String ficha) {
527 | String ficha1 = ficha;
528 | if (ficha.charAt(0) == 'A' || ficha.charAt(0) == 'B') {
529 | ficha1 = devolverFichaSintetizada(ficha);
530 | }
531 |
532 | int valor = 0;
533 | if (ficha1.equals("peon")) {
534 | valor = 1;
535 | } else if (ficha1.equals("alfil")) {
536 | valor = 8;
537 | } else if (ficha1.equals("torre")) {
538 | valor = 12;
539 | } else if (ficha1.equals("caballo")) {
540 | valor = 12;
541 | } else if (ficha1.equals("reina")) {
542 | valor = 18;
543 | }
544 | return valor;
545 | }
546 |
547 | /*
548 | private String[] pequeñaPruebaDeFuncionamiento(){
549 | int maximo = 0;
550 | int yI = 1;
551 | int xI = 0;
552 | for(int i = 0;i<8;i++){
553 | for(int j = 0;j<8;j++){
554 | if(puntuacionesPosiciones[i][j]>maximo){
555 | yI = i;
556 | xI = j;
557 | maximo = puntuacionesPosiciones[i][j];
558 | }
559 | }
560 | }
561 | String posicionInicial = ""+yI+""+xI;
562 | String[] movimientosPos = movimientos.movimientosFichas(tablero,posicionInicial);
563 | String[] arrayFinal = new String[2];
564 | arrayFinal[0] = posicionInicial;
565 | arrayFinal[1] = movimientosPos[0];
566 | return arrayFinal;
567 | }
568 |
569 | private int comparacionEntreTableros(String[][] tableroReal, String[][] tableroModificado) {
570 | int puntuacionTotal = 0;
571 | String[] fichasSiendoAtacadasEnTableroReal = nombresFichasQueEstanSiendoAtacadasEnElTablero(tableroReal);
572 | String[] fichasSiendoAtacadasEnTableroModificado = nombresFichasQueEstanSiendoAtacadasEnElTablero(tableroModificado);
573 | int puntuacionAtacadasReal = sumaPuntuacionesFichas(fichasSiendoAtacadasEnTableroReal);
574 | int puntuacionAtacadasModificado = sumaPuntuacionesFichas(fichasSiendoAtacadasEnTableroModificado);
575 |
576 | puntuacionTotal += (puntuacionAtacadasModificado - puntuacionAtacadasReal);
577 | puntuacionTotal += metodoDefensaMedianteComer(tableroReal, tableroModificado);
578 |
579 | String[] fichasSiendoProtegidasEnTableroReal = nombresFichasSiendoProtegidas(tableroReal);
580 | String[] fichasSiendoProtegidasEnTableroModificado = nombresFichasSiendoProtegidas(tableroModificado);
581 | int puntuacionDefendidasReal = sumaPuntuacionesFichas(fichasSiendoProtegidasEnTableroReal);
582 | int puntuacionDefendidasModificado = sumaPuntuacionesFichas(fichasSiendoProtegidasEnTableroModificado);
583 |
584 | puntuacionTotal += (puntuacionDefendidasModificado - puntuacionDefendidasReal);
585 |
586 | return puntuacionTotal;
587 | }
588 |
589 | private int sumaPuntuacionesFichas(String[] array) {
590 | int puntuacion = 0;
591 |
592 | for (int i = 0; i < array.length; i++) {
593 | if(!array[i].equals("")){
594 | int valor = valorDeLaFicha(array[i]);
595 | puntuacion += valor;
596 | }
597 | }
598 | return puntuacion;
599 | }
600 |
601 | private int fichasQueDefiende(String[][] tableroM, int y, int x) {
602 | String[] movimientosFicha = movimientos.movimientoAtaqueFichaB(tableroM, y, x);
603 | for (int i = 0; i < movimientosFicha.length; i++) {
604 | String posicionDefendida = movimientosFicha[i];
605 | int yN = Integer.parseInt(String.valueOf(posicionDefendida.charAt(0)));
606 | int xN = Integer.parseInt(String.valueOf(posicionDefendida.charAt(1)));
607 |
608 | if (comprobarSiLaFichaEsnegra(tableroM, yN, xN)) {
609 | return 2;
610 | }
611 | }
612 | return 0;
613 | }
614 |
615 | private int fichaQueAtaca(String[][] tableroM, int y, int x) {
616 | int puntuacionTotal = 0;
617 | String[] movimientosFicha = movimientos.movimientoAtaqueFichaB(tableroM, y, x);
618 | for (int i = 0; i < movimientosFicha.length; i++) {
619 | String posicionAtacada = movimientosFicha[i];
620 | int yN = Integer.parseInt(String.valueOf(posicionAtacada.charAt(0)));
621 | int xN = Integer.parseInt(String.valueOf(posicionAtacada.charAt(1)));
622 |
623 | if (comprobarSiLaFichaEsBlanca(tableroM, yN, xN)) {
624 | puntuacionTotal += valorDeLaFicha(posicionAtacada);
625 | }
626 | }
627 | return puntuacionTotal / 2;
628 | }
629 |
630 | private String[] nombresFichasQueEstanSiendoAtacadasEnElTablero(String[][] tableroM) {
631 | String nombresTotales = "";
632 | for (int i = 0; i < 8; i++) {
633 | for (int j = 0; j < 8; j++) {
634 | if (comprobarSiLaFichaEsBlanca(tableroM, i, j)) {
635 | String posicion = "" + i + "" + j;
636 | String[] movimientosFicha = movimientos.movimientosAmodificados(tableroM, posicion);
637 | for (int k = 0; k < movimientosFicha.length; k++) {
638 | if (!movimientosFicha[k].equals("")) {
639 | int ejeY = Integer.parseInt(String.valueOf(movimientosFicha[k].charAt(0)));
640 | int ejeX = Integer.parseInt(String.valueOf(movimientosFicha[k].charAt(1)));
641 | if (comprobarSiLaFichaEsnegra(tableroM, ejeY, ejeX) && estaLaFichaDefendidaPorB(tableroM, movimientosFicha[k]) == false) {
642 | nombresTotales += "" + tableroM[ejeY][ejeX] + ":";
643 | }
644 | }
645 | }
646 | }
647 | }
648 | }
649 | String[] arrayConNombres = nombresTotales.split(":");
650 | return arrayConNombres;
651 | }
652 |
653 | private String[] nombresFichasSiendoProtegidas(String[][] tableroM){
654 | String[] movimientosNegras = movimientos.todosLosMovimientosFichasB(tableroM);
655 | String nombresFichas = "";
656 | for(int i = 0;i max && valor > 2){
686 | posicionMasValiosa = posicion;
687 | max = valor;
688 | }
689 |
690 | }
691 | }
692 | }
693 | }
694 | }
695 | }
696 | System.out.println(posicionMasValiosa + " : "+max);
697 | for (int i = 0; i < 8; i++) {
698 | for (int j = 0; j < 8; j++) {
699 | if (comprobarSiLaFichaEsBlanca(tableroM, i, j)) {
700 | String posicion = "" + i + "" + j;
701 | String[] movimientosFicha = movimientos.movimientosAmodificados(tableroM, posicion);
702 | for (int k = 0; k < movimientosFicha.length; k++) {
703 | if(movimientosFicha[k].equals(posicionMasValiosa)){
704 | return -max;
705 | }
706 | }
707 | }
708 | }
709 | }
710 | return max*3;
711 | }
712 |
713 |
714 |
715 | */
716 | }
717 |
--------------------------------------------------------------------------------
/src/Vista/MateHaciaBlancas.form:
--------------------------------------------------------------------------------
1 |
2 |
3 |
100 |
--------------------------------------------------------------------------------
/src/Vista/MateHaciaBlancas.java:
--------------------------------------------------------------------------------
1 | /*
2 | * To change this license header, choose License Headers in Project Properties.
3 | * To change this template file, choose Tools | Templates
4 | * and open the template in the editor.
5 | */
6 | package Vista;
7 |
8 | /**
9 | *
10 | * @author Dani
11 | */
12 | public class MateHaciaBlancas extends javax.swing.JDialog {
13 |
14 | /**
15 | * Creates new form MateHaciaBlancas
16 | */
17 | public MateHaciaBlancas(java.awt.Frame parent, boolean modal) {
18 | super(parent, modal);
19 | initComponents();
20 | this.setLocationRelativeTo(null);
21 | }
22 |
23 | /**
24 | * This method is called from within the constructor to initialize the form.
25 | * WARNING: Do NOT modify this code. The content of this method is always
26 | * regenerated by the Form Editor.
27 | */
28 | @SuppressWarnings("unchecked")
29 | // //GEN-BEGIN:initComponents
30 | private void initComponents() {
31 |
32 | jPanel1 = new javax.swing.JPanel();
33 | jLabel1 = new javax.swing.JLabel();
34 | jLabel2 = new javax.swing.JLabel();
35 |
36 | setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
37 |
38 | jPanel1.setBackground(new java.awt.Color(102, 255, 255));
39 |
40 | jLabel1.setFont(new java.awt.Font("Dialog", 1, 48)); // NOI18N
41 | jLabel1.setForeground(new java.awt.Color(0, 0, 0));
42 | jLabel1.setText("LO SENTIMOS");
43 |
44 | jLabel2.setFont(new java.awt.Font("Dialog", 1, 48)); // NOI18N
45 | jLabel2.setForeground(new java.awt.Color(0, 0, 0));
46 | jLabel2.setText("GANÓ LA MAQUINA");
47 |
48 | javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
49 | jPanel1.setLayout(jPanel1Layout);
50 | jPanel1Layout.setHorizontalGroup(
51 | jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
52 | .addGroup(jPanel1Layout.createSequentialGroup()
53 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
54 | .addGroup(jPanel1Layout.createSequentialGroup()
55 | .addGap(90, 90, 90)
56 | .addComponent(jLabel1))
57 | .addGroup(jPanel1Layout.createSequentialGroup()
58 | .addGap(19, 19, 19)
59 | .addComponent(jLabel2)))
60 | .addContainerGap(40, Short.MAX_VALUE))
61 | );
62 | jPanel1Layout.setVerticalGroup(
63 | jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
64 | .addGroup(jPanel1Layout.createSequentialGroup()
65 | .addGap(50, 50, 50)
66 | .addComponent(jLabel1)
67 | .addGap(64, 64, 64)
68 | .addComponent(jLabel2)
69 | .addContainerGap(72, Short.MAX_VALUE))
70 | );
71 |
72 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
73 | getContentPane().setLayout(layout);
74 | layout.setHorizontalGroup(
75 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
76 | .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
77 | );
78 | layout.setVerticalGroup(
79 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
80 | .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
81 | );
82 |
83 | pack();
84 | }// //GEN-END:initComponents
85 |
86 | /**
87 | * @param args the command line arguments
88 | */
89 | public static void main(String args[]) {
90 | /* Set the Nimbus look and feel */
91 | //
92 | /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
93 | * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
94 | */
95 | try {
96 | for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
97 | if ("Nimbus".equals(info.getName())) {
98 | javax.swing.UIManager.setLookAndFeel(info.getClassName());
99 | break;
100 | }
101 | }
102 | } catch (ClassNotFoundException ex) {
103 | java.util.logging.Logger.getLogger(MateHaciaBlancas.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
104 | } catch (InstantiationException ex) {
105 | java.util.logging.Logger.getLogger(MateHaciaBlancas.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
106 | } catch (IllegalAccessException ex) {
107 | java.util.logging.Logger.getLogger(MateHaciaBlancas.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
108 | } catch (javax.swing.UnsupportedLookAndFeelException ex) {
109 | java.util.logging.Logger.getLogger(MateHaciaBlancas.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
110 | }
111 | //
112 |
113 | /* Create and display the dialog */
114 | java.awt.EventQueue.invokeLater(new Runnable() {
115 | public void run() {
116 | MateHaciaBlancas dialog = new MateHaciaBlancas(new javax.swing.JFrame(), true);
117 | dialog.addWindowListener(new java.awt.event.WindowAdapter() {
118 | @Override
119 | public void windowClosing(java.awt.event.WindowEvent e) {
120 | System.exit(0);
121 | }
122 | });
123 | dialog.setVisible(true);
124 | }
125 | });
126 | }
127 |
128 | // Variables declaration - do not modify//GEN-BEGIN:variables
129 | private javax.swing.JLabel jLabel1;
130 | private javax.swing.JLabel jLabel2;
131 | private javax.swing.JPanel jPanel1;
132 | // End of variables declaration//GEN-END:variables
133 | }
134 |
--------------------------------------------------------------------------------
/src/Vista/MateHaciaNegras.form:
--------------------------------------------------------------------------------
1 |
2 |
3 |
100 |
--------------------------------------------------------------------------------
/src/Vista/MateHaciaNegras.java:
--------------------------------------------------------------------------------
1 | /*
2 | * To change this license header, choose License Headers in Project Properties.
3 | * To change this template file, choose Tools | Templates
4 | * and open the template in the editor.
5 | */
6 | package Vista;
7 |
8 | /**
9 | *
10 | * @author Dani
11 | */
12 | public class MateHaciaNegras extends javax.swing.JDialog {
13 |
14 | /**
15 | * Creates new form MateHaciaNegras
16 | */
17 | public MateHaciaNegras(java.awt.Frame parent, boolean modal) {
18 | super(parent, modal);
19 | initComponents();
20 | this.setLocationRelativeTo(null);
21 | }
22 |
23 | /**
24 | * This method is called from within the constructor to initialize the form.
25 | * WARNING: Do NOT modify this code. The content of this method is always
26 | * regenerated by the Form Editor.
27 | */
28 | @SuppressWarnings("unchecked")
29 | // //GEN-BEGIN:initComponents
30 | private void initComponents() {
31 |
32 | jPanel1 = new javax.swing.JPanel();
33 | jLabel1 = new javax.swing.JLabel();
34 | jLabel2 = new javax.swing.JLabel();
35 |
36 | setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
37 |
38 | jPanel1.setBackground(new java.awt.Color(51, 255, 255));
39 |
40 | jLabel1.setFont(new java.awt.Font("Dialog", 1, 48)); // NOI18N
41 | jLabel1.setForeground(new java.awt.Color(0, 0, 0));
42 | jLabel1.setText("ENHORABUENA");
43 |
44 | jLabel2.setBackground(new java.awt.Color(0, 0, 0));
45 | jLabel2.setFont(new java.awt.Font("Dialog", 1, 48)); // NOI18N
46 | jLabel2.setForeground(new java.awt.Color(0, 0, 0));
47 | jLabel2.setText("GANASTE!!");
48 |
49 | javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
50 | jPanel1.setLayout(jPanel1Layout);
51 | jPanel1Layout.setHorizontalGroup(
52 | jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
53 | .addGroup(jPanel1Layout.createSequentialGroup()
54 | .addGap(85, 85, 85)
55 | .addComponent(jLabel1)
56 | .addContainerGap(84, Short.MAX_VALUE))
57 | .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
58 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
59 | .addComponent(jLabel2)
60 | .addGap(141, 141, 141))
61 | );
62 | jPanel1Layout.setVerticalGroup(
63 | jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
64 | .addGroup(jPanel1Layout.createSequentialGroup()
65 | .addGap(53, 53, 53)
66 | .addComponent(jLabel1)
67 | .addGap(46, 46, 46)
68 | .addComponent(jLabel2)
69 | .addContainerGap(123, Short.MAX_VALUE))
70 | );
71 |
72 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
73 | getContentPane().setLayout(layout);
74 | layout.setHorizontalGroup(
75 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
76 | .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
77 | );
78 | layout.setVerticalGroup(
79 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
80 | .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
81 | );
82 |
83 | pack();
84 | }// //GEN-END:initComponents
85 |
86 | /**
87 | * @param args the command line arguments
88 | */
89 | public static void main(String args[]) {
90 | /* Set the Nimbus look and feel */
91 | //
92 | /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
93 | * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
94 | */
95 | try {
96 | for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
97 | if ("Nimbus".equals(info.getName())) {
98 | javax.swing.UIManager.setLookAndFeel(info.getClassName());
99 | break;
100 | }
101 | }
102 | } catch (ClassNotFoundException ex) {
103 | java.util.logging.Logger.getLogger(MateHaciaNegras.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
104 | } catch (InstantiationException ex) {
105 | java.util.logging.Logger.getLogger(MateHaciaNegras.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
106 | } catch (IllegalAccessException ex) {
107 | java.util.logging.Logger.getLogger(MateHaciaNegras.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
108 | } catch (javax.swing.UnsupportedLookAndFeelException ex) {
109 | java.util.logging.Logger.getLogger(MateHaciaNegras.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
110 | }
111 | //
112 |
113 | /* Create and display the dialog */
114 | java.awt.EventQueue.invokeLater(new Runnable() {
115 | public void run() {
116 | MateHaciaNegras dialog = new MateHaciaNegras(new javax.swing.JFrame(), true);
117 | dialog.addWindowListener(new java.awt.event.WindowAdapter() {
118 | @Override
119 | public void windowClosing(java.awt.event.WindowEvent e) {
120 | System.exit(0);
121 | }
122 | });
123 | dialog.setVisible(true);
124 | }
125 | });
126 | }
127 |
128 | // Variables declaration - do not modify//GEN-BEGIN:variables
129 | private javax.swing.JLabel jLabel1;
130 | private javax.swing.JLabel jLabel2;
131 | private javax.swing.JPanel jPanel1;
132 | // End of variables declaration//GEN-END:variables
133 | }
134 |
--------------------------------------------------------------------------------
/src/Vista/VentanaEleccionFicha.form:
--------------------------------------------------------------------------------
1 |
2 |
3 |
87 |
--------------------------------------------------------------------------------
/src/Vista/VentanaEleccionFicha.java:
--------------------------------------------------------------------------------
1 | /*
2 | * To change this license header, choose License Headers in Project Properties.
3 | * To change this template file, choose Tools | Templates
4 | * and open the template in the editor.
5 | */
6 | package Vista;
7 |
8 | import javax.swing.ImageIcon;
9 |
10 | /**
11 | *
12 | * @author Dani
13 | */
14 | public class VentanaEleccionFicha extends javax.swing.JDialog {
15 |
16 |
17 | public VentanaEleccionFicha(java.awt.Frame parent, boolean modal) {
18 | super(parent, modal);
19 | initComponents();
20 | this.setLocationRelativeTo(null);
21 | }
22 |
23 |
24 | @SuppressWarnings("unchecked")
25 | // //GEN-BEGIN:initComponents
26 | private void initComponents() {
27 |
28 | jPanel1 = new javax.swing.JPanel();
29 | jButton1 = new javax.swing.JButton();
30 | jButton2 = new javax.swing.JButton();
31 | jButton3 = new javax.swing.JButton();
32 | jButton4 = new javax.swing.JButton();
33 |
34 | setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
35 |
36 | jPanel1.setLayout(new java.awt.GridLayout(2, 2));
37 |
38 | jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Reina.png"))); // NOI18N
39 | jButton1.addActionListener(new java.awt.event.ActionListener() {
40 | public void actionPerformed(java.awt.event.ActionEvent evt) {
41 | jButton1ActionPerformed(evt);
42 | }
43 | });
44 | jPanel1.add(jButton1);
45 |
46 | jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Alfil.png"))); // NOI18N
47 | jButton2.addActionListener(new java.awt.event.ActionListener() {
48 | public void actionPerformed(java.awt.event.ActionEvent evt) {
49 | jButton2ActionPerformed(evt);
50 | }
51 | });
52 | jPanel1.add(jButton2);
53 |
54 | jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Caballo.png"))); // NOI18N
55 | jButton3.addActionListener(new java.awt.event.ActionListener() {
56 | public void actionPerformed(java.awt.event.ActionEvent evt) {
57 | jButton3ActionPerformed(evt);
58 | }
59 | });
60 | jPanel1.add(jButton3);
61 |
62 | jButton4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Torre.png"))); // NOI18N
63 | jButton4.addActionListener(new java.awt.event.ActionListener() {
64 | public void actionPerformed(java.awt.event.ActionEvent evt) {
65 | jButton4ActionPerformed(evt);
66 | }
67 | });
68 | jPanel1.add(jButton4);
69 |
70 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
71 | getContentPane().setLayout(layout);
72 | layout.setHorizontalGroup(
73 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
74 | .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
75 | );
76 | layout.setVerticalGroup(
77 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
78 | .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
79 | );
80 |
81 | pack();
82 | }// //GEN-END:initComponents
83 |
84 | private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
85 | Controlador.Controlador.fichaElegida = "A_alfil";
86 | Controlador.Controlador.imagenElegida = (ImageIcon) jButton2.getIcon();
87 | dispose();
88 | }//GEN-LAST:event_jButton2ActionPerformed
89 |
90 | private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
91 | Controlador.Controlador.fichaElegida = "A_reina";
92 | Controlador.Controlador.imagenElegida = (ImageIcon) jButton1.getIcon();
93 | dispose();
94 | }//GEN-LAST:event_jButton1ActionPerformed
95 |
96 | private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
97 | Controlador.Controlador.fichaElegida = "A_caballo";
98 | Controlador.Controlador.imagenElegida = (ImageIcon) jButton3.getIcon();
99 | dispose();
100 | }//GEN-LAST:event_jButton3ActionPerformed
101 |
102 | private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
103 | Controlador.Controlador.fichaElegida = "A_torre";
104 | Controlador.Controlador.imagenElegida = (ImageIcon) jButton4.getIcon();
105 | dispose();
106 | }//GEN-LAST:event_jButton4ActionPerformed
107 |
108 | /**
109 | * @param args the command line arguments
110 | */
111 | public static void main(String args[]) {
112 | /* Set the Nimbus look and feel */
113 | //
114 | /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
115 | * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
116 | */
117 | try {
118 | for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
119 | if ("Nimbus".equals(info.getName())) {
120 | javax.swing.UIManager.setLookAndFeel(info.getClassName());
121 | break;
122 | }
123 | }
124 | } catch (ClassNotFoundException ex) {
125 | java.util.logging.Logger.getLogger(VentanaEleccionFicha.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
126 | } catch (InstantiationException ex) {
127 | java.util.logging.Logger.getLogger(VentanaEleccionFicha.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
128 | } catch (IllegalAccessException ex) {
129 | java.util.logging.Logger.getLogger(VentanaEleccionFicha.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
130 | } catch (javax.swing.UnsupportedLookAndFeelException ex) {
131 | java.util.logging.Logger.getLogger(VentanaEleccionFicha.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
132 | }
133 | //
134 |
135 | /* Create and display the dialog */
136 | java.awt.EventQueue.invokeLater(new Runnable() {
137 | public void run() {
138 | VentanaEleccionFicha dialog = new VentanaEleccionFicha(new javax.swing.JFrame(), true);
139 | dialog.addWindowListener(new java.awt.event.WindowAdapter() {
140 | @Override
141 | public void windowClosing(java.awt.event.WindowEvent e) {
142 | System.exit(0);
143 | }
144 | });
145 | dialog.setVisible(true);
146 | }
147 | });
148 | }
149 |
150 | // Variables declaration - do not modify//GEN-BEGIN:variables
151 | private javax.swing.JButton jButton1;
152 | private javax.swing.JButton jButton2;
153 | private javax.swing.JButton jButton3;
154 | private javax.swing.JButton jButton4;
155 | private javax.swing.JPanel jPanel1;
156 | // End of variables declaration//GEN-END:variables
157 | }
158 |
--------------------------------------------------------------------------------
/src/Vista/VistaTablero.form:
--------------------------------------------------------------------------------
1 |
2 |
3 |
1207 |
--------------------------------------------------------------------------------
/src/Vista/VistaTablero.java:
--------------------------------------------------------------------------------
1 | /*
2 | * To change this license header, choose License Headers in Project Properties.
3 | * To change this template file, choose Tools | Templates
4 | * and open the template in the editor.
5 | */
6 | package Vista;
7 |
8 | import Controlador.Controlador;
9 |
10 | /**
11 | *
12 | * @author Dani
13 | */
14 | public class VistaTablero extends javax.swing.JFrame {
15 |
16 | /**
17 | * Creates new form VistaTablero
18 | */
19 | public VistaTablero() {
20 | initComponents();
21 | //this.setSize(900, 920);
22 | this.setLocationRelativeTo(null);
23 | this.setTitle("Ajedrez");
24 | }
25 |
26 | /**
27 | * This method is called from within the constructor to initialize the form.
28 | * WARNING: Do NOT modify this code. The content of this method is always
29 | * regenerated by the Form Editor.
30 | */
31 | @SuppressWarnings("unchecked")
32 | // //GEN-BEGIN:initComponents
33 | private void initComponents() {
34 |
35 | jPanel1 = new javax.swing.JPanel();
36 | c00 = new javax.swing.JButton();
37 | c01 = new javax.swing.JButton();
38 | c02 = new javax.swing.JButton();
39 | c03 = new javax.swing.JButton();
40 | c04 = new javax.swing.JButton();
41 | c05 = new javax.swing.JButton();
42 | c06 = new javax.swing.JButton();
43 | c07 = new javax.swing.JButton();
44 | c10 = new javax.swing.JButton();
45 | c11 = new javax.swing.JButton();
46 | c12 = new javax.swing.JButton();
47 | c13 = new javax.swing.JButton();
48 | c14 = new javax.swing.JButton();
49 | c15 = new javax.swing.JButton();
50 | c16 = new javax.swing.JButton();
51 | c17 = new javax.swing.JButton();
52 | c20 = new javax.swing.JButton();
53 | c21 = new javax.swing.JButton();
54 | c22 = new javax.swing.JButton();
55 | c23 = new javax.swing.JButton();
56 | c24 = new javax.swing.JButton();
57 | c25 = new javax.swing.JButton();
58 | c26 = new javax.swing.JButton();
59 | c27 = new javax.swing.JButton();
60 | c30 = new javax.swing.JButton();
61 | c31 = new javax.swing.JButton();
62 | c32 = new javax.swing.JButton();
63 | c33 = new javax.swing.JButton();
64 | c34 = new javax.swing.JButton();
65 | c35 = new javax.swing.JButton();
66 | c36 = new javax.swing.JButton();
67 | c37 = new javax.swing.JButton();
68 | c40 = new javax.swing.JButton();
69 | c41 = new javax.swing.JButton();
70 | c42 = new javax.swing.JButton();
71 | c43 = new javax.swing.JButton();
72 | c44 = new javax.swing.JButton();
73 | c45 = new javax.swing.JButton();
74 | c46 = new javax.swing.JButton();
75 | c47 = new javax.swing.JButton();
76 | c50 = new javax.swing.JButton();
77 | c51 = new javax.swing.JButton();
78 | c52 = new javax.swing.JButton();
79 | c53 = new javax.swing.JButton();
80 | c54 = new javax.swing.JButton();
81 | c55 = new javax.swing.JButton();
82 | c56 = new javax.swing.JButton();
83 | c57 = new javax.swing.JButton();
84 | c60 = new javax.swing.JButton();
85 | c61 = new javax.swing.JButton();
86 | c62 = new javax.swing.JButton();
87 | c63 = new javax.swing.JButton();
88 | c64 = new javax.swing.JButton();
89 | c65 = new javax.swing.JButton();
90 | c66 = new javax.swing.JButton();
91 | c67 = new javax.swing.JButton();
92 | c70 = new javax.swing.JButton();
93 | c71 = new javax.swing.JButton();
94 | c72 = new javax.swing.JButton();
95 | c73 = new javax.swing.JButton();
96 | c74 = new javax.swing.JButton();
97 | c75 = new javax.swing.JButton();
98 | c76 = new javax.swing.JButton();
99 | c77 = new javax.swing.JButton();
100 | jMenuBar1 = new javax.swing.JMenuBar();
101 | jMenu1 = new javax.swing.JMenu();
102 | jMenuItem1 = new javax.swing.JMenuItem();
103 | jMenu2 = new javax.swing.JMenu();
104 | jMenuItem2 = new javax.swing.JMenuItem();
105 |
106 | setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
107 |
108 | jPanel1.setLayout(new java.awt.GridLayout(8, 8));
109 |
110 | c00.setBackground(new java.awt.Color(255, 255, 255));
111 | c00.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/TorreNegra.png"))); // NOI18N
112 | c00.setToolTipText("");
113 | c00.setBorder(javax.swing.BorderFactory.createEtchedBorder());
114 | jPanel1.add(c00);
115 |
116 | c01.setBackground(new java.awt.Color(51, 51, 51));
117 | c01.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/CaballoNegro.png"))); // NOI18N
118 | c01.setToolTipText("");
119 | c01.setBorder(javax.swing.BorderFactory.createEtchedBorder());
120 | jPanel1.add(c01);
121 |
122 | c02.setBackground(new java.awt.Color(255, 255, 255));
123 | c02.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/AlfilNegro.png"))); // NOI18N
124 | c02.setToolTipText("");
125 | c02.setBorder(javax.swing.BorderFactory.createEtchedBorder());
126 | jPanel1.add(c02);
127 |
128 | c03.setBackground(new java.awt.Color(51, 51, 51));
129 | c03.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/ReinaNegra.png"))); // NOI18N
130 | c03.setToolTipText("");
131 | c03.setBorder(javax.swing.BorderFactory.createEtchedBorder());
132 | jPanel1.add(c03);
133 |
134 | c04.setBackground(new java.awt.Color(255, 255, 255));
135 | c04.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/ReyNegro.png"))); // NOI18N
136 | c04.setToolTipText("");
137 | c04.setBorder(javax.swing.BorderFactory.createEtchedBorder());
138 | jPanel1.add(c04);
139 |
140 | c05.setBackground(new java.awt.Color(51, 51, 51));
141 | c05.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/AlfilNegro.png"))); // NOI18N
142 | c05.setToolTipText("");
143 | c05.setBorder(javax.swing.BorderFactory.createEtchedBorder());
144 | jPanel1.add(c05);
145 |
146 | c06.setBackground(new java.awt.Color(255, 255, 255));
147 | c06.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/CaballoNegro.png"))); // NOI18N
148 | c06.setToolTipText("");
149 | c06.setBorder(javax.swing.BorderFactory.createEtchedBorder());
150 | jPanel1.add(c06);
151 |
152 | c07.setBackground(new java.awt.Color(51, 51, 51));
153 | c07.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/TorreNegra.png"))); // NOI18N
154 | c07.setToolTipText("");
155 | c07.setBorder(javax.swing.BorderFactory.createEtchedBorder());
156 | jPanel1.add(c07);
157 |
158 | c10.setBackground(new java.awt.Color(51, 51, 51));
159 | c10.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Ficha PeonNegra.png"))); // NOI18N
160 | c10.setToolTipText("");
161 | c10.setBorder(javax.swing.BorderFactory.createEtchedBorder());
162 | jPanel1.add(c10);
163 |
164 | c11.setBackground(new java.awt.Color(255, 255, 255));
165 | c11.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Ficha PeonNegra.png"))); // NOI18N
166 | c11.setToolTipText("");
167 | c11.setBorder(javax.swing.BorderFactory.createEtchedBorder());
168 | jPanel1.add(c11);
169 |
170 | c12.setBackground(new java.awt.Color(51, 51, 51));
171 | c12.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Ficha PeonNegra.png"))); // NOI18N
172 | c12.setToolTipText("");
173 | c12.setBorder(javax.swing.BorderFactory.createEtchedBorder());
174 | jPanel1.add(c12);
175 |
176 | c13.setBackground(new java.awt.Color(255, 255, 255));
177 | c13.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Ficha PeonNegra.png"))); // NOI18N
178 | c13.setToolTipText("");
179 | c13.setBorder(javax.swing.BorderFactory.createEtchedBorder());
180 | jPanel1.add(c13);
181 |
182 | c14.setBackground(new java.awt.Color(51, 51, 51));
183 | c14.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Ficha PeonNegra.png"))); // NOI18N
184 | c14.setToolTipText("");
185 | c14.setBorder(javax.swing.BorderFactory.createEtchedBorder());
186 | jPanel1.add(c14);
187 |
188 | c15.setBackground(new java.awt.Color(255, 255, 255));
189 | c15.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Ficha PeonNegra.png"))); // NOI18N
190 | c15.setToolTipText("");
191 | c15.setBorder(javax.swing.BorderFactory.createEtchedBorder());
192 | jPanel1.add(c15);
193 |
194 | c16.setBackground(new java.awt.Color(51, 51, 51));
195 | c16.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Ficha PeonNegra.png"))); // NOI18N
196 | c16.setToolTipText("");
197 | c16.setBorder(javax.swing.BorderFactory.createEtchedBorder());
198 | jPanel1.add(c16);
199 |
200 | c17.setBackground(new java.awt.Color(255, 255, 255));
201 | c17.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Ficha PeonNegra.png"))); // NOI18N
202 | c17.setToolTipText("");
203 | c17.setBorder(javax.swing.BorderFactory.createEtchedBorder());
204 | jPanel1.add(c17);
205 |
206 | c20.setBackground(new java.awt.Color(255, 255, 255));
207 | c20.setToolTipText("");
208 | c20.setBorder(javax.swing.BorderFactory.createEtchedBorder());
209 | jPanel1.add(c20);
210 |
211 | c21.setBackground(new java.awt.Color(51, 51, 51));
212 | c21.setToolTipText("");
213 | c21.setBorder(javax.swing.BorderFactory.createEtchedBorder());
214 | jPanel1.add(c21);
215 |
216 | c22.setBackground(new java.awt.Color(255, 255, 255));
217 | c22.setToolTipText("");
218 | c22.setBorder(javax.swing.BorderFactory.createEtchedBorder());
219 | jPanel1.add(c22);
220 |
221 | c23.setBackground(new java.awt.Color(51, 51, 51));
222 | c23.setToolTipText("");
223 | c23.setBorder(javax.swing.BorderFactory.createEtchedBorder());
224 | jPanel1.add(c23);
225 |
226 | c24.setBackground(new java.awt.Color(255, 255, 255));
227 | c24.setToolTipText("");
228 | c24.setBorder(javax.swing.BorderFactory.createEtchedBorder());
229 | jPanel1.add(c24);
230 |
231 | c25.setBackground(new java.awt.Color(51, 51, 51));
232 | c25.setToolTipText("");
233 | c25.setBorder(javax.swing.BorderFactory.createEtchedBorder());
234 | jPanel1.add(c25);
235 |
236 | c26.setBackground(new java.awt.Color(255, 255, 255));
237 | c26.setToolTipText("");
238 | c26.setBorder(javax.swing.BorderFactory.createEtchedBorder());
239 | jPanel1.add(c26);
240 |
241 | c27.setBackground(new java.awt.Color(51, 51, 51));
242 | c27.setToolTipText("");
243 | c27.setBorder(javax.swing.BorderFactory.createEtchedBorder());
244 | jPanel1.add(c27);
245 |
246 | c30.setBackground(new java.awt.Color(51, 51, 51));
247 | c30.setToolTipText("");
248 | c30.setBorder(javax.swing.BorderFactory.createEtchedBorder());
249 | jPanel1.add(c30);
250 |
251 | c31.setBackground(new java.awt.Color(255, 255, 255));
252 | c31.setToolTipText("");
253 | c31.setBorder(javax.swing.BorderFactory.createEtchedBorder());
254 | jPanel1.add(c31);
255 |
256 | c32.setBackground(new java.awt.Color(51, 51, 51));
257 | c32.setToolTipText("");
258 | c32.setBorder(javax.swing.BorderFactory.createEtchedBorder());
259 | jPanel1.add(c32);
260 |
261 | c33.setBackground(new java.awt.Color(255, 255, 255));
262 | c33.setToolTipText("");
263 | c33.setBorder(javax.swing.BorderFactory.createEtchedBorder());
264 | jPanel1.add(c33);
265 |
266 | c34.setBackground(new java.awt.Color(51, 51, 51));
267 | c34.setToolTipText("");
268 | c34.setBorder(javax.swing.BorderFactory.createEtchedBorder());
269 | jPanel1.add(c34);
270 |
271 | c35.setBackground(new java.awt.Color(255, 255, 255));
272 | c35.setToolTipText("");
273 | c35.setBorder(javax.swing.BorderFactory.createEtchedBorder());
274 | jPanel1.add(c35);
275 |
276 | c36.setBackground(new java.awt.Color(51, 51, 51));
277 | c36.setToolTipText("");
278 | c36.setBorder(javax.swing.BorderFactory.createEtchedBorder());
279 | jPanel1.add(c36);
280 |
281 | c37.setBackground(new java.awt.Color(255, 255, 255));
282 | c37.setToolTipText("");
283 | c37.setBorder(javax.swing.BorderFactory.createEtchedBorder());
284 | jPanel1.add(c37);
285 |
286 | c40.setBackground(new java.awt.Color(255, 255, 255));
287 | c40.setToolTipText("");
288 | c40.setBorder(javax.swing.BorderFactory.createEtchedBorder());
289 | jPanel1.add(c40);
290 |
291 | c41.setBackground(new java.awt.Color(51, 51, 51));
292 | c41.setToolTipText("");
293 | c41.setBorder(javax.swing.BorderFactory.createEtchedBorder());
294 | jPanel1.add(c41);
295 |
296 | c42.setBackground(new java.awt.Color(255, 255, 255));
297 | c42.setToolTipText("");
298 | c42.setBorder(javax.swing.BorderFactory.createEtchedBorder());
299 | jPanel1.add(c42);
300 |
301 | c43.setBackground(new java.awt.Color(51, 51, 51));
302 | c43.setToolTipText("");
303 | c43.setBorder(javax.swing.BorderFactory.createEtchedBorder());
304 | jPanel1.add(c43);
305 |
306 | c44.setBackground(new java.awt.Color(255, 255, 255));
307 | c44.setToolTipText("");
308 | c44.setBorder(javax.swing.BorderFactory.createEtchedBorder());
309 | jPanel1.add(c44);
310 |
311 | c45.setBackground(new java.awt.Color(51, 51, 51));
312 | c45.setToolTipText("");
313 | c45.setBorder(javax.swing.BorderFactory.createEtchedBorder());
314 | jPanel1.add(c45);
315 |
316 | c46.setBackground(new java.awt.Color(255, 255, 255));
317 | c46.setToolTipText("");
318 | c46.setBorder(javax.swing.BorderFactory.createEtchedBorder());
319 | jPanel1.add(c46);
320 |
321 | c47.setBackground(new java.awt.Color(51, 51, 51));
322 | c47.setToolTipText("");
323 | c47.setBorder(javax.swing.BorderFactory.createEtchedBorder());
324 | jPanel1.add(c47);
325 |
326 | c50.setBackground(new java.awt.Color(51, 51, 51));
327 | c50.setToolTipText("");
328 | c50.setBorder(javax.swing.BorderFactory.createEtchedBorder());
329 | jPanel1.add(c50);
330 |
331 | c51.setBackground(new java.awt.Color(255, 255, 255));
332 | c51.setToolTipText("");
333 | c51.setBorder(javax.swing.BorderFactory.createEtchedBorder());
334 | jPanel1.add(c51);
335 |
336 | c52.setBackground(new java.awt.Color(51, 51, 51));
337 | c52.setToolTipText("");
338 | c52.setBorder(javax.swing.BorderFactory.createEtchedBorder());
339 | jPanel1.add(c52);
340 |
341 | c53.setBackground(new java.awt.Color(255, 255, 255));
342 | c53.setToolTipText("");
343 | c53.setBorder(javax.swing.BorderFactory.createEtchedBorder());
344 | jPanel1.add(c53);
345 |
346 | c54.setBackground(new java.awt.Color(51, 51, 51));
347 | c54.setToolTipText("");
348 | c54.setBorder(javax.swing.BorderFactory.createEtchedBorder());
349 | jPanel1.add(c54);
350 |
351 | c55.setBackground(new java.awt.Color(255, 255, 255));
352 | c55.setToolTipText("");
353 | c55.setBorder(javax.swing.BorderFactory.createEtchedBorder());
354 | jPanel1.add(c55);
355 |
356 | c56.setBackground(new java.awt.Color(51, 51, 51));
357 | c56.setToolTipText("");
358 | c56.setBorder(javax.swing.BorderFactory.createEtchedBorder());
359 | jPanel1.add(c56);
360 |
361 | c57.setBackground(new java.awt.Color(255, 255, 255));
362 | c57.setToolTipText("");
363 | c57.setBorder(javax.swing.BorderFactory.createEtchedBorder());
364 | jPanel1.add(c57);
365 |
366 | c60.setBackground(new java.awt.Color(255, 255, 255));
367 | c60.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Ficha Peon.png"))); // NOI18N
368 | c60.setToolTipText("");
369 | c60.setBorder(javax.swing.BorderFactory.createEtchedBorder());
370 | jPanel1.add(c60);
371 |
372 | c61.setBackground(new java.awt.Color(51, 51, 51));
373 | c61.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Ficha Peon.png"))); // NOI18N
374 | c61.setToolTipText("");
375 | c61.setBorder(javax.swing.BorderFactory.createEtchedBorder());
376 | jPanel1.add(c61);
377 |
378 | c62.setBackground(new java.awt.Color(255, 255, 255));
379 | c62.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Ficha Peon.png"))); // NOI18N
380 | c62.setToolTipText("");
381 | c62.setBorder(javax.swing.BorderFactory.createEtchedBorder());
382 | jPanel1.add(c62);
383 |
384 | c63.setBackground(new java.awt.Color(51, 51, 51));
385 | c63.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Ficha Peon.png"))); // NOI18N
386 | c63.setToolTipText("");
387 | c63.setBorder(javax.swing.BorderFactory.createEtchedBorder());
388 | jPanel1.add(c63);
389 |
390 | c64.setBackground(new java.awt.Color(255, 255, 255));
391 | c64.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Ficha Peon.png"))); // NOI18N
392 | c64.setToolTipText("");
393 | c64.setBorder(javax.swing.BorderFactory.createEtchedBorder());
394 | jPanel1.add(c64);
395 |
396 | c65.setBackground(new java.awt.Color(51, 51, 51));
397 | c65.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Ficha Peon.png"))); // NOI18N
398 | c65.setToolTipText("");
399 | c65.setBorder(javax.swing.BorderFactory.createEtchedBorder());
400 | jPanel1.add(c65);
401 |
402 | c66.setBackground(new java.awt.Color(255, 255, 255));
403 | c66.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Ficha Peon.png"))); // NOI18N
404 | c66.setToolTipText("");
405 | c66.setBorder(javax.swing.BorderFactory.createEtchedBorder());
406 | jPanel1.add(c66);
407 |
408 | c67.setBackground(new java.awt.Color(51, 51, 51));
409 | c67.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Ficha Peon.png"))); // NOI18N
410 | c67.setToolTipText("");
411 | c67.setBorder(javax.swing.BorderFactory.createEtchedBorder());
412 | jPanel1.add(c67);
413 |
414 | c70.setBackground(new java.awt.Color(51, 51, 51));
415 | c70.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Torre.png"))); // NOI18N
416 | c70.setToolTipText("");
417 | c70.setBorder(javax.swing.BorderFactory.createEtchedBorder());
418 | jPanel1.add(c70);
419 |
420 | c71.setBackground(new java.awt.Color(255, 255, 255));
421 | c71.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Caballo.png"))); // NOI18N
422 | c71.setToolTipText("");
423 | c71.setBorder(javax.swing.BorderFactory.createEtchedBorder());
424 | jPanel1.add(c71);
425 |
426 | c72.setBackground(new java.awt.Color(51, 51, 51));
427 | c72.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Alfil.png"))); // NOI18N
428 | c72.setToolTipText("");
429 | c72.setBorder(javax.swing.BorderFactory.createEtchedBorder());
430 | jPanel1.add(c72);
431 |
432 | c73.setBackground(new java.awt.Color(255, 255, 255));
433 | c73.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Reina.png"))); // NOI18N
434 | c73.setToolTipText("");
435 | c73.setBorder(javax.swing.BorderFactory.createEtchedBorder());
436 | jPanel1.add(c73);
437 |
438 | c74.setBackground(new java.awt.Color(51, 51, 51));
439 | c74.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Rey.png"))); // NOI18N
440 | c74.setToolTipText("");
441 | c74.setBorder(javax.swing.BorderFactory.createEtchedBorder());
442 | jPanel1.add(c74);
443 |
444 | c75.setBackground(new java.awt.Color(255, 255, 255));
445 | c75.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Alfil.png"))); // NOI18N
446 | c75.setToolTipText("");
447 | c75.setBorder(javax.swing.BorderFactory.createEtchedBorder());
448 | jPanel1.add(c75);
449 |
450 | c76.setBackground(new java.awt.Color(51, 51, 51));
451 | c76.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Caballo.png"))); // NOI18N
452 | c76.setToolTipText("");
453 | c76.setBorder(javax.swing.BorderFactory.createEtchedBorder());
454 | jPanel1.add(c76);
455 |
456 | c77.setBackground(new java.awt.Color(255, 255, 255));
457 | c77.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Torre.png"))); // NOI18N
458 | c77.setToolTipText("");
459 | c77.setBorder(javax.swing.BorderFactory.createEtchedBorder());
460 | jPanel1.add(c77);
461 |
462 | jMenu1.setText("Restart");
463 | jMenu1.addActionListener(new java.awt.event.ActionListener() {
464 | public void actionPerformed(java.awt.event.ActionEvent evt) {
465 | jMenu1ActionPerformed(evt);
466 | }
467 | });
468 |
469 | jMenuItem1.setText("Aceptar");
470 | jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
471 | public void actionPerformed(java.awt.event.ActionEvent evt) {
472 | jMenuItem1ActionPerformed(evt);
473 | }
474 | });
475 | jMenu1.add(jMenuItem1);
476 |
477 | jMenuBar1.add(jMenu1);
478 |
479 | jMenu2.setText("Exit");
480 |
481 | jMenuItem2.setText("Aceptar");
482 | jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
483 | public void actionPerformed(java.awt.event.ActionEvent evt) {
484 | jMenuItem2ActionPerformed(evt);
485 | }
486 | });
487 | jMenu2.add(jMenuItem2);
488 |
489 | jMenuBar1.add(jMenu2);
490 |
491 | setJMenuBar(jMenuBar1);
492 |
493 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
494 | getContentPane().setLayout(layout);
495 | layout.setHorizontalGroup(
496 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
497 | .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
498 | );
499 | layout.setVerticalGroup(
500 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
501 | .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
502 | );
503 |
504 | pack();
505 | }// //GEN-END:initComponents
506 |
507 | private void jMenu1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenu1ActionPerformed
508 |
509 | }//GEN-LAST:event_jMenu1ActionPerformed
510 |
511 | private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
512 | dispose();
513 | Controlador controlador = new Controlador();
514 | }//GEN-LAST:event_jMenuItem1ActionPerformed
515 |
516 | private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
517 | System.exit(0);
518 | }//GEN-LAST:event_jMenuItem2ActionPerformed
519 |
520 | /**
521 | * @param args the command line arguments
522 | */
523 | public static void main(String args[]) {
524 | /* Set the Nimbus look and feel */
525 | //
526 | /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
527 | * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
528 | */
529 | try {
530 | for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
531 | if ("Nimbus".equals(info.getName())) {
532 | javax.swing.UIManager.setLookAndFeel(info.getClassName());
533 | break;
534 | }
535 | }
536 | } catch (ClassNotFoundException ex) {
537 | java.util.logging.Logger.getLogger(VistaTablero.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
538 | } catch (InstantiationException ex) {
539 | java.util.logging.Logger.getLogger(VistaTablero.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
540 | } catch (IllegalAccessException ex) {
541 | java.util.logging.Logger.getLogger(VistaTablero.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
542 | } catch (javax.swing.UnsupportedLookAndFeelException ex) {
543 | java.util.logging.Logger.getLogger(VistaTablero.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
544 | }
545 | //
546 |
547 | /* Create and display the form */
548 | java.awt.EventQueue.invokeLater(new Runnable() {
549 | public void run() {
550 | new VistaTablero().setVisible(true);
551 | }
552 | });
553 | }
554 |
555 | // Variables declaration - do not modify//GEN-BEGIN:variables
556 | public static javax.swing.JButton c00;
557 | public static javax.swing.JButton c01;
558 | public static javax.swing.JButton c02;
559 | public static javax.swing.JButton c03;
560 | public static javax.swing.JButton c04;
561 | public static javax.swing.JButton c05;
562 | public static javax.swing.JButton c06;
563 | public static javax.swing.JButton c07;
564 | public static javax.swing.JButton c10;
565 | public static javax.swing.JButton c11;
566 | public static javax.swing.JButton c12;
567 | public static javax.swing.JButton c13;
568 | public static javax.swing.JButton c14;
569 | public static javax.swing.JButton c15;
570 | public static javax.swing.JButton c16;
571 | public static javax.swing.JButton c17;
572 | public static javax.swing.JButton c20;
573 | public static javax.swing.JButton c21;
574 | public static javax.swing.JButton c22;
575 | public static javax.swing.JButton c23;
576 | public static javax.swing.JButton c24;
577 | public static javax.swing.JButton c25;
578 | public static javax.swing.JButton c26;
579 | public static javax.swing.JButton c27;
580 | public static javax.swing.JButton c30;
581 | public static javax.swing.JButton c31;
582 | public static javax.swing.JButton c32;
583 | public static javax.swing.JButton c33;
584 | public static javax.swing.JButton c34;
585 | public static javax.swing.JButton c35;
586 | public static javax.swing.JButton c36;
587 | public static javax.swing.JButton c37;
588 | public static javax.swing.JButton c40;
589 | public static javax.swing.JButton c41;
590 | public static javax.swing.JButton c42;
591 | public static javax.swing.JButton c43;
592 | public static javax.swing.JButton c44;
593 | public static javax.swing.JButton c45;
594 | public static javax.swing.JButton c46;
595 | public static javax.swing.JButton c47;
596 | public static javax.swing.JButton c50;
597 | public static javax.swing.JButton c51;
598 | public static javax.swing.JButton c52;
599 | public static javax.swing.JButton c53;
600 | public static javax.swing.JButton c54;
601 | public static javax.swing.JButton c55;
602 | public static javax.swing.JButton c56;
603 | public static javax.swing.JButton c57;
604 | public static javax.swing.JButton c60;
605 | public static javax.swing.JButton c61;
606 | public static javax.swing.JButton c62;
607 | public static javax.swing.JButton c63;
608 | public static javax.swing.JButton c64;
609 | public static javax.swing.JButton c65;
610 | public static javax.swing.JButton c66;
611 | public static javax.swing.JButton c67;
612 | public static javax.swing.JButton c70;
613 | public static javax.swing.JButton c71;
614 | public static javax.swing.JButton c72;
615 | public static javax.swing.JButton c73;
616 | public static javax.swing.JButton c74;
617 | public static javax.swing.JButton c75;
618 | public static javax.swing.JButton c76;
619 | public static javax.swing.JButton c77;
620 | private javax.swing.JMenu jMenu1;
621 | private javax.swing.JMenu jMenu2;
622 | private javax.swing.JMenuBar jMenuBar1;
623 | private javax.swing.JMenuItem jMenuItem1;
624 | private javax.swing.JMenuItem jMenuItem2;
625 | private javax.swing.JPanel jPanel1;
626 | // End of variables declaration//GEN-END:variables
627 | }
628 |
--------------------------------------------------------------------------------