Author Topic: CPChessNet [developing]  (Read 14346 times)

0 Members and 2 Guests are viewing this topic.

Offline Joseman

  • 6128 Plus
  • ******
  • Posts: 810
  • Country: es
    • Awards
Re: CPChessNet [developing]
« Reply #25 on: 18:15, 07 March 18 »
Of course always check for disconnection on the status and go through the entire re-connection process if so.

can be disconnections even if the other side didn't send the command disconnect?
like
0
No reactions

Offline Duke

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.259
  • Country: dk
    • spinpoint.org
    • Awards
Re: CPChessNet [developing]
« Reply #26 on: 18:57, 07 March 18 »
can be disconnections even if the other side didn't send the command disconnect?
Errors can occur that will lead to a disconnection, check the error codes I pasted earlier.
like
0
No reactions

Offline GUNHED

  • 6128 Plus
  • ******
  • Posts: 2.827
  • Country: de
  • Reincarnation of TFM
    • FutureOS - The quickest OS for the CPC and Plus
    • Awards
Re: CPChessNet [developing]
« Reply #27 on: 23:51, 07 March 18 »
Congratulations!!! So this means that one only need two CPC's and a WiFi-device and they can talk. Or is it two CPC connected by two Wifi-devides via the internet. Sorry for asking, but I'm not into PC stuff that much. Ok, now it's CPC stuff too.  :) :) :)
like
0
No reactions
http://futureos.de --> Get the revolutionary FutureOS (Update: 2021.01.24)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> Get the RSX-ROM for LambdaSpeak :-) (Updated: 2021.07.15)

Offline Joseman

  • 6128 Plus
  • ******
  • Posts: 810
  • Country: es
    • Awards
Re: CPChessNet [developing]
« Reply #28 on: 12:59, 08 March 18 »
Congratulations!!! So this means that one only need two CPC's and a WiFi-device and they can talk. Or is it two CPC connected by two Wifi-devides via the internet. Sorry for asking, but I'm not into PC stuff that much. Ok, now it's CPC stuff too.  :) :) :)

2 cpc + 2 m4 (and a router of course), it can be in local lan on your house or internet around the world (untested XD)
like
0
No reactions

Offline Joseman

  • 6128 Plus
  • ******
  • Posts: 810
  • Country: es
    • Awards
Re: CPChessNet [developing]
« Reply #29 on: 15:56, 08 March 18 »
ok

today i achieve board send between the 2 cpc's and turn change

right know the 2 cpc's knows the white moves and what is the turn (white move or black move)

i'm afraid that i'm not programming any check on connection errors, in lan works well, on internet... well we will see...

now i'll return to do the piece moves and when all white and black moves are done, the first beta will be released

i need to program the "board reversal" too, who plays with black will play with black on the bottom, who plays with white will play with white on the bottom too, but i think that only repaiting in accordance whith this is enough, the move code is the same after all... isn't it?


like
0
No reactions

Offline blackdalek

  • Supporter
  • CPC6128
  • *
  • Posts: 232
  • Country: au
  • Fraser
    • Awards
Re: CPChessNet [developing]
« Reply #30 on: 14:16, 09 March 18 »
I haven't played chess in years, but I am wiling to give this game a try when it is finished. 8)
Add me to your list of potential players.  :P

I'd also be interested if someone coded a CPC Scrabble game over WIFI too.
like
0
No reactions
CPC6128 modded with ABBA switch. External 5.25" floppy drive with side switch and Multiface 2. Now also sporting a joystick splitter and M4 WiFi board.

Offline Joseman

  • 6128 Plus
  • ******
  • Posts: 810
  • Country: es
    • Awards
Re: CPChessNet [developing]
« Reply #31 on: 22:34, 10 March 18 »
Hi

At this point all the piece moves are done...

The castling too (minus the possible check)

next is the check, checkmate and En Passant.

If i don't forget anything, the game will be done when this things are completed.




like
0
No reactions

Offline Joseman

  • 6128 Plus
  • ******
  • Posts: 810
  • Country: es
    • Awards
Re: CPChessNet [developing]
« Reply #32 on: 04:41, 13 March 18 »
Hi!

ok, the check ('jaque' in spanish) is 100% done, the 2 kings always knows  if they are in check by any piece in any place of the board.

this will allow me to complete the castling (they cant do castling if any walk of the king to make the castling is in check)

at this point  playing a chess  game is totally possible (only lacking checkmate (you can't do anything if checkmate but the game doesn't stops), em pasant and promotion)

Soon the first beta (i think)

like
0
No reactions

Offline Takis Kalatzis

  • CPC464
  • **
  • Posts: 37
  • Country: gr
    • Awards
Re: CPChessNet [developing]
« Reply #33 on: 11:50, 13 March 18 »
Great work Joseman!


