News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

A simple chess board

Started by jj2007, December 31, 2015, 11:41:44 PM

Previous topic - Next topic

jj2007

GuiParas equ "A simple Chessboard", x100, y-20, w800, h760, cblack, s0, bnone
include \masm32\MasmBasic\Res\MbGui.asm
  SetGlobals White$, Black$, Board$
  Let Board$="Board.png"
  .if !Exist(Board$)
      void FileRead$("https://upload.wikimedia.org/wikipedia/commons/thumb/d/d5/Chess_Board.svg/768px-Chess_Board.svg.png")
      Rename "~FrLocal.tmp", Board$
  .endif
  MakeFont ChessFont, Height:84
Let White$="♖♘♗♔♕♗♘♖♙♙♙♙♙♙♙♙"
Let Black$="♜♞♝♚♛♝♞♜♟♟♟♟♟♟♟♟"
Event Paint
  GuiImage Board$, fit            ; we need to scale it a little bit
  GuiTextStyle font ChessFont, fcol RgbCol(255, 128, 0)
  invoke SetBkMode, PtDC, TRANSPARENT
  scaleX=33      ; some fiddling with
  scaleY=92      ; image dimensions
  xoff=-15
  y1=5
  y2=y1+scaleY
  y7=y1+scaleY*6
  y8=y1+scaleY*7
  For_ ecx=1 To 21 Step 3
      GuiText ecx*scaleX+xoff, y1, Mid$(White$, ecx, 3)
      GuiText ecx*scaleX+xoff, y2, Mid$(White$, ecx+24, 3)
      GuiText ecx*scaleX+xoff, y7, Mid$(Black$, ecx+24, 3)
      GuiText ecx*scaleX+xoff, y8, Mid$(Black$, ecx, 3)
  Next
GuiEnd


P.S.: Requires MasmBasic. The second attachment is the source for an example with a nicer background picture. Just extract the ChessBoardBrown.asc to any folder on your Masm32 drive, open it in RichMasm and hit F6.

Magnum

Looks good.

Chess was too complicated for me.
Too many things to remember.

Checkers was much easier. :-)

Take care,
                   Andy

Ubuntu-mate-18.04-desktop-amd64

http://www.goodnewsnetwork.org

Grincheux

I like chess, even if I don't know to win in 3 move.
Problem Professor :
QuoteCould not open https://upload.wikimedia.org/wikipedia/commons/thumb/d/d5/Chess_Board.svg/768px-Chess_Board.svg.png
for recall,



But I can open it with SlimJet!

jj2007

Quote from: Grincheux on January 05, 2016, 04:22:03 PM
I like chess, even if I don't know to win in 3 move.
Problem Professor :
QuoteCould not open https://upload.wikimedia.org/wikipedia/commons/thumb/d/d5/Chess_Board.svg/768px-Chess_Board.svg.png
for recall,
...
But I can open it with SlimJet!

Some sites don't like it when non-browsers access their material. But you can right-click and "save as" to the folder of the executable (local filenames in bold):

ChessBoard.asc:
  Let Board$="Board.png"
  .if !Exist(Board$)
      void FileRead$("https://upload.wikimedia.org/wikipedia/commons/thumb/d/d5/Chess_Board.svg/768px-Chess_Board.svg.png")
      Rename "~FrLocal.tmp", Board$
  .endif


ChessBoardBrown.asc:
  SetGlobals Board$="ChessBoard.jpg"
  SetGlobals
  .if !Exist(Board$)
      void FileRead$("http://www.sjgames.com/proteus/img/chessboard.jpg")
      Rename "~FrLocal.tmp", Board$
  .endif

dedndave

one of my facebook friends posted this - hit the play button

http://www.chess.com/livechess/game?id=1404962680

long ago, i used to play an occassional game at work
we used a program called "email chess tool", which was free back then

jj2007

Dave,
Have a look at the PGN specs - fascinating stuff 8)

[Event "F/S Return Match"]
[Site "Belgrade, Serbia Yugoslavia|JUG"]
[Date "1992.11.04"]
[Round "29"]
[White "Fischer, Robert J."]
[Black "Spassky, Boris V."]
[Result "1/2-1/2"]

1. e4 e5 2. Nf3 Nc6 3. Bb5 a6 {This opening is called the Ruy Lopez.}
4. Ba4 Nf6 5. O-O Be7 6. Re1 b5 7. Bb3 d6 8. c3 O-O 9. h3 Nb8  10. d4 Nbd7
11. c4 c6 12. cxb5 axb5 13. Nc3 Bb7 14. Bg5 b4 15. Nb1 h6 16. Bh4 c5 17. dxe5
Nxe4 18. Bxe7 Qxe7 19. exd6 Qf6 20. Nbd2 Nxd6 21. Nc4 Nxc4 22. Bxc4 Nb6
23. Ne5 Rae8 24. Bxf7+ Rxf7 25. Nxf7 Rxe1+ 26. Qxe1 Kxf7 27. Qe3 Qg5 28. Qxg5
hxg5 29. b3 Ke6 30. a3 Kd6 31. axb4 cxb4 32. Ra5 Nd5 33. f3 Bc8 34. Kf2 Bf5
35. Ra7 g6 36. Ra6+ Kc5 37. Ke1 Nf4 38. g3 Nxh3 39. Kd2 Kb5 40. Rd6 Kc5 41. Ra6
Nf2 42. g4 Bd3 43. Re6 1/2-1/2