From 91da7823ad0e6b30e8eb87b738a56519e4fbafb3 Mon Sep 17 00:00:00 2001 From: "basile.blanchard" Date: Tue, 22 Apr 2025 15:49:04 +0200 Subject: [PATCH] final deposit --- .DS_Store | Bin 0 -> 6148 bytes .classpath | 10 + .project | 17 + .settings/org.eclipse.core.resources.prefs | 2 + .settings/org.eclipse.jdt.core.prefs | 11 + bin/.DS_Store | Bin 0 -> 6148 bytes bin/Main.class | Bin 0 -> 808 bytes bin/backend/AutoPlayer.class | Bin 0 -> 417 bytes bin/backend/Board$Position.class | Bin 0 -> 828 bytes bin/backend/Board.class | Bin 0 -> 10760 bytes bin/backend/ChessTimer$1.class | Bin 0 -> 571 bytes .../ChessTimer$TimerUpdateListener.class | Bin 0 -> 287 bytes bin/backend/ChessTimer.class | Bin 0 -> 2838 bytes bin/backend/Game$1.class | Bin 0 -> 974 bytes bin/backend/Game.class | Bin 0 -> 5241 bytes bin/backend/Move.class | Bin 0 -> 2650 bytes bin/backend/MoveHistory.class | Bin 0 -> 1027 bytes bin/backend/Piece.class | Bin 0 -> 913 bytes bin/backend/PieceType.class | Bin 0 -> 1572 bytes bin/windowInterface/JPanelChessBoard$1.class | Bin 0 -> 1835 bytes bin/windowInterface/JPanelChessBoard.class | Bin 0 -> 5339 bytes bin/windowInterface/MyInterface$1.class | Bin 0 -> 730 bytes bin/windowInterface/MyInterface$10.class | Bin 0 -> 744 bytes bin/windowInterface/MyInterface$2.class | Bin 0 -> 742 bytes bin/windowInterface/MyInterface$3.class | Bin 0 -> 737 bytes bin/windowInterface/MyInterface$4.class | Bin 0 -> 740 bytes bin/windowInterface/MyInterface$5.class | Bin 0 -> 742 bytes bin/windowInterface/MyInterface$6.class | Bin 0 -> 738 bytes bin/windowInterface/MyInterface$7.class | Bin 0 -> 741 bytes bin/windowInterface/MyInterface$8.class | Bin 0 -> 736 bytes bin/windowInterface/MyInterface$9.class | Bin 0 -> 742 bytes bin/windowInterface/MyInterface.class | Bin 0 -> 11814 bytes default.board | 9 + pieces.png | Bin 0 -> 954 bytes src/.DS_Store | Bin 0 -> 6148 bytes src/Main.java | 19 + src/backend/AutoPlayer.java | 10 + src/backend/Board.java | 621 ++++++++++++++++++ src/backend/ChessTimer.java | 166 +++++ src/backend/Game.java | 220 +++++++ src/backend/Move.java | 64 ++ src/backend/MoveHistory.java | 55 ++ src/backend/Piece.java | 36 + src/backend/PieceType.java | 26 + src/windowInterface/JPanelChessBoard.java | 196 ++++++ src/windowInterface/MyInterface.java | 387 +++++++++++ 46 files changed, 1849 insertions(+) create mode 100644 .DS_Store create mode 100644 .classpath create mode 100644 .project create mode 100644 .settings/org.eclipse.core.resources.prefs create mode 100644 .settings/org.eclipse.jdt.core.prefs create mode 100644 bin/.DS_Store create mode 100644 bin/Main.class create mode 100644 bin/backend/AutoPlayer.class create mode 100644 bin/backend/Board$Position.class create mode 100644 bin/backend/Board.class create mode 100644 bin/backend/ChessTimer$1.class create mode 100644 bin/backend/ChessTimer$TimerUpdateListener.class create mode 100644 bin/backend/ChessTimer.class create mode 100644 bin/backend/Game$1.class create mode 100644 bin/backend/Game.class create mode 100644 bin/backend/Move.class create mode 100644 bin/backend/MoveHistory.class create mode 100644 bin/backend/Piece.class create mode 100644 bin/backend/PieceType.class create mode 100644 bin/windowInterface/JPanelChessBoard$1.class create mode 100644 bin/windowInterface/JPanelChessBoard.class create mode 100644 bin/windowInterface/MyInterface$1.class create mode 100644 bin/windowInterface/MyInterface$10.class create mode 100644 bin/windowInterface/MyInterface$2.class create mode 100644 bin/windowInterface/MyInterface$3.class create mode 100644 bin/windowInterface/MyInterface$4.class create mode 100644 bin/windowInterface/MyInterface$5.class create mode 100644 bin/windowInterface/MyInterface$6.class create mode 100644 bin/windowInterface/MyInterface$7.class create mode 100644 bin/windowInterface/MyInterface$8.class create mode 100644 bin/windowInterface/MyInterface$9.class create mode 100644 bin/windowInterface/MyInterface.class create mode 100644 default.board create mode 100644 pieces.png create mode 100644 src/.DS_Store create mode 100644 src/Main.java create mode 100644 src/backend/AutoPlayer.java create mode 100644 src/backend/Board.java create mode 100644 src/backend/ChessTimer.java create mode 100644 src/backend/Game.java create mode 100644 src/backend/Move.java create mode 100644 src/backend/MoveHistory.java create mode 100644 src/backend/Piece.java create mode 100644 src/backend/PieceType.java create mode 100644 src/windowInterface/JPanelChessBoard.java create mode 100644 src/windowInterface/MyInterface.java diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..81d1c9ef34b0e751f25257965d140ef88ca2f662 GIT binary patch literal 6148 zcmeHK!AiqG5Z!I6O(;SR3OxqA7OZV4h?fxS4;aydN=;1BV9ZLAnnNk%tUu(J_&v_- zZpB)qH<3C6vu}2GCShK}?ha#&dy{CNF`F@Ff+E%|7`_o)M_rPd_S6A6J|lk&6A{Af zHGEu(CdXf70Kc8VLKd?$EI)t0B+iRY=Z)8l`o?C%Y?w{+%D)q(Uj)S@_k!#KXQx6W z;oJ_wvv^#N?Cm3w7D1ejGno)aV+grCkJCt$o|vRjE^~dgU|Oa%vRl(>chG4&z5Za< zcBThiu=~BiY-X7|yL*Qxqx<9`70-%74u6}JEsb+{0Yg{w + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..14798d9 --- /dev/null +++ b/.project @@ -0,0 +1,17 @@ + + + Project_2 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..9a7984b --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=21 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=21 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=21 diff --git a/bin/.DS_Store b/bin/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..dbc1dc901c0e38412af0d87130e46c54667025a4 GIT binary patch literal 6148 zcmeHK!AiqG5S_KrrWUaWg&qT53)Z$2#7l_v;MIs8RBB?PhQ@4ZQ*$VVob`wN62Hfp z-7VNw5ig>42WH>w&Q8KS*x4NbV9qGm1E>IiiArd!zc z-;Wn|>jlk#X5hCmKxelIK6r2gJ$QG1xsRR~zaK}#v|fK@D+Ob9t!Ng_vU%m+^UO`X zbTo9l!3E7uIgkCR?fGX>m~|^#hdfEWC zm})+l`ZH4<3KM_F?^|L!Fk7M?H3OP~Sq2JnTA};@==1)6Hb~Dj1Db(<#Q-xpZpXot z)ZMy}9No1R>NP3}?aL*K5FFHXEDXAetEfWIXOV$uE6gS03W|OR2paUD8Te5K-T=Od BkwyRj literal 0 HcmV?d00001 diff --git a/bin/Main.class b/bin/Main.class new file mode 100644 index 0000000000000000000000000000000000000000..f5ea01de0f62bc5194228fdac83fed9e8986a800 GIT binary patch literal 808 zcmaJEo4;T|QF(EnB1anF2rvne*MHmU ziMC=`cqSvMo-<@!FQnX8aYxw5!g7$q0>e@uBk^WDXo=)KZ}kPk)gW&3e#jH4?|&W* z^-+!pEzn#w!WocfSam-H7o1I%$f#TMLKDjjg%)pr5>dy08S|uLqll8`Tw%z$^|}}8 zmsJPXbQOhRJRJAA5^1i58(1?@nG@7J8!0hxu#OE96OTz-dB!bc{~Zx4q8EHn)3}=s zwy@2RSMjVUh85SlT&j&7+%|EGp_Iy)hjMTSyA0+~qxVT}*}V**)p`tTr!wlqr}apQ z8QUNPS|=bwCt3=!Cf$7UjC^iyiu~6!Y?IYt zP{JZvXO=*|KsO6lutYEV^A{K?sC$m$Q88c4Pie3ACn$fzb#gZ+sGh?;nqseUU`()o xfnOm8z$VN^8l-~?VOHt1i{+GaYlchZ-AgN2$9+5?)++sbh)1c2#}vun$!}XztGNIG literal 0 HcmV?d00001 diff --git a/bin/backend/AutoPlayer.class b/bin/backend/AutoPlayer.class new file mode 100644 index 0000000000000000000000000000000000000000..c69dc033770d93a3c77b97a360fa6e4ea9d20e2d GIT binary patch literal 417 zcmZWlyH3ME5S(@FIGBI~M6`%5p}-wY5K@9fWgZeJ{nY+b0q!>DkKU%fR94# z*&!)tW^Q+9_ICIC=kp7|7=0fOVLuV+vn;Y`Tp4|ri&t6ta0$JcSc)hY#bb1v%w%c^ z?Q>Nqb3teghEsxjsWTa%g{>|;vA66K+;K zwcFtsybIp~aQMYLF!~%t%*5=Se4z7Qmjgyy1{<~+yN!T(haEd{;|s(={XGiTc~0RlbQn6Py4sj=tTBhP$z8Tk!Zu-c=5SiSaau&JQoKs^D@06T zoii3-S_SbP6^ow)ci2q$S}`w>ch)t;P|H8js^=zTSO&PUk{!qSM9CnBuG%IC=%^mM Li))N(aentF2Jw&k literal 0 HcmV?d00001 diff --git a/bin/backend/Board.class b/bin/backend/Board.class new file mode 100644 index 0000000000000000000000000000000000000000..379f5628881695d6338ae4d04020ffa92583c55f GIT binary patch literal 10760 zcmdT~dwf*onSQ=AXXZ>MClC?_2$^8GClhWC8X!>=QXr8Kga9ET$dDPxXp%`M6A^n; zi>Ph2t*yHSRtwZNuC-NBf{L}aRBgM}*50-kyV}cYx7&-_ZqZZTV(Gpn_&X;VYv6`NM9Y+g0X-Qg^~!%h2oIj6BrbekCp;2VbIm@VoF?wDmim_Z6 zQbk#CtZEGF`PXoxVy6F1N8=3Ic0;#Hys|3L86h(aKa`XS!F4cG>8V zBL9Z|WU@y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ZyCV!`Hw1o8F~_{)>~(|D-DSP0uV zm(~?S#5f=48nsx(cZ;!f7^2pD3tg|)@>o!ey-m~%-~=Qmf)~5FaKc*rIz=}|P^Oyc zzc{j)r#Hvxl!TRreSt78*7G?2bnehm^m(3hda6&->bXwbrTt~@cP8CNHHU7as;D*j ztgO|s7Kv=-P#QL4VLv?viOkSDG{attvH*iK8r`~$Kw3KLAPo})r+5RpyL59SHDvPt zB~X)>>Ln76Ga6wUP4FAME*tAG-e^JCSdVgJBhlMR^tNHKaT(Sc+lks8*lonI*GS+) z#vY=!69o)eVqQG_<3R6LN8H1I+XJ-bvA0| zUCel>gj50=*9|cJLzwQ;>}ekQWW6DVz%2*aQXuH&Lj!(PF|ALj;vjkYC$3_D%V~u; zlgCwS`_nKVXnRC$e&X@a+URlYU|7RiPdC1enFKS%fn07Ib6#cxGiI(P&P*_u*~*OH z$+SPDS|8vpig}hqR6FrC7g4@z_~C2`-%I&z_C0*Bq9t$Odm}?hJNO>P{*9=>J40x8Bb8ysOgsLUiI2pEAK*tB zZwUz|u;}f%x96Vw=+E!hH-IaYZNwPzeLffqf7ob^gi>8O5n-ii!(!NY;xD`rY3Vhl z;VxHWhNK=zRXL`__G0EayPv=Fbs6EX$6&RBp-6*a#YF;12XU;ru(8GvuNp$8 zEq&36CVdfhdEXNZxppw%UXO>;__Ls8T45+IsZ(iEEAcS$9TZTqQ6!1Qc3o_mqE7TY z86inDdm18^vWoi13w zW=8t-H1C_Q@9hr21#*FaaJrV&8|%7Uys|M5>Yay^aX$97w0xtCWzB=YgpfCKBgbGZ)FoXl4&wy# Gk!L?|dPZdc literal 0 HcmV?d00001 diff --git a/bin/backend/ChessTimer.class b/bin/backend/ChessTimer.class new file mode 100644 index 0000000000000000000000000000000000000000..a590880eb7972d1db2e8c8bba4b21797c7fe7a62 GIT binary patch literal 2838 zcma)8+fx&F6#g~|goH(qn-RHaMNJ|S1uxZriYP6}r3FMm+qxtREQC#(-H7%!wWCvC z`sRzazICQA?M$5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T( taNG#H>E}(uZrDGT@Z8Vz3OOrGFW69h{E6az#%bstf6jfzWx2CI{x8k#9^e1~ literal 0 HcmV?d00001 diff --git a/bin/backend/Game$1.class b/bin/backend/Game$1.class new file mode 100644 index 0000000000000000000000000000000000000000..9057994065deb30c7eb81b5d5bb771e47e8e79da GIT binary patch literal 974 zcmaKrU31bv6o%jBDt0z#F{O5MoGnjouew^=t2qkto(RL>SUT zf1Nry<5rnyqXMgzFy4k#LHB`{}fAc%mg;PgufXhGDHt*> zyJwgk!;xwnI3p@N9pXxaVx7Ws+fst3dKseSX0y_XV+Hp#+@}ShQ9H~rA2GSF1)Rv~Hbh9RT zyCzlTvNti6zWeP|I-*a>Dj!ukDsY*jf)c}`M~wM&Qo5fNcowS8Fu=^_ORK9%q#$&6J@I8x4-Y^Z<6|RQoRFYW|FK!9LvVYv` z_heyTxZVfb^^m8khv|!grPHeTbV0-P#i5gTk*sZm=mqrZ=1=hIFC>4^D1;?yW3&cX zMTT1L+d7tUi$)B$kqrn3M30g$Q9T1c!=3fQIo2*9x{uEjpx}e@zJNpkqHTD9hdw-k zB3VlABa{O8+dv)<;JI^bTxXZ)AR9hA>&N1AHb)hkM2g@s2@K&0wy2NL#jK%DR)&00 RJi~TO{T|cj1$7~;{0E>s%OU^( literal 0 HcmV?d00001 diff --git a/bin/backend/Game.class b/bin/backend/Game.class new file mode 100644 index 0000000000000000000000000000000000000000..162fa6ea1ce2bb6e61a455eb9798311bca18e97b GIT binary patch literal 5241 zcma)A`+F4C8Ga|b$tKGrfk1)~NCFM834wrM1cH$eZi@*b31FaTCz~M|*zBykvjnQG z+DfgqwXMBa1Zx#5y-+JkHdGL`_NKk5wY9Yu`#k*{`b%&0{m#tJZemLHd9vrsIp_P% z``zB}$m{=k;WB_u{56Ck4f=o)J8UKfTelh`W(YwI(+?R(jMli37;5bsPMOA_hEl`Y z88?oZDGjr_a{`?i$97lSH53onMv5mZ{q2piz@2bx*i5JUtdWV*UH&T11V#=W)G)t$ z)Jh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G;Gx1FS1$rQUCw| literal 0 HcmV?d00001 diff --git a/bin/backend/Move.class b/bin/backend/Move.class new file mode 100644 index 0000000000000000000000000000000000000000..c2730bdf0492f6f10b130c2a1810fdb6151ce3e2 GIT binary patch literal 2650 zcma)8T~8ZV5IxuU3$p}cFpfhAga9!H;(U-c!6a?shC&KST2szyCS>6TlD2fWb6@Ay^km6g0z2s(vT$q<51=A7b*}7!M6{xvD4Gm9n)SsI^ zMm)+=l9x)S6BTbAdkN=OBojv(al=E`jU$K~3a8wpay~Btk>oAEAKNP1P10jV$?T*8 zTx~Iq4-^tl>bv&A7~k4Rv4ZYtxQ_*eOkLkGN>-zy+b>Ofn^Mcx8#a?Rlq;53KJ*bW@F#lF$(UhxH(_aE4I}XNo+Cl3uHoP1`8;Me%tY z?1_+4aeU3xDK)1!e^wd|qgkryt(MV>;akpxGvNjW5X1NE<^R6Q7ICA+RhC>AYc|S4 z;Jly|l4;@WoE6T_N#X3A6VA>l!M%@`y|}=&k6*tycED8r44DgQLf{hNWdV%NOK|$5if%QTtt@tqqu}g3}cKpmdT3fru(L2J>=dvF0ZIpUJ7%;IB7r5t#fdsIOVl(1mk4a=D7-=pV`9F z#7pds;lB_~-F=tTrBmMgn2d8zR}b+au<9r?o-#{i5m*zO_gH+7$1}5s_!N+8>2lg@ z$Qc9oIY<^b6c(v_K%WmCUSqCD@BK${9Z&HY`OI@vtWpYL&B0OfQ|lSU5T4@&_d$Md V@Z!sk^%Y+8Bth*r_zrK7{TCpK#C`w( literal 0 HcmV?d00001 diff --git a/bin/backend/MoveHistory.class b/bin/backend/MoveHistory.class new file mode 100644 index 0000000000000000000000000000000000000000..4170f591121e85ee9a2c5b639d8fa5b0ccd6a4a1 GIT binary patch literal 1027 zcmZWn%Wl(95IvJPb>cdS(^qJDl=MZCLIOy1ld9sOA{Hq~1cG39<5;OnVn>cssh`3Z zuwhXoXeE#kYd#7w*S1n8Z0_~UoH=Li8UOkF;}?J@c&H*lSnLS%qvdq#NA9Wh!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qkn6eR7WQ+*-dH5>=92H=ZZ`QfO-df#b^6zlFWaXUgWRXn1KVnE U2EU5gyNcPfzuaNtd)EH_{|**(hyVZp literal 0 HcmV?d00001 diff --git a/bin/backend/PieceType.class b/bin/backend/PieceType.class new file mode 100644 index 0000000000000000000000000000000000000000..c969af821837dbe5c10378d3f3c3510f4637eae4 GIT binary patch literal 1572 zcmZ{kZBr9h7>4gdlHE;M5l&Mo;tNG7$%>{_#nwbbDYi&>(S^)p+Ao{9hLvQ4n?#4- z(Ld70Iy&vt>F4%8b-d3ZXvU<&49}kHoaa8z+sQxw{qYXKJ(Nt02uxJG>VY3V$?XJw z)!#ij^i9MC#-4dEyj`a#)tf87$kdaZ0JL z*cihpmaV-Xv{?O`-`>*ANoTTy`3t0Yz&+`Z@xrTje7a3$vcuYw!jE`pVqIXouhU1Z zw%@R^fucatiz4r++B{^xo&I>YE6@CDJKx`x6SS_{Z0f7Gp9;+PyYJ7iW=X?ARE z;t{Lc@3UI>TCMzGvi~F<(kTl$+$r+^xB<>n{$17%DFHk zqUHR`B3lsSGfb{bshI+3IY-)ZcC_WZXv-PVmUBT5sXC}F`v;7lRa3&X!I_)jF5f6u z|LU{AFMmRmWjZF)^7A+N;uWSfI3Jhi zfhhxVhMmAH1HR7n_e^7tPvt4g^PN7aPV*V}68o7vK`xyu=icD9bM-auI8*W0xcgC8 zQWG3+gQXc|aVGeuv}Sb4C4c)=Ax}!F+91_qpqIdXtoClo(F*P*oZoThSAHA^ZD^R* zg7)!&o}ggx!<_Ga>U?I1a}sNKKsnXCC1$9in(Sh!yb*KWl?$r8o3ZJ)_+jBwHSwWN hNe=l|Ps3rjD*BWZ&RcB%4e|eeBY3RSbFr)K-h1ffDA)i1 literal 0 HcmV?d00001 diff --git a/bin/windowInterface/JPanelChessBoard$1.class b/bin/windowInterface/JPanelChessBoard$1.class new file mode 100644 index 0000000000000000000000000000000000000000..717b32519963fb0e8d4e1032a747021d4859c9ff GIT binary patch literal 1835 zcmah~-%}e^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t=T(db83i<(U#WG#UAcDUjVt{*~xb VJ}T|}BHzH3e~P`A)f literal 0 HcmV?d00001 diff --git a/bin/windowInterface/MyInterface$1.class b/bin/windowInterface/MyInterface$1.class new file mode 100644 index 0000000000000000000000000000000000000000..9c35eb68751d0030ffc971a972d241ceaa77ade1 GIT binary patch literal 730 zcmaJ%TsCN zak65?F)S4|Y;BXc2G7U(Nz2jcQ1pq@4&R;p$ZlbGz3ZZhuMWO2%ooh7rLWRR97{Wz|K_eXttiraq@qM;QpIP&Tx!zmohrJI!-QvE*tQ zX?&)LVFt6~3g78(E7UrF;N4^HKi|#slKKwv8nb_K;~K=k0v3r~!8hWUuta)6Q4DdE1~%cN8vnmABqICni-DHoHMImzwdtn=%ekT#;`q;YNBUDWkmjkCn7rf`jEHZ z?z?ap!gGGbql~LG`ZPWliE+_j*ebhxW+HJVl!^L@ky^#FFhYr(p<$-7Xzvp+u9(py z;Crd0`M}WXR3djr49-ALga?Kv0bDHjsG}LcL ?SU@wDN*rHaj75IR$C+SQigm)X z5znQq=S|0oqlr}m$v&xT^3vC5T93{z#Drm|6aUxxfn7sycjRLYFI=oMY*ZKzuz^j6 zAjxFXAD-$owPKylS!t8!DQ#}EY7m2eqA&AAe3bUf@Sls@v-(K-fl4x6NR=K5Gu0$L z7%IA(LB@+hko|>YQJ6zr7_?}mb&5w|VQ4o?zetV3gHPSZl)afgc5Ph43I5CE}EtEhhDJ6$ANElVziV!F&B9dDURJm`QrP<0|SKduqeijlR z5(j<&KML_SjerZm(yV7jZ{EC_-5)={eFyLgj{;N#HZQc96clSDKRS5)+wV(fx4S&+kMI=>5?vc z1U}bByB8$wEk*8(1Zsm~qM8u65g|Y$L=~+FO~eA#o(Hs2ZPelHbgarFInI^9YFcD6 zAIVbtc#*7maRQxX4ZFJ(7g;Brx|(ewu-!}lHTk~Z!rsm(L>u=4+!feZGIxXxFM4Hm zHX;9z3(zt@(x((GXr2GG5eVNEvoce!wVyHm>)xJtfn3DC$@0STeh!qI7StXM4KHSp zOKTNpZyYM?-W1khi~Fq7u0h1HUn^foh1NvK>~(t282e1vfBYFy|0`~OoMTpa)`tS=Z|^6wcM{ZEL#;Le}=aGo#O*UmZCuW$qJ> VUNCB-g@^RKMz6qs+q4SWzW|I!tWW>| literal 0 HcmV?d00001 diff --git a/bin/windowInterface/MyInterface$3.class b/bin/windowInterface/MyInterface$3.class new file mode 100644 index 0000000000000000000000000000000000000000..ed184d2a7e85709d2e98807ae7a6172e37ef62ad GIT binary patch literal 737 zcmaJNtc*y{c`U+{n}2?D z(?NwHxa8M7Ot|WYpSzbLHV&#p%(HxGLUApW3HM?nwTfhBgc2!3)m+G|`GJ5@L5pny zew0d@9fp-wA#%OLP&v>&Q3u0>2M0A5W%wTI2pGyO3-BYU#OdIwE7GsLn+S%fNXID|!aU@y2=$_(R&raUR(anz({w9$SF$&a_yYuA zgTzJRfe+xLP-jh4ctEx^>zUCxGiPS^*Y6)c0qo(qhmyeBROykK9&1bKrHm;&d4KPB z`W`9*&1-op!$j(Fcs9JI*m|fkG0)1W4e6G&4fkTJjE+=hNmD9NwO1LcKvn@JjzBk~pfb89c1JXU_FIQ?2*YVHhH0CwmFDq)9sbtM~STtpR@Dq^*MGKzxU!Rg5Gy5e$Fuu z_^dJp_<$ClLGJr_h({a=JjT+j!Y=<^g<9_mf^T^8m+$BKkKFfDUSsJGZdQXCSj8H% cD_CcK2^*{z9JSHF7JE*kQ{cX5Y$des0OJR%eE59ThJy_w1P&3rSvKYxAy0bm~+9!df$6Qu`ca-=P#pJYto@zo!{ zz2l)G(7cdi875K>!w>xnimit#6Z5Q`*pSAgZMYv>Wpt!6OPW%Fsy$a(`y~UTf)=|B ze66&yZv@slg~-jGK;^&;s1AWg0X)=vl+g%KM^m8OaezjoG@Xnt`;?x^enJAXk%?u} zlc{p?G+A-t1Xhb0ws%-uL*`?BSx`I7#*w{0howIAv@F`3fCW3uOl zwFgI<@8%$pSw=j5?SwM>-eeYQywWn;1BhnRZI)k1iLDNwvk%#O#j(ry-K{$W-EVmO zImgWKS!E1xjafc}-1jkud5#1YusE%-$A4F$*8PIuE1vx2`+5F```+d?7VmM>8qB~l eR+wGEbLN+@%6h?33k|$r&uMfD+_%nFLhCp9ovdpB literal 0 HcmV?d00001 diff --git a/bin/windowInterface/MyInterface$6.class b/bin/windowInterface/MyInterface$6.class new file mode 100644 index 0000000000000000000000000000000000000000..2306f9dd2cc2557ea318336739146e83e5d471ab GIT binary patch literal 738 zcmaJ<+fLg+5IviiI5BSH(iT!K4W)SqsZ{r&;st~n5U5CoR%(^^jlG1WW>>N|MEw&) zzoJqvQXlvLJ_>c#M9_!ImS#OOI%nq0>|WpexdPC~OBWS}m5Ee|o*XD6vSS{L@bK%M z-`Q~CFa)RkoQEk_qwvGZXJyg;3(LlgZ?OH%Hl1dzn&xRuV%!jF9n2U7G z(*e(g`bf*s*_lX)(~bT+`JUav=K8=x3yUtEF)WqL?PJM` z4&qeCUv|dEXw^>=yElhtBih<>Sr-QHlOAWW*q3(1;Ga8tZN-u9Jr$=qmuhq<%!wx5 z{(+)<*-d$#3mUzCBy#g!=LV~^&MMgqSPn|SGs`>x` literal 0 HcmV?d00001 diff --git a/bin/windowInterface/MyInterface$7.class b/bin/windowInterface/MyInterface$7.class new file mode 100644 index 0000000000000000000000000000000000000000..38431834f49b81b1f39774000612004569999615 GIT binary patch literal 741 zcmaJfgc5Ph4NI5CEpei3L(3*?Xnspe3rhayC&im2okq@vt6&X8_#cO`q%sQ;#d zUx3tt#DO2ck3!6v2sj{Hn)S@+&CHv(`{U=g?*Ml3*hfuZb*l8pOb@iB{Jl&mKD_wj zcej0b0@0~FmvJWbIDRucrPTUpaABF1QybGcX&djRRvDeB!jh(3pkYr`(S6Fmq+-Ml z1D`3a>~n$jUL|s4AmHtp5w#$2D};|`fI8YCT8ISdJqKtfO4HHgY)JV#Im}34E-|Uh z1~OMJo+Uj;PGGHSV0W9zwPm^1TNcOUXEfrPUh?0~_nitm8-oBH-1l)$V7X%N5X+AA ze445B!^?@aMjung+8UP5llhp1Td5i(5FDFHp3*Djwv7I{woS*6sqgDFGlkOQL$W7^ zsfP!euVyckMM1oM^N0%j+7uS+tZ1F>21FD&Vflg7*jflUdy~B_j$J0`Ke&ZrmS!DZ@ZWW4_OB3r!QH?0L7D%^b3c_mmVV=AJ-7lZ fSmkOD54gUDHRcPBI%wk|dyb=H;J!y}HFSOfXH2Yk literal 0 HcmV?d00001 diff --git a/bin/windowInterface/MyInterface$8.class b/bin/windowInterface/MyInterface$8.class new file mode 100644 index 0000000000000000000000000000000000000000..767e31c91d0eb4a53be35b3745088b08a53ea856 GIT binary patch literal 736 zcmaJO{v$+B zm0FN`=nvpWRm{3k%b~KRSX+SnvunA2j1 zfV)yj^PXX?nTu?77)l4aC#qnW^x&Z4qKKM@Dtv}w(*kOtRN`bf=!)cmcVodY6Y7Y^ z9iB)VkCP=Uj$t*gVPl)b)p$1687)UA1JNT+GyL!5hjt4)t&WR2UORZju$VKqhea!T zDvD+FnJ(bN&={>~K%VqzXG?iK7~FF`Od|17+5!D%H}=j-Bh`m0ighYg|5%tSO{%>k zMYnPg^E4GSc;!T-=95kh)@YeUvKL^!Z+A*>qd-=LOW6tXwkWn4xBd19y!Hd8zGawc zI?IFsZZSirm-#MUVwNI?In0kM?9ty=sIgk@rv butNL-R!J`?s-uQCQPS_k^kh0h>m_e`>kCU z4nugsuX&Vll}0Cn3y~NX4Qed2d}JbVEtHA6iIG~xvM@r4oS|XPWzpK9!nk6@9uTO%ljHMFCSC<2kpYlN_80KP~@T|{s zY2$IyvE&%ms|L1qiCmMHYkenibbcv@)YFdtyZND2VQ;(dV-ZU(-ZLy$>>XekD-1!B z$)wvm)oE(EI_HBztw-hnF!~7VbJ4Wz2w+NhjEW7~tCG>9^ds~9cm$5enu{2h(MlcT6 a3A9FZH|g(?&`o?G&yuth?6*Z$!{R?(tg4Uz literal 0 HcmV?d00001 diff --git a/bin/windowInterface/MyInterface.class b/bin/windowInterface/MyInterface.class new file mode 100644 index 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+oGZSNR&a;692z$VbGYs05eu5Pu#1oQvOQ zJ&dj*K#Pz=-@s~+mLe)2MfByNb{dt_EU+fj(2Cmbi5Q^PD`Cpz=VKPoo9p%B+C^F9yoq(_8O?d?GusH5=VEY8nc9NbS6%gwRD1$6;AG4Y$5=alh(<#~0G#|Fpd-*w{GbJ7Ok zZ(b(Sjetb8)UE~tyNHVFDzsh1F+_DA6prJP#ibgI7xNA%o1hiQ*(UV2Yk8+qcm-l@ zSYeDj-^ob%4!hh^!!$ymKZ%Ns0>o(moj9V?un?URK=UYY0^u3TsC~f1%_YMG2Z+u% zfpc`$AO~O=BZ$q|C^RIdB?5i}%0i_Xp?9!iqQAr)F>qSewfzpPzLYjfWZ5Xwdo$k0 zs`oRbA{r9}Ql)w(0(AM`gFxMjwEh5;zZBlvODp*@7~pbW@Mb&?F^q|-{L5$(%AqcT z=SaF0D@9cCqjr{BD2m}7k9P6+1$eHH(|8Y_;}D})fa1;g)!DuHt=D1v{OU1!^8Wx#`35Ec literal 0 HcmV?d00001 diff --git a/default.board b/default.board new file mode 100644 index 0000000..8d83268 --- /dev/null +++ b/default.board @@ -0,0 +1,9 @@ +BR,BN,BB,BQ,BK,BB,BN,BR +BP,BP,BP,BP,BP,BP,BP,BP + , , , , , , , + , , , , , , , + , , , , , , , + , , , , , , , +WP,WP,WP,WP,WP,WP,WP,WP +WR,WN,WB,WQ,WK,WB,WN,WR +W diff --git a/pieces.png b/pieces.png new file mode 100644 index 0000000000000000000000000000000000000000..01cc2f8e0723c40907fcafb30d2044adb1dbd2ff GIT binary patch literal 954 zcmV;r14aCaP)Px&bV)=(RA_n93+CyBv1*&Oq{|ll?3Z58QD>Akp8lm*j5papY>-F z_|!G7(E+F0t>l*zXgEm&ZX>9f!1N&qw-hUoZ8N-SbSxaZQZ4>gfJ_4KfM-5!RAwmJ zMI2yF^HZ4sCXebFxEx$X2W8v9$LS)4Z@xqo@XOd44k-syX8#}){C6-GEbrN>nHrbpkZqDvUnK2wjy?t@5Rq@NFzyDK7;PhNe%$nS?gU#z?WPf0 z=Bh{9D_%50EY8Tmu^pC9C;6oj)D`T4XjaOO$^;XQ5ZQ&5aq|iC@qZ7s^`d)qG970lGuj~I+H*dh?h7i*(5ku$?%p{z4<&P9=274 zgXq}=KDD{39dO#*N`5DSnpAR7{v54Ix!65KGqwpIS0_1l@pkYLe#J+}w~8l>Q`XTg{0sZ)wNvYW cJN8}q0;pW6z5*s-O#lD@07*qoM6N<$g2Ji5hX4Qo literal 0 HcmV?d00001 diff --git a/src/.DS_Store b/src/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..dbc1dc901c0e38412af0d87130e46c54667025a4 GIT binary patch literal 6148 zcmeHK!AiqG5S_KrrWUaWg&qT53)Z$2#7l_v;MIs8RBB?PhQ@4ZQ*$VVob`wN62Hfp z-7VNw5ig>42WH>w&Q8KS*x4NbV9qGm1E>IiiArd!zc z-;Wn|>jlk#X5hCmKxelIK6r2gJ$QG1xsRR~zaK}#v|fK@D+Ob9t!Ng_vU%m+^UO`X zbTo9l!3E7uIgkCR?fGX>m~|^#hdfEWC zm})+l`ZH4<3KM_F?^|L!Fk7M?H3OP~Sq2JnTA};@==1)6Hb~Dj1Db(<#Q-xpZpXot z)ZMy}9No1R>NP3}?aL*K5FFHXEDXAetEfWIXOV$uE6gS03W|OR2paUD8Te5K-T=Od BkwyRj literal 0 HcmV?d00001 diff --git a/src/Main.java b/src/Main.java new file mode 100644 index 0000000..7732cc8 --- /dev/null +++ b/src/Main.java @@ -0,0 +1,19 @@ +import backend.Board; +import backend.Move; +import backend.Piece; +import backend.PieceType; +import windowInterface.MyInterface; + +public class Main { + public static void main(String[] args) { + // testing : + Board testBoard = new Board(8, 8); + testBoard.populateBoard(); + System.out.println(testBoard.toString()); + + // launches graphical interface : + MyInterface mjf = new MyInterface(); + mjf.setVisible(true); + } + +} \ No newline at end of file diff --git a/src/backend/AutoPlayer.java b/src/backend/AutoPlayer.java new file mode 100644 index 0000000..3e67f52 --- /dev/null +++ b/src/backend/AutoPlayer.java @@ -0,0 +1,10 @@ +package backend; + +public class AutoPlayer { + + public Move computeBestMove(Board board) { + // This will be implemented in Part 4 + // For now, just return null or a placeholder move + return null; + } +} \ No newline at end of file diff --git a/src/backend/Board.java b/src/backend/Board.java new file mode 100644 index 0000000..9b876b0 --- /dev/null +++ b/src/backend/Board.java @@ -0,0 +1,621 @@ +package backend; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Set; + +public class Board { + private int width; + private int height; + private Piece[][] pieces; // 2D array to represent the chess board + private int turnNumber; + private boolean isWhiteTurn; + private int selectedX; + private int selectedY; + private boolean hasSelection; + private Set validMoves; // Set of valid positions for the selected piece + private MoveHistory moveHistory; // Added move history + + /** + * Position class to store x,y coordinates and enable using them in HashSet + */ + private static class Position { + private final int x; + private final int y; + + public Position(int x, int y) { + this.x = x; + this.y = y; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null || getClass() != obj.getClass()) return false; + Position position = (Position) obj; + return x == position.x && y == position.y; + } + + @Override + public int hashCode() { + return 31 * x + y; + } + } + + /** + * Constructor for creating a new chess board + * @param width Width of the board + * @param height Height of the board + */ + public Board(int width, int height) { + this.width = width; + this.height = height; + this.pieces = new Piece[width][height]; + this.turnNumber = 0; + this.isWhiteTurn = true; // White goes first in chess + this.hasSelection = false; + this.selectedX = -1; + this.selectedY = -1; + this.validMoves = new HashSet<>(); + this.moveHistory = new MoveHistory(); // Initialize move history + } + + /** + * @return Width of the chess board + */ + public int getWidth() { + return width; + } + + /** + * @return Height of the chess board + */ + public int getHeight() { + return height; + } + + /** + * @return Current turn number + */ + public int getTurnNumber() { + return turnNumber; + } + + /** + * @return True if it's white's turn, false if it's black's turn + */ + public boolean isTurnWhite() { + return isWhiteTurn; + } + + /** + * Places a piece of specified type and color at the given position + * @param isWhite True for white piece, false for black piece + * @param type Type of piece (Pawn, Rook, etc.) + * @param x X-coordinate + * @param y Y-coordinate + */ + public void setPiece(boolean isWhite, PieceType type, int x, int y) { + if (x >= 0 && x < width && y >= 0 && y < height) { + pieces[x][y] = new Piece(x, y, type, isWhite); + } + } + + /** + * Sets up the board with the standard chess starting position + */ + public void populateBoard() { + // Place pawns + for (int x = 0; x < width; x++) { + setPiece(true, PieceType.Pawn, x, 6); // White pawns + setPiece(false, PieceType.Pawn, x, 1); // Black pawns + } + + // Place Rooks + setPiece(true, PieceType.Rook, 0, 7); + setPiece(true, PieceType.Rook, 7, 7); + setPiece(false, PieceType.Rook, 0, 0); + setPiece(false, PieceType.Rook, 7, 0); + + // Place Knights + setPiece(true, PieceType.Knight, 1, 7); + setPiece(true, PieceType.Knight, 6, 7); + setPiece(false, PieceType.Knight, 1, 0); + setPiece(false, PieceType.Knight, 6, 0); + + // Place Bishops + setPiece(true, PieceType.Bishop, 2, 7); + setPiece(true, PieceType.Bishop, 5, 7); + setPiece(false, PieceType.Bishop, 2, 0); + setPiece(false, PieceType.Bishop, 5, 0); + + // Place Queens + setPiece(true, PieceType.Queen, 3, 7); + setPiece(false, PieceType.Queen, 3, 0); + + // Place Kings + setPiece(true, PieceType.King, 4, 7); + setPiece(false, PieceType.King, 4, 0); + + // Reset turn information + turnNumber = 0; + isWhiteTurn = true; + + // Clear selection and valid moves + clearSelection(); + moveHistory.clear(); // Clear move history when starting a new game + } + + /** + * Removes all pieces from the board + */ + public void cleanBoard() { + for (int x = 0; x < width; x++) { + for (int y = 0; y < height; y++) { + pieces[x][y] = null; + } + } + turnNumber = 0; + isWhiteTurn = true; + clearSelection(); + moveHistory.clear(); // Clear move history when cleaning the board + } + + /** + * @return String representation of the board + */ + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("Turn: ").append(turnNumber).append(", ").append(isWhiteTurn ? "White" : "Black").append("\n"); + + for (int y = 0; y < height; y++) { + sb.append(8 - y).append(" "); + for (int x = 0; x < width; x++) { + if (pieces[x][y] == null) { + sb.append(((x + y) % 2 == 0) ? "." : " "); + } else { + Piece p = pieces[x][y]; + char c = p.getType().getSummary().charAt(0); + sb.append(p.isWhite() ? Character.toUpperCase(c) : Character.toLowerCase(c)); + } + sb.append(" "); + } + sb.append("\n"); + } + sb.append(" a b c d e f g h"); + return sb.toString(); + } + + /** + * @return List of all pieces currently on the board + */ + public ArrayList getPieces() { + ArrayList piecesList = new ArrayList<>(); + for (int x = 0; x < width; x++) { + for (int y = 0; y < height; y++) { + if (pieces[x][y] != null) { + piecesList.add(pieces[x][y]); + } + } + } + return piecesList; + } + + /** + * Handles user clicks on the board + * @param x X-coordinate + * @param y Y-coordinate + */ + public void userTouch(int x, int y) { + if (x < 0 || x >= width || y < 0 || y >= height) { + return; // Out of bounds + } + + if (!hasSelection) { + // If no piece is selected yet, select the piece at the clicked position + if (pieces[x][y] != null && pieces[x][y].isWhite() == isWhiteTurn) { + // Select the piece and calculate valid moves + selectedX = x; + selectedY = y; + hasSelection = true; + calculateValidMoves(); + } + } else { + // If a piece is already selected + if (selectedX == x && selectedY == y) { + // If the same position is clicked again, unselect it + clearSelection(); + } else if (isHighlighted(x, y)) { + // Move the selected piece to the new position if it's a valid move + Piece selectedPiece = pieces[selectedX][selectedY]; + Piece capturedPiece = pieces[x][y]; // Store captured piece (null if no capture) + + // Create a Move object to record this move + Move move = new Move(selectedX, selectedY, x, y, selectedPiece, capturedPiece); + + // Move the piece (captures any piece at destination) + pieces[x][y] = selectedPiece; + pieces[selectedX][selectedY] = null; + + // Update the piece's position + selectedPiece.setPosition(x, y); + + // Record the move in history + moveHistory.recordMove(move); + + // Update turn information + turnNumber++; + isWhiteTurn = !isWhiteTurn; + + // Reset selection and valid moves + clearSelection(); + } else if (pieces[x][y] != null && pieces[x][y].isWhite() == isWhiteTurn) { + // If clicked on another piece of the same color, select it instead + selectedX = x; + selectedY = y; + hasSelection = true; + calculateValidMoves(); + } else { + // Clicked on an invalid position, unselect + clearSelection(); + } + } + } + + /** + * Clears selection and valid moves + */ + private void clearSelection() { + hasSelection = false; + selectedX = -1; + selectedY = -1; + validMoves.clear(); + } + + /** + * Calculates valid moves for the currently selected piece + */ + private void calculateValidMoves() { + validMoves.clear(); + + if (!hasSelection) return; + + Piece piece = pieces[selectedX][selectedY]; + if (piece == null) return; + + switch (piece.getType()) { + case Pawn: + calculatePawnMoves(piece); + break; + case Rook: + calculateRookMoves(piece); + break; + case Knight: + calculateKnightMoves(piece); + break; + case Bishop: + calculateBishopMoves(piece); + break; + case Queen: + calculateQueenMoves(piece); + break; + case King: + calculateKingMoves(piece); + break; + } + } + + /** + * Calculate valid moves for a pawn + * @param piece The pawn piece + */ + private void calculatePawnMoves(Piece piece) { + int x = piece.getX(); + int y = piece.getY(); + boolean isWhite = piece.isWhite(); + + // Direction is -1 for white (moving up) and 1 for black (moving down) + int direction = isWhite ? -1 : 1; + int startingRow = isWhite ? 6 : 1; + + // Move forward one square + if (isInsideBoard(x, y + direction) && pieces[x][y + direction] == null) { + validMoves.add(new Position(x, y + direction)); + + // Move forward two squares from starting position + if (y == startingRow && isInsideBoard(x, y + 2 * direction) && pieces[x][y + 2 * direction] == null) { + validMoves.add(new Position(x, y + 2 * direction)); + } + } + + // Capture diagonally + for (int dx = -1; dx <= 1; dx += 2) { + int newX = x + dx; + int newY = y + direction; + + if (isInsideBoard(newX, newY) && pieces[newX][newY] != null && pieces[newX][newY].isWhite() != isWhite) { + validMoves.add(new Position(newX, newY)); + } + } + } + + /** + * Calculate valid moves for a rook + * @param piece The rook piece + */ + private void calculateRookMoves(Piece piece) { + int x = piece.getX(); + int y = piece.getY(); + boolean isWhite = piece.isWhite(); + + // Four directions: horizontal and vertical + int[][] directions = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}}; + + for (int[] dir : directions) { + int dx = dir[0]; + int dy = dir[1]; + + for (int step = 1; step < Math.max(width, height); step++) { + int newX = x + dx * step; + int newY = y + dy * step; + + if (!isInsideBoard(newX, newY)) break; // Out of bounds + + if (pieces[newX][newY] == null) { + // Empty square, can move here + validMoves.add(new Position(newX, newY)); + } else { + // Square has a piece + if (pieces[newX][newY].isWhite() != isWhite) { + // Can capture opponent's piece + validMoves.add(new Position(newX, newY)); + } + break; // Can't move past a piece + } + } + } + } + + /** + * Calculate valid moves for a knight + * @param piece The knight piece + */ + private void calculateKnightMoves(Piece piece) { + int x = piece.getX(); + int y = piece.getY(); + boolean isWhite = piece.isWhite(); + + // All possible knight moves + int[][] moves = { + {-2, -1}, {-2, 1}, {-1, -2}, {-1, 2}, + {1, -2}, {1, 2}, {2, -1}, {2, 1} + }; + + for (int[] move : moves) { + int newX = x + move[0]; + int newY = y + move[1]; + + if (isInsideBoard(newX, newY) && (pieces[newX][newY] == null || pieces[newX][newY].isWhite() != isWhite)) { + validMoves.add(new Position(newX, newY)); + } + } + } + + /** + * Calculate valid moves for a bishop + * @param piece The bishop piece + */ + private void calculateBishopMoves(Piece piece) { + int x = piece.getX(); + int y = piece.getY(); + boolean isWhite = piece.isWhite(); + + // Four diagonal directions + int[][] directions = {{1, 1}, {1, -1}, {-1, 1}, {-1, -1}}; + + for (int[] dir : directions) { + int dx = dir[0]; + int dy = dir[1]; + + for (int step = 1; step < Math.max(width, height); step++) { + int newX = x + dx * step; + int newY = y + dy * step; + + if (!isInsideBoard(newX, newY)) break; // Out of bounds + + if (pieces[newX][newY] == null) { + // Empty square, can move here + validMoves.add(new Position(newX, newY)); + } else { + // Square has a piece + if (pieces[newX][newY].isWhite() != isWhite) { + // Can capture opponent's piece + validMoves.add(new Position(newX, newY)); + } + break; // Can't move past a piece + } + } + } + } + + /** + * Calculate valid moves for a queen + * @param piece The queen piece + */ + private void calculateQueenMoves(Piece piece) { + // Queen combines rook and bishop movement + calculateRookMoves(piece); + calculateBishopMoves(piece); + } + + /** + * Calculate valid moves for a king + * @param piece The king piece + */ + private void calculateKingMoves(Piece piece) { + int x = piece.getX(); + int y = piece.getY(); + boolean isWhite = piece.isWhite(); + + // All 8 directions around the king + for (int dx = -1; dx <= 1; dx++) { + for (int dy = -1; dy <= 1; dy++) { + if (dx == 0 && dy == 0) continue; // Skip the current position + + int newX = x + dx; + int newY = y + dy; + + if (isInsideBoard(newX, newY) && (pieces[newX][newY] == null || pieces[newX][newY].isWhite() != isWhite)) { + validMoves.add(new Position(newX, newY)); + } + } + } + } + + /** + * Check if coordinates are inside the board + * @param x X-coordinate + * @param y Y-coordinate + * @return True if inside board, false otherwise + */ + private boolean isInsideBoard(int x, int y) { + return x >= 0 && x < width && y >= 0 && y < height; + } + + /** + * Checks if a position is currently selected + * @param x X-coordinate + * @param y Y-coordinate + * @return True if the position is selected, false otherwise + */ + public boolean isSelected(int x, int y) { + return hasSelection && selectedX == x && selectedY == y; + } + + /** + * Checks if a position is highlighted as a valid move + * @param x X-coordinate + * @param y Y-coordinate + * @return True if the position is highlighted, false otherwise + */ + public boolean isHighlighted(int x, int y) { + return validMoves.contains(new Position(x, y)); + } + + /** + * Undoes the last move made + */ + public void undoLastMove() { + if (!moveHistory.canUndo()) { + return; // No moves to undo + } + + // Get the last move + Move lastMove = moveHistory.getLastMove(); + + // Get the moving piece (which is now at the destination) + Piece movingPiece = pieces[lastMove.getToX()][lastMove.getToY()]; + + if (movingPiece == null) { + // Something went wrong, the piece isn't where it should be + return; + } + + // Move the piece back to its original position + pieces[lastMove.getFromX()][lastMove.getFromY()] = movingPiece; + movingPiece.setPosition(lastMove.getFromX(), lastMove.getFromY()); + + // If a piece was captured, put it back + if (lastMove.getCapturedPiece() != null) { + Piece capturedPiece = lastMove.getCapturedPiece(); + pieces[lastMove.getToX()][lastMove.getToY()] = capturedPiece; + } else { + // Otherwise, clear the destination square + pieces[lastMove.getToX()][lastMove.getToY()] = null; + } + + // Revert turn information + turnNumber--; + isWhiteTurn = !isWhiteTurn; + + // Clear any selection and highlighting + clearSelection(); + } + + /** + * Constructor for loading a board from a file + * @param array Array of strings representing the board + */ + public Board(String[] array) { + this(8, 8); // Default to standard 8x8 board + // The rest will be implemented in part 3 + } + + /** + * Constructor for copying a board + * @param board Board to copy + */ + public Board(Board board) { + this(board.getWidth(), board.getHeight()); + + this.turnNumber = board.getTurnNumber(); + this.isWhiteTurn = board.isTurnWhite(); + + // Copy pieces + for (Piece piece : board.getPieces()) { + this.setPiece(piece.isWhite(), piece.getType(), piece.getX(), piece.getY()); + } + } + + /** + * Placeholder for saving the board to a file + * @return Array of strings representing the board + */ + public String[] toFileRep() { + // This will be implemented in part 3 + return null; + } + + /** + * Plays a move on the board + * @param move Move to play + */ + public void playMove(Move move) { + if (move == null) { + return; + } + + int fromX = move.getFromX(); + int fromY = move.getFromY(); + int toX = move.getToX(); + int toY = move.getToY(); + + // Make sure there's a piece at the starting position + if (pieces[fromX][fromY] == null) { + return; + } + + // Store the piece that might be captured + Piece capturedPiece = pieces[toX][toY]; + + // Update the move object with the actual pieces + move = new Move(fromX, fromY, toX, toY, pieces[fromX][fromY], capturedPiece); + + // Make the move + pieces[toX][toY] = pieces[fromX][fromY]; + pieces[fromX][fromY] = null; + + // Update the piece's position + pieces[toX][toY].setPosition(toX, toY); + + // Record the move + moveHistory.recordMove(move); + + // Update turn information + turnNumber++; + isWhiteTurn = !isWhiteTurn; + + // Clear any selection + clearSelection(); + } +} \ No newline at end of file diff --git a/src/backend/ChessTimer.java b/src/backend/ChessTimer.java new file mode 100644 index 0000000..7aba328 --- /dev/null +++ b/src/backend/ChessTimer.java @@ -0,0 +1,166 @@ +package backend; + +import java.util.Timer; +import java.util.TimerTask; + +public class ChessTimer { + private long whiteTimeMillis; // Time remaining for white player in milliseconds + private long blackTimeMillis; // Time remaining for black player in milliseconds + private long lastUpdateTime; // Time when the timer was last updated + private boolean isRunning; // Is the timer currently running? + private boolean isWhiteTurn; // Is it white's turn? + private Timer timer; // Java util timer to handle periodic updates + private TimerUpdateListener listener; // Listener to notify UI when time changes + + /** + * Interface for notifying time updates + */ + public interface TimerUpdateListener { + void onTimeUpdate(long whiteTimeMillis, long blackTimeMillis); + void onTimeExpired(boolean isWhiteExpired); // Called when a player's time runs out + } + + /** + * Constructor with initial time in minutes + * @param initialTimeMinutes Initial time for both players in minutes + * @param listener Listener to receive time updates + */ + public ChessTimer(int initialTimeMinutes, TimerUpdateListener listener) { + this.whiteTimeMillis = initialTimeMinutes * 60 * 1000; + this.blackTimeMillis = initialTimeMinutes * 60 * 1000; + this.isRunning = false; + this.isWhiteTurn = true; // White starts in chess + this.listener = listener; + } + + /** + * Start the timer + */ + public void start() { + if (!isRunning) { + isRunning = true; + lastUpdateTime = System.currentTimeMillis(); + + // Schedule periodic updates (every 100ms) + timer = new Timer(true); + timer.scheduleAtFixedRate(new TimerTask() { + @Override + public void run() { + updateTime(); + } + }, 0, 100); + } + } + + /** + * Stop the timer + */ + public void stop() { + if (isRunning) { + isRunning = false; + updateTime(); // Update one last time + + if (timer != null) { + timer.cancel(); + timer = null; + } + } + } + + /** + * Reset the timer to the initial values + * @param initialTimeMinutes New initial time in minutes + */ + public void reset(int initialTimeMinutes) { + stop(); + this.whiteTimeMillis = initialTimeMinutes * 60 * 1000; + this.blackTimeMillis = initialTimeMinutes * 60 * 1000; + this.isWhiteTurn = true; + notifyTimeUpdate(); + } + + /** + * Switch the active player + * @param isWhiteTurn True if it's now white's turn + */ + public void switchTurn(boolean isWhiteTurn) { + if (isRunning) { + updateTime(); // Update time for the player who just completed their move + } + this.isWhiteTurn = isWhiteTurn; + notifyTimeUpdate(); + } + + /** + * Update the time based on elapsed time + */ + private void updateTime() { + if (!isRunning) return; + + long currentTime = System.currentTimeMillis(); + long elapsedTime = currentTime - lastUpdateTime; + lastUpdateTime = currentTime; + + // Deduct time from the active player + if (isWhiteTurn) { + whiteTimeMillis -= elapsedTime; + if (whiteTimeMillis <= 0) { + whiteTimeMillis = 0; + stop(); + if (listener != null) { + listener.onTimeExpired(true); + } + } + } else { + blackTimeMillis -= elapsedTime; + if (blackTimeMillis <= 0) { + blackTimeMillis = 0; + stop(); + if (listener != null) { + listener.onTimeExpired(false); + } + } + } + + notifyTimeUpdate(); + } + + /** + * Notify the listener about time updates + */ + private void notifyTimeUpdate() { + if (listener != null) { + listener.onTimeUpdate(whiteTimeMillis, blackTimeMillis); + } + } + + /** + * Get white player's remaining time in milliseconds + */ + public long getWhiteTimeMillis() { + return whiteTimeMillis; + } + + /** + * Get black player's remaining time in milliseconds + */ + public long getBlackTimeMillis() { + return blackTimeMillis; + } + + /** + * Format milliseconds as "mm:ss" + */ + public static String formatTime(long timeMillis) { + int seconds = (int) (timeMillis / 1000) % 60; + int minutes = (int) (timeMillis / (60 * 1000)); + return String.format("%02d:%02d", minutes, seconds); + } + + /** + * Check if the timer is currently running + */ + public boolean isRunning() { + return isRunning; + } +} \ No newline at end of file diff --git a/src/backend/Game.java b/src/backend/Game.java new file mode 100644 index 0000000..ab05009 --- /dev/null +++ b/src/backend/Game.java @@ -0,0 +1,220 @@ +package backend; + +import windowInterface.MyInterface; + +public class Game extends Thread { + + private AutoPlayer aiPlayer; + private Board board; + private ChessTimer chessTimer; // Add chess timer + private MyInterface mjf; + private int COL_NUM = 8; + private int LINE_NUM = 8; + private int loopDelay = 250; + boolean[] activationAIFlags; + private int initialTimeMinutes = 10; // Default to 10 minutes per player + private boolean timerEnabled = false; // Flag to enable/disable timer + + public Game(MyInterface mjfParam) { + mjf = mjfParam; + board = new Board(COL_NUM, LINE_NUM); + loopDelay = 250; + LINE_NUM = 8; + COL_NUM = 8; + activationAIFlags = new boolean[2]; + aiPlayer = new AutoPlayer(); + + // Initialize the timer with a listener + chessTimer = new ChessTimer(initialTimeMinutes, new ChessTimer.TimerUpdateListener() { + @Override + public void onTimeUpdate(long whiteTimeMillis, long blackTimeMillis) { + // Update UI with new time values + mjf.updateTimers(whiteTimeMillis, blackTimeMillis); + } + + @Override + public void onTimeExpired(boolean isWhiteExpired) { + // Handle time expiration - game over + mjf.timeExpired(isWhiteExpired); + } + }); + } + + public int getWidth() { + return board.getWidth(); + } + + public int getHeight() { + return board.getHeight(); + } + + // Added getBoard method to access the board + public Board getBoard() { + return this.board; + } + + public void run() { + while(true) { + aiPlayerTurn(); + mjf.update(board.getTurnNumber(), board.isTurnWhite()); + try { + Thread.sleep(loopDelay); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } + + private boolean isAITurn() { + return activationAIFlags[board.isTurnWhite()?1:0]; + } + + private void aiPlayerTurn() { + if(isAITurn()) { + // Before AI makes a move + boolean currentTurn = board.isTurnWhite(); + + board.playMove(aiPlayer.computeBestMove(new Board(board))); + + // After AI makes a move, switch the timer + if (timerEnabled && currentTurn != board.isTurnWhite()) { + chessTimer.switchTurn(board.isTurnWhite()); + } + } + } + + public void clickCoords(int x, int y) { + int width = this.getWidth(); + int height = this.getHeight(); + if(0>x || 0>y || x>width || y>height) { + System.out.println("Click out of bounds"); + return; + } + if(!isAITurn()) { + // Before user makes a move + boolean currentTurn = board.isTurnWhite(); + + board.userTouch(x, y); + + // After user makes a move, check if turn switched and update timer + if (timerEnabled && currentTurn != board.isTurnWhite()) { + chessTimer.switchTurn(board.isTurnWhite()); + } + } + } + + public void setPiece(boolean isWhite, PieceType type, int x, int y) { + board.setPiece(isWhite, type, x, y); + } + + public String[] getFileRepresentation() { + return board.toFileRep(); + } + + public void setLoopDelay(int delay) { + this.loopDelay = delay; + } + + public void setDefaultSetup() { + board.cleanBoard(); + board.populateBoard(); + + // Reset the timer when starting a new game + if (timerEnabled) { + chessTimer.reset(initialTimeMinutes); + } + } + + public void setBoard(String[] array) { + board = new Board(array); + + // Reset the timer when loading a new board + if (timerEnabled) { + chessTimer.reset(initialTimeMinutes); + } + } + + public Iterable getPieces() { + return board.getPieces(); + } + + public boolean isSelected(int x, int y) { + return board.isSelected(x, y); + } + + public boolean isHighlighted(int x, int y) { + return board.isHighlighted(x, y); + } + + public void undoLastMove() { + // Store current turn before undo + boolean currentTurn = board.isTurnWhite(); + + board.undoLastMove(); + + // After undo, check if turn switched and update timer + if (timerEnabled && currentTurn != board.isTurnWhite()) { + chessTimer.switchTurn(board.isTurnWhite()); + } + } + + public void toggleAI(boolean isWhite) { + this.activationAIFlags[isWhite?1:0] = !this.activationAIFlags[isWhite?1:0]; + } + + // Timer-related methods + + /** + * Start the chess timer + */ + public void startTimer() { + if (timerEnabled) { + chessTimer.start(); + } + } + + /** + * Stop the chess timer + */ + public void stopTimer() { + if (timerEnabled) { + chessTimer.stop(); + } + } + + /** + * Enable or disable the timer feature + */ + public void setTimerEnabled(boolean enabled) { + this.timerEnabled = enabled; + if (enabled) { + chessTimer.reset(initialTimeMinutes); + } else { + chessTimer.stop(); + } + } + + /** + * Check if timer is enabled + */ + public boolean isTimerEnabled() { + return timerEnabled; + } + + /** + * Set the initial time in minutes for both players + */ + public void setInitialTime(int minutes) { + this.initialTimeMinutes = minutes; + if (timerEnabled) { + chessTimer.reset(minutes); + } + } + + /** + * Get the current chess timer + */ + public ChessTimer getChessTimer() { + return chessTimer; + } +} \ No newline at end of file diff --git a/src/backend/Move.java b/src/backend/Move.java new file mode 100644 index 0000000..a44958f --- /dev/null +++ b/src/backend/Move.java @@ -0,0 +1,64 @@ +package backend; + +public class Move { + private int fromX; + private int fromY; + private int toX; + private int toY; + private Piece movingPiece; + private Piece capturedPiece; + + /** + * Constructor for a move + * @param fromX Starting X-coordinate + * @param fromY Starting Y-coordinate + * @param toX Destination X-coordinate + * @param toY Destination Y-coordinate + * @param movingPiece The piece being moved + * @param capturedPiece The piece being captured (null if no capture) + */ + public Move(int fromX, int fromY, int toX, int toY, Piece movingPiece, Piece capturedPiece) { + this.fromX = fromX; + this.fromY = fromY; + this.toX = toX; + this.toY = toY; + this.movingPiece = movingPiece; + this.capturedPiece = capturedPiece; + } + + // Basic constructor for now - can be expanded later + public Move() { + this.fromX = -1; + this.fromY = -1; + this.toX = -1; + this.toY = -1; + this.movingPiece = null; + this.capturedPiece = null; + } + + // Getters + public int getFromX() { return fromX; } + public int getFromY() { return fromY; } + public int getToX() { return toX; } + public int getToY() { return toY; } + public Piece getMovingPiece() { return movingPiece; } + public Piece getCapturedPiece() { return capturedPiece; } + + // Setters if needed + public void setFromX(int fromX) { this.fromX = fromX; } + public void setFromY(int fromY) { this.fromY = fromY; } + public void setToX(int toX) { this.toX = toX; } + public void setToY(int toY) { this.toY = toY; } + public void setMovingPiece(Piece movingPiece) { this.movingPiece = movingPiece; } + public void setCapturedPiece(Piece capturedPiece) { this.capturedPiece = capturedPiece; } + + @Override + public String toString() { + if (movingPiece == null) { + return "Empty move"; + } + String from = (char)('a' + fromX) + "" + (8 - fromY); + String to = (char)('a' + toX) + "" + (8 - toY); + return movingPiece.getType().getSummary() + from + "-" + to; + } +} \ No newline at end of file diff --git a/src/backend/MoveHistory.java b/src/backend/MoveHistory.java new file mode 100644 index 0000000..c90b527 --- /dev/null +++ b/src/backend/MoveHistory.java @@ -0,0 +1,55 @@ +package backend; + +import java.util.Stack; + +/** + * Class to maintain a history of moves made during the game + * and enable undo functionality + */ +public class MoveHistory { + private Stack moveStack; + + /** + * Constructor for MoveHistory + */ + public MoveHistory() { + moveStack = new Stack<>(); + } + + /** + * Records a move in the history + * + * @param move The move to record + */ + public void recordMove(Move move) { + moveStack.push(move); + } + + /** + * Gets the last move made and removes it from history + * + * @return The last move made, or null if no moves have been made + */ + public Move getLastMove() { + if (moveStack.isEmpty()) { + return null; + } + return moveStack.pop(); + } + + /** + * Checks if there are moves to undo + * + * @return True if there are moves in the history, false otherwise + */ + public boolean canUndo() { + return !moveStack.isEmpty(); + } + + /** + * Clears the move history + */ + public void clear() { + moveStack.clear(); + } +} \ No newline at end of file diff --git a/src/backend/Piece.java b/src/backend/Piece.java new file mode 100644 index 0000000..ef34f35 --- /dev/null +++ b/src/backend/Piece.java @@ -0,0 +1,36 @@ +package backend; + +public class Piece { + private int x; + private int y; + private PieceType type; + private boolean isWhite; + + public Piece(int x, int y, PieceType type, boolean isWhite) { + this.x = x; + this.y = y; + this.type = type; + this.isWhite = isWhite; + } + + public PieceType getType() { + return type; + } + + public boolean isWhite() { + return isWhite; + } + + public int getX() { + return x; + } + + public int getY() { + return y; + } + + public void setPosition(int x, int y) { + this.x = x; + this.y = y; + } +} \ No newline at end of file diff --git a/src/backend/PieceType.java b/src/backend/PieceType.java new file mode 100644 index 0000000..382a02a --- /dev/null +++ b/src/backend/PieceType.java @@ -0,0 +1,26 @@ +package backend; + +public enum PieceType { + Pawn("Pawn", "p"), + Rook("Rook", "r"), + Knight("Knight", "n"), + Bishop("Bishop", "b"), + Queen("Queen", "q"), + King("King", "k"); + + private final String name; + private final String summary; + + PieceType(String name, String summary) { + this.name = name; + this.summary = summary; + } + + public String getName() { + return name; + } + + public String getSummary() { + return summary; + } +} \ No newline at end of file diff --git a/src/windowInterface/JPanelChessBoard.java b/src/windowInterface/JPanelChessBoard.java new file mode 100644 index 0000000..ad260b1 --- /dev/null +++ b/src/windowInterface/JPanelChessBoard.java @@ -0,0 +1,196 @@ +package windowInterface; + +import java.awt.Color; +import java.awt.Graphics; +import java.awt.Image; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; + +import javax.imageio.ImageIO; +import javax.swing.JPanel; + +import backend.Game; +import backend.Piece; +import backend.PieceType; + +public class JPanelChessBoard extends JPanel { + + private static final long serialVersionUID = 1L; + private Game myGame; + private MyInterface interfaceGlobal; + private BufferedImage spriteSheet; + private int PIECE_WIDTH = 16; //in spritesheet + private int PIECE_HEIGHT = 16; //in spritesheet + private int MARGIN = 6; + + private boolean pieceSelectorMode; + private boolean selectedPieceIsWhite; + private PieceType selectedPieceType; + private boolean pieceAdderMode; + + public JPanelChessBoard(MyInterface itf) { + super(); + myGame = null; + interfaceGlobal = itf; + selectedPieceIsWhite = true; + selectedPieceType = PieceType.Pawn; + pieceSelectorMode = false; + try { + spriteSheet = ImageIO.read(new File("pieces.png")); + } catch (IOException e) { + e.printStackTrace(); + } + pieceSelectorMode = false; + pieceAdderMode = false; + addMouseListener(new MouseAdapter() { + public void mousePressed(MouseEvent me) { + // System.out.println(me); + if(pieceSelectorMode) { + int x = Math.round(me.getX()/cellWidth()); + selectedPieceType = PieceType.values()[5-x]; + selectedPieceIsWhite = (me.getY() > cellHeight()); + pieceSelectorMode = false; + } else { + if(myGame == null) { + interfaceGlobal.instantiateSimu(); + } + int x = (me.getX()*myGame.getWidth())/getWidth(); + int y = (me.getY()*myGame.getHeight())/getHeight(); + if(pieceAdderMode) { + //TODO + myGame.setPiece(selectedPieceIsWhite,selectedPieceType, x, y); + pieceAdderMode = false; + } else { + myGame.clickCoords(x,y); + } + } + repaint(); + } + }); + } + + + public void setGame(Game simu) { + myGame = simu; + } + + @Override + protected void paintComponent(Graphics g) { + super.paintComponent(g); + this.setBackground(Color.black); + if(pieceSelectorMode) { + g.drawImage( + spriteSheet, + 0, + 0, + Math.round(5*cellWidth()), + Math.round(2*cellHeight()), + null + ); + return; + } + if (myGame != null) { + // Draw Interface from state of simulator + float cellWidth = cellWidth(); + float cellHeight = cellHeight(); + + g.setColor(Color.white); + for(int x=0; x lines = new LinkedList(); + if (fileName.length()>0) { + try { + BufferedReader fileContent = new BufferedReader(new FileReader(fileName)); + String line = fileContent.readLine(); + int colorID = 0; + while (line != null) { + lines.add(line); + line = fileContent.readLine(); + } + loadedSim.setBoard(Arrays.stream(lines.toArray()).map(Object::toString).toArray(String[]::new)); + fileContent.close(); + } catch (Exception e) { + e.printStackTrace(); + } + game = loadedSim; + panelDraw.setGame(game); + this.repaint(); + } + } + + public void clicSaveToFileButton() { + String fileName=SelectFile(); + if (fileName.length()>0) { + String[] content = game.getFileRepresentation(); + writeFile(fileName, content); + } + } + + public String SelectFile() { + String s; + JFileChooser chooser = new JFileChooser(); + chooser.setCurrentDirectory(new java.io.File(".")); + chooser.setDialogTitle("Choose a file"); + chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); + chooser.setAcceptAllFileFilterUsed(true); + if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { + s=chooser.getSelectedFile().toString(); + } else { + System.out.println("No Selection "); + s=""; + } + return s; + } + + public void writeFile(String fileName, String[] content) { + FileWriter csvWriter; + try { + csvWriter = new FileWriter(fileName); + for (String row : content) { + csvWriter.append(row); + csvWriter.append("\n"); + } + csvWriter.flush(); + csvWriter.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + public void update(int turnCount, boolean turnIsWhite) { + turnLabel.setText("Turn : "+turnCount+", "+ (turnIsWhite?"White":"Black")); + actionLabel.setText(panelDraw.isPieceAdderMode()?"Adding Piece": + (panelDraw.isPieceSelectorMode()?"Selecting Piece to Add": + "Playing")); + this.repaint(); + } + + public void eraseLabels() { + this.setStepBanner("Turn : X"); + } +} \ No newline at end of file