Week 5: There Are Simply These Days When Nothing Works
April 7, 2023
“Chess is a fairy tale of 1001 blunders” -Savielly Tartakower
It was my birthday this week!!! Yay!!! I posted a picture of the cake my friends surprised me with at the top. Shout-outs to @Alison and @Garv for preparing this!!! Go check out their blogs!
Anyways, back to my project. As the title suggests, things did not go well (again). But as I said before, all this was predicted (totally). Let’s take a look at my progress from this week. Though, let me warn you ahead of time, it was sadly not much.
- En Passant
- More MRTK Errors
- New MRTK Project
- Plans For Next Week
En Passant
What Is En Passant?
The en passant is a very weird chess rule that even confuses chess players themselves. It’s a special move that allows the pawn to move diagonally and capture an enemy pawn without the enemy pawn even being on the diagonal square. However, this special move can only be played under one specific circumstance, which I will explain later. Right now, this is a bit confusing, so let me use a few images. Again, please note that all images are screenshots of sample positions that I created using Chess.com’s analysis board.
In this position, it is White to move, and the pawn on e4 can capture the pawn on d5, since it is on an adjacent diagonal square. This would be considered a normal capture, since basic chess rules state that pawns can only capture diagonally.
In this new position, Black has just played d5, moving the pawn two squares up. This activates the special condition for en passant. The White pawn is on the 5th rank, and even though there are no pieces on the d6 square, the White pawn can still move there and capture the d5 pawn. When it does, the move would be called an “en passant.”
This is the resulting position after the en passant. The White pawn is on d6, and even though the Black pawn was on d5, not d6, it is still captured.
Rules Of En Passant
The rules for en passant to occur are very specific.
1) The attacking pawn performing the “en passant” must be on the 5th rank.
2) The last move played must be the opponent’s pawn moving 2 squares up, so that it is right next to the attacking pawn.
3) The “en passant” must be played immediately. If the player waits a move, then the en passant is no longer valid.
Implementing The Mechanics
Previously, I already had partial code in my Pawn class to check for a valid en passant. All I had to do was finish it in the BoardManager script. I created two variables, PowerR and PowerC, to mark the most recent pawn move where the pawn moved 2 squares up. Then, in my Pawn class, I use PowerR and PowerC to determine whether or not the selected pawn has the option to “en passant.” If it does and the user chooses to play the en passant, then I will remove the piece at location PowerR and PowerC and proceed as normally. Note – if any other move is played, PowerR and PowerC would be set to -1 to indicate that there is no valid en passant.
Black has just played pawn to d5, moving the pawn up twice, which allows white to en passant. Normally, the white pawn shouldn’t be able to move diagonally, but in this case, it is, showing that the en passant is working.
Here is the final position. After the white pawn “en passants” the pawn on d5, we can see that it captured the piece correctly.
More MRTK Errors
FocusProvider Errors
Now, back to the Mixed Reality portion of this project. The issue regarding the hand gestures from last time is still there. So, I decided to study the error messages a bit more carefully to see if I might be able to figure out what’s wrong.
Here are the errors I’m getting. In my working MRTK project, the three red errors should not exist, which means something is really wrong here. After taking a look at what the error messages say, I realized that the FocusProvider script is causing a lot of problems. Thus, I went to my old project and copied over the “working” FocusProvider script. However, that did not resolve the issue.
Missing Scripts
When I did that, the code wouldn’t even compile! Apparently, I was missing a “namespace” called IMixedRealityQueryablePointer. I checked my old project, and this script did exist. However, I couldn’t find it anywhere in my current project. I was utterly confused. Thus, since I didn’t know what to do, I decided to delete the entire package and re-import it. The script was no longer missing, but the errors were still there.
New MRTK Project
At least for now, I was forced to abandon my old project template and start from scratch. I followed Microsoft’s tutorial [1] for setting up a new MRTK project, and luckily, the hand gestures are working this time. That means I should be able to work on adding the buttons under the chess board with no problems. However, I will need to figure out a way to re-import the Spatial Anchors from my mentor’s old platform because those are pretty important.
Here is a quick demonstration of moving an object. Right now, the cube is at the center of the screen.
Now, you can see that I have successfully moved the cube with my virtual hands.
Adding The Buttons
I’m not finished with this part yet, so I’ll quickly show what I currently have. I continued following Microsoft’s MRTK tutorial to learn more about how to create a custom button [2, 3], and I found a very handy tool to help me organize all 64 buttons under each square. The MRTK TileGridObjectCollection script [4] is very useful in that instead of me manually putting all the buttons at the right coordinates, this script can do it for me automatically. All I have to do is provide the appropriate parameters. It took me a while to figure out how to rotate the grid in the right direction, but eventually, I got it, yay! Here is what it looks like:
Currently, I have cubes, but I’ll replace them with actual buttons once I get them to work.
Plans For Next Week
Next week, I will be working on the MRTK buttons and replacing the cursor with the buttons for moving the pieces. I’m not sure how long this would take, but I’ll try my best to finally get this done. As of now, I’m deciding against working on the Oculus version for the sake of time. Very soon, I need to start translating over the portion of the code I wrote during my Capstone CS class, so I must save some time to do that.
Thanks for reading my blog!!! Come back next week for some more updates on my project!
Analysis Board
References
- Aprilspeight. “Set Up A Mixed Reality Project In Unity With The Mixed Reality Toolkit – Training.” Training | Microsoft Learn, Https://Learn.Microsoft.Com/En-Us/Training/Modules/Mixed-Reality-Toolkit-Project-Unity/.
- Sean-Kerawala. “Place A Mars Rover Object In The Scene And Work With Grids And Intelligent Object Tracking – Training.” Training | Microsoft Learn, Https://Learn.Microsoft.Com/En-Us/Training/Modules/Place-Scene-Objects/.
- Sean-Kerawala. “Getting Started With 3D Object Interaction – Training.” Training | Microsoft Learn, Https://Learn.Microsoft.Com/En-Us/Training/Modules/Get-Started-With-Object-Interaction/.
- CDiaz-MS. “Object Collection – MRTK 2.” Object Collection – MRTK 2 | Microsoft Learn, Https://Learn.Microsoft.Com/En-Us/Windows/Mixed-Reality/Mrtk-Unity/Mrtk2/Features/Ux-Building-Blocks/Object-Collection?View=Mrtkunity-2022-05.