This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
nitrogenfingers's profile picture

Minecraft Chess

Started by nitrogenfingers, 14 April 2012 - 06:02 AM
nitrogenfingers #1
Posted 14 April 2012 - 08:02 AM
I've been working on expanded networks and operating systems on and off for about a month now. The forums here seem ablaze with similar activity and debugging it is a very painful process so I've taken a free day to do something a bit different.

[media]http://youtu.be/I0Uqww8h_vE[/media]

As of this point, Chess is by in large complete, with a few caveats and not a lot of testing. Please report any bugs in this thread, or by personal message.

- A nice UI
- Command parsing to move pieces- uses standard long notation without a piece identifier (e.g. e2-e4, g2xh5, with "quit" and "exit" to quit)
- A list of each move made
- Logic constricting piece movement to standard chess rules
- Local multiplayer (on the same machine)
1100 15/4/2012
- Restrictions on piece movements- all pieces now can only move or take according to standard chess rules
- Support for en passant and castling
- Support for pawn promotion
1400 16/4/2012
- Check acknowledgement
2200 16/4/2012
- A GUI for accessing local and network play, and displaying instruction
0300 19/4/2012
- Monitor support for observation of the board
- Network multiplayer using p2p
- Hook-in for the monitor interface with the rest of the game (6x6 bigscreen)
0000 21/11/2012
- Colour support for the client

Planned updates
- Identifying checkmates and stalemates

I've got an upload of the code on mediafire here:
CLIENT: http://www.mediafire.com/?vy76al1qfttfn3d
MONITOR: http://www.mediafire...s8d4tvxsh780qeu

This might be fun if you want a break from zombie slaying and creeper repairs, and would like a nice gentleman's game to play.
Ludburghmdm #2
Posted 14 April 2012 - 09:30 AM
Whoa! EPIC!!!
kamnxt #3
Posted 14 April 2012 - 11:05 AM
Maybe you could make multiplayer client-server-client, so you could connect a monitor to the server?
nitrogenfingers #4
Posted 14 April 2012 - 11:14 AM
Maybe you could make multiplayer client-server-client, so you could connect a monitor to the server?

That may be the best way. I wanted to avoid a server situation because that sort of makes updates a complicated process and I'm absolutely sick of message parsing- was planning a simple peer-to-peer host join system that would just fire off moves as a message, and each computer keeps a local copy of the data rather than having a central repository that has to be queried. It's a messy solution but it's far easier to code…

But you may be right. I'll ponder on it, but focussing on local multiplayer for the moment.
lukeplechaty #5
Posted 14 April 2012 - 04:16 PM
the link is broke it say Invalid or Deleted File.
nitrogenfingers #6
Posted 14 April 2012 - 04:38 PM
Thanks for the heads up. I'm not sure why, mediafire mesbehaving. Once I've got… well some of the rules of Chess working correctly I'll try reuploading it and providing a fresh link.
lukeplechaty #7
Posted 14 April 2012 - 07:24 PM
that ok hope you get one up soon
Turtle #8
Posted 14 April 2012 - 09:10 PM
Congratz, you just put up a middle-finger to the whole CC-Chess team.

(Incase you don't get it, its not ment seriusly, it's just that you sort of annoyed us by making a working chess code)

Cool code dude, as CC-Chess is broken atm (1 damn error i can't fix, and seemingly , no-one wants to fix), you currently own the only working code for chess in CC
Cloudy #9
Posted 14 April 2012 - 09:55 PM
Why would you be annoyed? Surely a little competition is good?
Wolvan #10
Posted 14 April 2012 - 10:40 PM
I maybe could help with the rednet play
You can do it like this: You can send the commands (eg. e2-e3) via rednet and the local computer can run it. I could help..Maybe :)/>/>
Ludburghmdm #11
Posted 14 April 2012 - 10:56 PM
Try using Dropbox or you can try to install MediaFire Express to upload
FuzzyPurp #12
Posted 15 April 2012 - 12:42 AM
Looks awesome, can't wait to play it.
Leo Verto #13
Posted 15 April 2012 - 01:24 AM
This is awesome! Did you implement winning yet?
nitrogenfingers #14
Posted 15 April 2012 - 02:28 AM
Congratz, you just put up a middle-finger to the whole CC-Chess team.

Dino2306, I'm really sorry mate I had NO idea there was another team working on computercraft chess!

If it makes you feel any better all I've managed to get so far is some of the rules working (as of right now pieces move on constraints). It's not been an easy job, really it was something a friend suggested on a whim and it sounded like fun. It sort of has been….