Couple of questions : Will you need a memory expansion in order to use your online chess and chat or only the M4 board? Also, will there be an English UI for us who are not familiar with Spanish?


Best regards,


Takis
like
0
No reactions

Offline Joseman

  • 6128 Plus
  • ******
  • Posts: 810
  • Country: es
    • Awards
Re: CPChessNet [developing]
« Reply #34 on: 11:56, 13 March 18 »
Great work Joseman!


Couple of questions : Will you need a memory expansion in order to use your online chess and chat or only the M4 board? Also, will there be an English UI for us who are not familiar with Spanish?


Best regards,


Takis

The game has to work on a plain 464 (even from cassette), i only tested in a 6128.

Yes, i started to put the messages in spanish because the first idea of the program was to play with a good friend of mine from here. But it will had english text too. anyway chess itself and 2 more keys doesn't need any language  :) .
like
0
No reactions

Offline Joseman

  • 6128 Plus
  • ******
  • Posts: 810
  • Country: es
    • Awards
Re: CPChessNet [developing]
« Reply #35 on: 04:14, 14 March 18 »
Hi

OMG the 'en passant' move was a hell to code, i didn't expect that!

https://en.wikipedia.org/wiki/En_passant

you can only use the en passant move if the enemy pawn makes a double-step (to avoid your pawn) and you ONLY can do the move in the next turn!, if you don't see it, the next time you cant make the 'en passant' move!, AND if the enemy pawn didn't do double-step (he reach with a 1+1 move) you need to control that your pawn don't make the 'en passant' move!!!!!

with the complexity of the move  i have no other choice that make 2 tables for the status of the pawns and send 1 table to the other cpc via net with the enemy pawns that are 'en passant' in the next turn, if we don't do the 'en passant' move (or is not possible) the 2 tables are reinitiated and so on...

the problem once i made the initial code, was to debug it, we have two possible bugs, on the move code itself (and trust me there were bugs) AND the possible bugs on the LAN code (and trust me there were bugs), the problem with the lan/m4 code is that you have to do all BLIND. i only have 2 functions to test the LAN code, one changes the border, and the other display the last stack entry (handy to display what values has a variable, a register... simply do 'push de : call check_stack' or ld a,(de) :push af: call check_stack'... as you can see hell in earth!!  :laugh:
« Last Edit: 04:27, 14 March 18 by Joseman »
like
0
No reactions

Offline Joseman

  • 6128 Plus
  • ******
  • Posts: 810
  • Country: es
    • Awards
Re: CPChessNet [developing]
« Reply #36 on: 04:15, 14 March 18 »
(see previous post)
like
0
No reactions

Offline Skunkfish

  • Supporter
  • 6128 Plus
  • *
  • Posts: 720
  • Country: gb
  • Editor of Colour Personal Computing
    • CPCSTORE.CO.UK - Dedicated to the Amstrad CPC
    • Awards
Re: CPChessNet [developing]
« Reply #37 on: 13:50, 15 March 18 »
I'm such an amateur when it comes to chess, I wasn't even aware of the 'en passant' move!
like
0
No reactions
An expanding array of hardware available at www.cpcstore.co.uk (and issue 3 of CPC Fanzine!)

Offline Joseman

  • 6128 Plus
  • ******
  • Posts: 810
  • Country: es
    • Awards
Re: CPChessNet [developing]
« Reply #38 on: 17:00, 16 March 18 »
Hi

...And for the ones who thought that coding the 'en passant' move was hard, the next chapter: coding the checkmate detection.

with the checkmate code i can assure you one thing now: i know why nobody coded a netchess on cpc before... it is a hell, trust me a HELL to code it.

hours and hours and hours (and hours) of debugging the checkmate code...

there are many ways for the detection of checkmate, but they do more or less the same (or so i have read): you do all the possible moves of your pieces in the next turn and if no move can prevent your king for being in checkmate you're lost.

i approach  the move a little differently, i look in the 8 directions of the king (plus the knights moves), while i look step by step i save the steps on an array, if any direction is in check, i end the function with carry activated.

if carry is activated (king in check) i already have the steps of the enemy piece to achieve the check condition. Next i move the king in all 8 directions and check (again, because the check function can be called separately) if in any direction the king is not in check, if any direction prevent the king for being in check (and the king can move to that direction), then there is not checkmate. But if the king can't move in 8 directions, next i look for all the pieces of my color in the board (minus the king) and try to intercept the check seeing the array of steps of the enemy piece, if any of my pieces can do the move, then this means that at least one of my pieces can 'eat' the enemy piece or put itself on the way to checkmate (with the knight only can 'eat'). BUT there is a last check! if we can intercept the check, but there is a double check (2 pieces threating the king) then our king will be still in check!. we have to double check the check condition intercepting one piece and seeing if the king is still in check!! in that case is checkmate

Ok, one thing is to say that and other thing is to CODE that... and trust me you DONT WANT to code something like this!!  :laugh:

anyway checkmate code is finished and working (or not if any bug still remains).

this means that the last move that can prevent cpchessnet to see the light of day is DONE.

now only a little more and game finished (i hope!)





« Last Edit: 17:08, 16 March 18 by Joseman »
like
0
No reactions

Offline Skunkfish

  • Supporter
  • 6128 Plus
  • *
  • Posts: 720
  • Country: gb
  • Editor of Colour Personal Computing
    • CPCSTORE.CO.UK - Dedicated to the Amstrad CPC
    • Awards
Re: CPChessNet [developing]
« Reply #39 on: 18:16, 16 March 18 »
Wow, sounds complicated! How long does the checkmate detection take to run?
like
0
No reactions
An expanding array of hardware available at www.cpcstore.co.uk (and issue 3 of CPC Fanzine!)

Offline Joseman

  • 6128 Plus
  • ******
  • Posts: 810
  • Country: es
    • Awards
Re: CPChessNet [developing]
« Reply #40 on: 19:02, 16 March 18 »
Wow, sounds complicated! How long does the checkmate detection take to run?

they are easy calculations (a lot, and hard to debug), the cpc is almost idle with the game XD, even i have to slowdown the keyboard detection, if i detect the keyboard keys in every game loop, the pieces are almost impossible to select because the cursor is too fast, even you don't see the cursor when you press the keys because it is doing the same moves 100 times or more in one key press!
like
0
No reactions

Offline Targhan

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.416
  • Country: fr
    • Awards
Re: CPChessNet [developing]
« Reply #41 on: 02:00, 17 March 18 »
This is really an interesting project. Do you intend to release the sources once it is done?


As for you complex "check mate" code, this is typically the kind of code that would benefit from Z80 test units so that you can be sure your code works as expected and won't break as the code progresses. But maybe you've done so.
like
0
No reactions
Targhan/Arkos

Arkos Tracker 2.0.1 now released! - Follow the news on Twitter!
Disark - A cross-platform Z80 disassembler/source converter
FDC Tool 1.1 - Read Amsdos files without the system

Imperial Mahjong
Orion Prime

Offline mr_lou

  • 6128 Plus
  • ******
  • Posts: 3.206
  • Country: dk
    • index.php?action=treasury
    • 8-bit Memoirs - a Blu-ray diskmag-like eBook about the 8-bit era
    • Awards
Re: CPChessNet [developing]
« Reply #42 on: 02:51, 17 March 18 »
As I kid I was very interested in chess at one point. So I wished for one of those chess computers for Christmas one year.

17 years later I beat it!

Yea... it's safe to say I'm no expert chess player.  :)

