Java Chess Programming Video #40 The GUI (Part XII)

preview_player
Показать описание

Chess Code Repository :

IDE:

Reading Material:
Рекомендации по теме
Комментарии
Автор

Quick side note initializeAlgebraicNotation() you can use 2 nested for loops. The outer one counts from NUM_TILES_PER_ROW down to >0 and the inner one uses a char not a int. So the inner for loop looks like this: for(char y = 'a'; y < 'a'+NUM_TILES_PER_ROW; y++). Char values are using the integral numbers in the ASCII Table, so its possible to just count them up. Inittialize a ArrayList of the type String and add( ""+outerindex+innerindex). return ArrayList.toArray.

A nice little way to automate the initialization and it resizes automatically if you choose for whatever reason to change the size of the board. This makes it less prone to errors and saves you from typing.

Not a critique just a note.

Emanuel-zrdu
Автор

Here's an alternate solution to writing if you don't feel like copying the whole thing from the repo:

private static String[] initializeAlgebraicNotation() {
String[] finalArray = new String[64];
int[] numbers = {8, 7, 6, 5, 4, 3, 2, 1};
String[] letters = {"a", "b", "c", "d", "e", "f", "g", "h"};
int count = 0;
for(int x : numbers) {
for (String y : letters) {
finalArray[count] = y + x;
count++;
}
}
return finalArray;
}

Loving the playlist, Amir! I'm excited to finish this engine.

gloriasun
Автор

Thank you, I have been answered in this video. The problem lies in super (null, null, -1);
I Feedback: If there are errors in the previous video, leave it in the notes.

oaiduongthanh
Автор

Finally made it through the GUI section! It looks like I can fix all the other visuals for the GUI except for 1. In the table class, we use highlightLegals() to hightlight all the possible destinations a piece can move to. For the king though, it fails to show a green dot for king and queenside castle options even though the move is available. This makes sense since pieceLegalMoves() uses the Piece class method of calculateLegalMoves(), and for the King class, the cases for castling aren't included in the list of legal moves. After all that background info my question is this: Since we already calculate castles in the calculateKingCastles() in the Player class, is there a way to get the results from that method into pieceLegalMoves()? To me, it seems a bit redundant to have to add the cases for castles within the King class when they were already tested somewhere else, so I was wondering if there was a workaround for this. Any help pointing me in the right direction is greatly appreciated because the things I tried didn't really help.

yasindante
Автор

Hello Amir, really enjoying the series. Sorry to bother you but I have a problem with my castle move, it can't be played in game. Can you help?

thanks in advance

davidmozny
Автор

hello. I tried catching the errors that I have but I cant seem to find it. I am really bad at GUI so I dont understand which part to fix. 1. My white pawns cant seem to pawn jump and the highlight only shows 1, not 2 for the jump. 2. for my black pieces, the highlight seems to work but when i select the pawns to a location, the icon doesn't move and it just stays in its same place. However, on the location(right panel) it seems to register that it moved.

andrewheo
Автор

Hey Amir I apologize if this is becoming a nuisance, but I'm not sure if you saw my link in the reply. I had posted it the first time you asked but I don't know if it was visible based on your second request for it. Thank you again for your help man. It's amazing what you're doing.

cassiusmusic
Автор

Thank you, again, very much for this series of videos i really learned a lot!

But i ran into some trouble. if i try to change the images of the pieces the clarity is not so good and the pieces look not so good. any ideas how can i fix this?

AnonimMadess
Автор

Im getting an error from the Move class saying that cant be referenced from a static context. What up with that?

lukajozic
Автор

Hi Amir! How in your code from githab select the game mode against the computer ? In the setting of the game when choosing a computer, nothing changes, the computer does not start to play (

mavpa_z_karpat
Автор

sorry, i have probleme now that my pieces can not eat each other. debuger says "transBoard in makeMove (Player) is null". Don't know what to do....

guaaasuka
Автор

Hi Amir, I have issue rendering the board after clicking destination tile for very first move for Pawn. It prints correct move in the GameHistoryPanel but Pawn image does not appear in target tile. I am using Java 8 and NetBeans 8.2 IDE. Same happens if I move Knight. Your help will be really appreciated.
I put debug messages as follows:
getcurrent coordinate:52
current coordinate:52
get destination coordinate:36
destination coordinate:36
In board execute method: get moved piece:P

Thanks,
Chirag Mehta

chiragmehtaca
Автор

hey Amir. I've been trying to debug my unmoving pieces and I found that when I click a piece on a tile in starting position I'm getting a null pointer from the method `public int getCurrentCoordinate()` in Class Move, which returns . I tried switching out `movedPiece` with the method `getMovedPiece()` to no avail. Thanks for your help man.

cassiusmusic
Автор

Oh I didn't make my method static.. That's why I faced problem.

sakata_gintoki
Автор

Hi there Amir, I've thoroughly enjoyed your series so far, however, this is the first time I've come across an error in my code and I'm not quite sure how to fix it. I run into:
"Exception in thread "AWT-EventQueue-0"
when I attempt to move 1. e4 for example, and if I attempt to make any illegal moves it throws that error, for example 1. Ke2
I'd appreciate any help, here is the GitHub Repo:

Thank you very much for the video series.

anneksiy
welcome to shbcf.ru