I actually haven't posted any of my network code for exactly that reason (among others), I really don't want to tread on anyone's toes.

I maybe could help with the rednet play
You can do it like this: You can send the commands (eg. e2-e3) via rednet and the local computer can run it. I could help..Maybe :)/>/>
Wolfran, if you'd like to take a look at network enabling this game, awesome, one less job for me! I had planned to do it exactly as you suggest- I have an isLegal function and a makeMove function. How I imagine the program to run is the player will ask if the move is legal, then submit a rednet command so both computers (or all three if I get monitors working) will execute that move. It should be pretty simple I'm hoping at least, but yeah send me an email or a message or something and we'll figure it out.


This is awesome! Did you implement winning yet?
I genuinely have no idea how I'm going to implement checkmate yet. Check is easy- you just iterate through the board (I'm using a board-relative rather than piece-relative perspective), check the movement of each piece and see if moving to the king's square is a legal move, but mate… I'll have to check, well taking the checking piece, the path between the checking piece and the king and moving the king too. hm…

I've added a new update with hopefully a working mediafire link that displays movement rules being enforced by the underlying engine. Checking, checkmating and castling are all that's missing right now. Cool to see a few people interested, genuinely expected little-no interest on this one.
Turtle #15
Posted 15 April 2012 - 09:02 AM
@Nitrogen, it's not really an issue, the code is broken pretty badly, mainly some gui issues (printing random stuff instead of what is supposed to be printed)
But we DO have got the whole system, board, pieces etc running, im currently fixing the connection via rednet, :)/>/>
if you want to look at the code, https://docs.google.com/document/d/1Sau8k0UKbzmsOS9ZC2_LjcB87RvQe-5EMTIBAFm7crE/edit
Just please do not copy-paste code, you are however allowed to use idea's from this code, as we're trying to reach a common goal.
Turtle #16
Posted 15 April 2012 - 09:05 AM
Why would you be annoyed? Surely a little competition is good?

It's annoying to work for over a month, and still having the code broken, to then see someone doing it perfectly, it makes you feel stupit, but as I tried to say, its annoying, but not really an issue.
nitrogenfingers #17
Posted 15 April 2012 - 11:36 AM
@Nitrogen, it's not really an issue, the code is broken pretty badly, mainly some gui issues (printing random stuff instead of what is supposed to be printed)

I've had a flip over it, myself and your team went about this in wildly different ways! Where you seem to have gone for a piece-centric model I've gone for a board-centric one. I went for that because it meant a bit less looping. Are you using classes? I didn't even know lua had them, this almost looks like C++ code. Something I didn't know..
No idea what's causing the bugs you mentioned but even then I'm so embarrassed I wouldn't dare give you advice at this point!

Oh out curiosity (mingled with self-interest) have you managed to get checkmates working? I can't see any computationally efficient way to do it….
nitrogenfingers #18
Posted 16 April 2012 - 06:16 AM
I've just added support for checking (and just need to update this code to be reflected in castling as well), but it seems to be going well. The Checkmate and Stalemate algorithms I've decided to combine- rather than the insane idea I previously had of searching for king movement, blocking paths and taking other pieces, I'm going to use the stalemate rule: If there are no legal moves for any pieces then if the king is in check it's checkmate, otherwise its stalemate. It's far less computationally efficient I know, but I need to do it for stalemate anyway so may as well kill 2 birds with one stone.

While I've been unit testing this program right through development, which has been surprisingly easy thanks to the nice compartmentalization of the game logic (piece logic rarely interferes with one another), I haven't done much large-scale testing simply out of lack of time. If you like the look of the program so far please give it a try and if you'd be so good please report any/all errors you come across. The GUI and parser are both pretty rock solid at this point, so I'm mainly interested in the game logic- the game reporting checks where they're not happening, disallowing illegal moves, allowing illegal ones and so on.
lukeplechaty #19
Posted 16 April 2012 - 02:26 PM
you know this is bad im still geting Invalid or Deleted File.
nitrogenfingers #20
Posted 16 April 2012 - 03:04 PM
I have no idea what's going on- when I copy the link and paste it in the URL window it seems to run fine, it's only the embedded link that's having problems. Try doing the same:
http://www.mediafire.com/?n4y9vy72woqmbqs
lukeplechaty #21
Posted 16 April 2012 - 03:12 PM
I have no idea what's going on- when I copy the link and paste it in the URL window it seems to run fine, it's only the embedded link that's having problems. Try doing the same:
http://www.mediafire...n4y9vy72woqmbqs
that works thanks
theoriginalbit #22
Posted 23 April 2012 - 03:21 PM
I cannot get the download link to work… tried all suggestions… :)/>/>
BigSHinyToys #23
Posted 23 April 2012 - 07:44 PM
your chess is awesome but mediafile links are not the best way to distribute it. i would suggest switching to http://pastebin.com/
mediafile is more for large files anyway. pastbin is for code.
Leo Verto #24
Posted 24 April 2012 - 05:24 PM
I'm looking forward to seeing this for rednet multiplayer.
I really want monitors on my tekkit server but I can't afford installing the backport. :)/>/>
nitrogenfingers #25
Posted 27 April 2012 - 05:30 AM
Thanks for everyone's interests, for the moment at least I'm calling this project largely complete. When I finish up that stalemate algorithm I think it will be entirely done.