CPC networked games is intriguing. Using the CPC for e-mail and IRC and a few games is intriguing. But in order for it to succeed, a lot of people have to have their CPC setup for Internet. So you can sit on IRC on #cpc, and go "Hey! Anyone up for a game of CPChessNet?" and 5 people will go: "Me!"

Oh, that gives me an idea: Could it be made possible to have spectators for a game?
like
0
No reactions

Offline robcfg

  • Supporter
  • 6128 Plus
  • *
  • Posts: 2.428
  • Country: se
  • 8-Bit Technomancer
    • index.php?action=treasury
    • Awards
Re: CPChessNet [developing]
« Reply #43 on: 11:30, 17 March 18 »
That would be certainly interesting!


You get to watch the match and have group chat.
like
0
No reactions

Offline Joseman

  • 6128 Plus
  • ******
  • Posts: 810
  • Country: es
    • Awards
Re: CPChessNet [developing]
« Reply #44 on: 18:43, 17 March 18 »
Hi

Pawn Promotion done!

This was a easy one! only intercept the pawn_move rutine with is the pawn on the last line? then call pawn_promote, change the piece type for what is selected on the pawn promotion menu and ret to pawn_move

As for you complex "check mate" code, this is typically the kind of code that would benefit from Z80 test units so that you can be sure your code works as expected and won't break as the code progresses.

to be honest... i don't have idea of what Z80 test units are! if you can explain...

CPC networked games is intriguing. Using the CPC for e-mail and IRC and a few games is intriguing. But in order for it to succeed, a lot of people have to have their CPC setup for Internet. So you can sit on IRC on #cpc, and go "Hey! Anyone up for a game of CPChessNet?" and 5 people will go: "Me!"

Oh, that gives me an idea: Could it be made possible to have spectators for a game?

is not impossible to allow more clients to connect only to repaint the board on his side... but @Duke can tell us if there are limits on the number of clients conected!

But i think that only watch a chess game must be a hell of boring! and anyway the chat is only 3 lines, i have no more room for it... i don't know if it makes any sense. i'll be happy if the game works 100% correct, and i know for sure that actually it doesnt  :laugh:

Maybe the real interesting thing is to make a pc client, to allow to play chess with non cpc users... but i don't have patience to make a pc client right now!

if anyone wants to do a pc client... only have to read a little table with the board pieces and send it back when the move is done.

 OR better!! some emulator with M4 emulation!!!

pic of promotion:
 

« Last Edit: 19:00, 17 March 18 by Joseman »
like
0
No reactions

Offline Targhan

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.416
  • Country: fr
    • Awards
Re: CPChessNet [developing]
« Reply #45 on: 19:05, 17 March 18 »
Quote
to be honest... i don't have idea of what Z80 test units are! if you can explain...


It's a code, that you run from time to time, that will call some other code and checks that the result is fine. Let's say you have a multiplication code:


Code: [Select]
MultiplyBy4
  add hl,hl
  add hl,hl
  ret

To make sure that this code works, and will continue to work, you will make another code that will do this:
Code: [Select]
ld hl,10
call MultiplyBy4
;Checks the result: must be 40.
ld de,40
or a
sbc hl,de
jr z,OK
;Error!


You can do such code for all small subcodes, or on larger scale. For example, your test unit could:
- Create a chessboard (in memory) with a checkmate situation.
- Call the "isCheckMate" call
- Make sure the result is "true".


And you would create as many situations as possible to make sure the checkmate code works for them (and also for situatiosn where the checkmate returns false). Now, with such code, you KNOW that you checkmate code works, even after you make the checkmate code evolve.


Of course, it takes time to make such code, but it is extremely valuable to be sure that algorithms work perfectly; now and later.
 
like
0
No reactions
Targhan/Arkos

Arkos Tracker 2.0.1 now released! - Follow the news on Twitter!
Disark - A cross-platform Z80 disassembler/source converter
FDC Tool 1.1 - Read Amsdos files without the system

Imperial Mahjong
Orion Prime

Offline Gryzor

  • Administrator
  • 6128 Plus
  • *****
  • Posts: 17.095
  • Country: gr
  • CPC-Wiki maintainer
    • CPCWiki
    • Awards
Re: CPChessNet [developing]
« Reply #46 on: 10:23, 18 March 18 »
PROMOCION DEL PEON!


That's my new favourite phrase after Basket Master's "CANASTA!" :D
like
0
No reactions

Offline Joseman

  • 6128 Plus
  • ******
  • Posts: 810
  • Country: es
    • Awards
Re: CPChessNet [developing]
« Reply #47 on: 04:44, 19 March 18 »
Hi

Castling move finished, now the kings can't do castling if any of the square that the king needs walk to do the move is in threat. Fixed 1  (serious) bug in the routine too.

At this point i can tell you that all the moves & all the rules are finished, CPChessnet is almost finished.

I'll do a win/lose screen and the options to restart the game or go to the main menu, make the net code more reliable and the game will be uploaded for all who wants to betatest the game!.




like
0
No reactions

Offline blackdalek

  • Supporter
  • CPC6128
  • *
  • Posts: 232
  • Country: au
  • Fraser
    • Awards
Re: CPChessNet [developing]
« Reply #48 on: 10:44, 19 March 18 »
Hi

Castling move finished, now the kings can't do castling if any of the square that the king needs walk to do the move is in threat. Fixed 1  (serious) bug in the routine too.

At this point i can tell you that all the moves & all the rules are finished, CPChessnet is almost finished.

I'll do a win/lose screen and the options to restart the game or go to the main menu, make the net code more reliable and the game will be uploaded for all who wants to betatest the game!.
I'll help you beta test (pending any catastrophic hardware failure of my cpc that may occur beforehand)

Sent from my 4013X using Tapatalk

like
0
No reactions
CPC6128 modded with ABBA switch. External 5.25" floppy drive with side switch and Multiface 2. Now also sporting a joystick splitter and M4 WiFi board.

Offline Joseman

  • 6128 Plus
  • ******
  • Posts: 810
  • Country: es
    • Awards
Re: CPChessNet [developing]
« Reply #49 on: 16:59, 19 March 18 »
Hi @Duke

I'm looking again the net code, and there is a problem with the connection...

if i setup the server, put it listening for a client and only after of this setup the client, the conexion works well, BUT

if i setup first the client and put it listening for a server and after of this, setup the server, the conexion doesn't work NEVER

what can i doing bad?

And other question, this is from the start, but never looked back again until the game is nearly finished...

my client/server cpc's create a socket, but i never close the sockets, the first time they choose 01h, if i reset the cpc, they choose 02h and so on...

what is the correct way of closing a socket, and this way the cpc's always use 01h?

thankyou for all !!
like
0
No reactions