I'll post a video soon to show off the game running.

I've done basic unit testing and white box testing while I've been working through it but I haven't done much black box, so please report any bugs you come across. Leave them as a message or send me a personal message, I really appreciate the help.

And I'll switch over from mediafire to pastebin, thanks for the advice!
Leo Verto #26
Posted 27 April 2012 - 04:27 PM
I will certainly get this on my server when tekkit includes monitors :)/>/>
BigSHinyToys #27
Posted 28 April 2012 - 02:43 AM
I was thinking about your display problems and how you wanted to use monitors and that lead me to this idea.

Using turtles to build the pieces on a board so spectators can see the game. One turtle would be for white one for black when instructed they would move to the piece and remove it then move to the position it should be and build it.or if you wanted it to happen faster use four bots two for each side one building while the other removes the piece.

It would be a lot of work to get it going but you have to admit it would be cool.
Spoiler
nitrogenfingers #28
Posted 28 April 2012 - 04:41 AM
I did have a similar idea. I'd have an 8x8 grid of turtles beneath the surface. That way players could make moves on a physical board rather than a digital one, but of course that would require some sort of legend and wouldn't look very exciting.
What you've got there looks pretty cool- I suppose instead there would just be one or two turtles that "commit" moves by de and reconstructing large chess pieces in different spots. Probably need to use another mod to get some better blocks, but you're right that is a big job. I may have to give that a try…
Negeator #29
Posted 30 April 2012 - 10:15 PM
Just put this program on a server I play on with a few friends. We've really enjoyed this so far.

Great Job!
PixelToast #30
Posted 10 May 2012 - 08:47 PM
I did have a similar idea. I'd have an 8x8 grid of turtles beneath the surface. That way players could make moves on a physical board rather than a digital one, but of course that would require some sort of legend and wouldn't look very exciting.
What you've got there looks pretty cool- I suppose instead there would just be one or two turtles that "commit" moves by de and reconstructing large chess pieces in different spots. Probably need to use another mod to get some better blocks, but you're right that is a big job. I may have to give that a try…
might be possible to put icons above the turtles with the openGL peripheral and it would look really cool to see one turtle kill another
and for controlling what turtle will go you might be able to use the controller peripheral i think
Leo Verto #31
Posted 13 May 2012 - 09:54 PM
I think using 2 periphals for this is not a very good idea, since this program is meant to be used on servers (why else would there be chess multiplayer) and all users would have to mod CC and install both periphals.
And using periphals would exclude tekkit support completely.

But maybe having an alternate version for the periphals would be a good idea.
nitrogenfingers #32
Posted 19 September 2012 - 12:41 PM
A bit of a shameless bumb but this recently received a 2 1/2 second mention on Yogcast at around 18:30- celebrity endorsement!
http://www.youtube.com/watch?v=yK2SSXac1fw
Cranium #33
Posted 19 September 2012 - 04:38 PM
This is an amazing accomplishment! And here I am stuck on restaraunt-napkin level games like hangman or tic-tac-toe….
Great job!
nitrogenfingers #34
Posted 21 November 2012 - 02:20 AM
This is a tiny update but I've added colour to the client, to make it a little less epilepsy-inducing to play.



Most of the interface and the chesswatch remains monochrome however and the game is compatible with both kinds of computers. I'm still not happy with the colours, but it's good enough for the moment.
BigSHinyToys #35
Posted 21 November 2012 - 03:24 AM
you can set background to white or black in the normal computers. Might solve your flashing problem
Spoiler
rhyleymaster #36
Posted 21 November 2012 - 01:04 PM
Im gonna use this on a server. CHESS TOURNAMENTS BEGIN!
nitrogenfingers #37
Posted 21 November 2012 - 01:10 PM
you can set background to white or black in the normal computers. Might solve your flashing problem

Oh, my main concern is with contrast. White doesn't show well on yellow, black doesn't show well on brown. I can't keep the checker pattern needed on monochrome monitors on white or black pieces of the wrong colour won't show up. I could have the board change colour depending on what piece is on the board, but that might look a bit strange.

I'll keep thinking about it.
BigSHinyToys #38
Posted 22 November 2012 - 12:27 AM
you can set background to white or black in the normal computers. Might solve your flashing problem

Oh, my main concern is with contrast. White doesn't show well on yellow, black doesn't show well on brown. I can't keep the checker pattern needed on monochrome monitors on white or black pieces of the wrong colour won't show up. I could have the board change colour depending on what piece is on the board, but that might look a bit strange.

I'll keep thinking about it.
I was hoping that gray and light Gray was possible on black and white monitors. would have the distinctest contrasts you need.
KaoS #39
Posted 22 November 2012 - 11:20 AM
I have just watched your youtube video and must admit it is quite cool. I am now determined to make a mouse operated version with move highlighting and the rest
KaoS #40
Posted 23 November 2012 - 07:20 AM
well. finished the first beta. forum post is here. thanks for the inspiration nitro
Dlcruz129 #41
Posted 07 January 2013 - 11:53 AM
Any chance of us finally getting checkmate/stalemate recognition? Oh, and possibly mouse support?
nitrogenfingers #42
Posted 07 January 2013 - 03:15 PM
So much to do… finish the RPG, clean up GameUtils, turn LaserBlast into colour, write up more lectures…

Keep pestering me about it and it will eventually get done, I've not "forgotten" about Chess but it's very much on the back burner.
XoX #43
Posted 07 January 2013 - 09:42 PM
If you want you could contact me on skype I got a nice idea for the checkmate recognition.
nitrogenfingers #44
Posted 08 January 2013 - 12:54 AM
I think that the actual code for checkmate recognition is in place, but isn't tested and isn't working- I simply planned to determine if the king was in check and there existed no legal move on the board that could remove the king from check. Stalemate is the same except the king isn't in check. A legal move being defined as a move which does not move the king into check, that meaning there exists no enemy piece on the board that can move to that square should the king occupy it. It's n^2, but I can't think of a better way.

It just needs testing, I'm fairly certain the engine I've built allows for most of those tests.
arctivlargl #45
Posted 24 November 2013 - 11:55 PM
So a recent reddit post has asked me to implement a turtle chess board. Do you mind if I look at your code and use parts of it? It would be great to have a visual simulation on the master computer that commands are provided to.
nitrogenfingers #46
Posted 01 December 2013 - 06:25 PM
Sure. Same deal with all my programs on my forums; feel free to use the code as you see fit, but if you're reusing large parts of it, crediting me would be nice and sharing what you have come up with would be great as well.
arctivlargl #47
Posted 02 December 2013 - 05:04 PM
Sounds good. I actually completed my version last night - just have some debugging to do. I'll look at yours probably next weekend to see if you found a neat solution for some of my more messy solutions, then hopefully finish debugging everything and post it.

So far it looks really nice. Kinda excited to post it.
arctivlargl #48
Posted 08 December 2013 - 05:47 AM
I still need to get around to looking at your code some time. I'd like to use your monitor set up - it might give the board a nice 2D representation for people to follow.

Here is my current code that hasn't been stress tested yet. After this semester is done I'll look into some more corner cases. Maybe change rednetRelay since it seems to be bogging down the move speed.
http://www.reddit.co...r_minechildren/

Thanks for offering to let me look at your code though. I still don't have checkmate or stalemate worked out, so when I get time I'll probably look at yours to see how you did it.
Edited on 08 December 2013 - 04:47 AM
FlaskBreaker #49
Posted 08 December 2013 - 06:55 AM
Cool!
But, why don't you use advanced computers for the monitor?
mrpoopy345 #50
Posted 09 December 2013 - 12:19 PM
Man, this is cool. Always leave it up to nitrogen to make something that will blow my mind!
arctivlargl #51
Posted 09 December 2013 - 01:03 PM
But, why don't you use advanced computers for the monitor?

You mean like he did in post #34 on this thread?

– Edit : My mistake #34 only shows an advanced computer - it doesn't necessarily show an advanced monitor which I believe is what you were getting at with your post.
Edited on 09 December 2013 - 12:05 PM
ltgthebeast #52
Posted 10 November 2014 - 10:41 PM
hey nitrogen fingers i tried to put the chess on the monitor and the code is on there but when i run it it says enter computer id then i enter the id of the host computer and it says no response what do i do?
KingJackTBE #53
Posted 21 December 2016 - 03:45 AM
Can you please tell me how to install this I have no idea how to.