Is it Possible to Implement a Chess Game in Tiddlywiki

I was playing with

To me it seems not difficult to implement this interface in Tiddlywiki!
Using button, CSS, and SVG and some scripts behind!

I like to know if there are such games implemented in Tiddlywiki, specially Chess!

Yes :slight_smile:

https://Telumire.github.io/TiddlyTweaks/index.html#:[[Chess]]

I just copy/pasted the code from 1K Javascript Tiny Chess by Óscar Toledo G. ©2010 in an iframe on my wiki. His code is so tiny, it’s incredible 


Chess.tid (1.4 KB)

3 Likes

@telumire interesting implementation, provisioning scripts inside an iFrame, I see the bulk comes from the inclusion of the tiny_chess_1.html. I assume a copy of which could be stored along side a single file wiki?

I am interested in being able to publish other javascript in tiddlywiki even if it remains sandboxed in an iframe.

Perhaps at most we may copy and paste results into the wiki can you provide any generic guidance? In a new thread if necessary. Only if you have the time of course.

1 Like

Back on August 16th: Just a goofy thought: a way to get javascript into a Tiddler

Really easy.

Slap HTML and javascript into a tiddler, and feed the content of that tiddler as ifame’s srcdoc parameter value .

1 Like

As a fun project for somebody having the time, the chess game could definitely be developed with native TiddlyWiki + HTML + CSS.

And that would be very cool.

I have nothing more to add beyond what @Charlie_Veniot said :slight_smile:

The proper way would be to create a wikitext or javascript macro but I just wanted to share this amazing little snippet of js. I don’t understand how it works (yet), so I probably wont be the one adapting it the “tiddlywiki” way 
 but I’d love to see it !

Hmm, doesn’t seem to understand castling.

EDIT: Or en passant.

1 Like

Yes he had to remove these features to met the challenge of writing a chess engine under 1Ko :

I had news of the contest in August 8 and came to my mind the challenge of writing a chess in 1K of Javascript, so based on my 2.2K Javascript chess in six hours I managed to crunch it to 1K. I had to remove castling, en passant and limit promotion to queen, leaving a simple chessboard with letters for chessmen, click in origin square and target square to move pieces.

I think this is the 2.2K version he’s talking about :
https://nanochess.org/archive/toledo_javascript_chess_3.html

Full article : Toledo Javascript Chess Game


PS: here’s the license, for those of you who’d like to make a proper port to tiddlywiki :

License terms for your Javascript chess?

It is free for non-commercial use, this includes all the forks, even those under the GPL as legally I’m the original author.

Please cite my name and website in any derivative source code or webpage where it is used. I would be glad to receive an e-mail telling me where you used it.

If you want to do commercial usage, just write me and we can reach a reasonable agreement.

Toledo Chess: Frequently asked questions

1 Like

In abstract terms, some of Cadbury’s APL folk managed it in a single line of vector rules in 1980, albeit with no strategy constraints, so the answer must be yes.

Sound interesting, what do you mean by that ? Can you provide a link to a paper or article explaining that concept/showcasing it ?

1 Like

It is certainly possible. I haven’t seen it or done it but I made the small interactive fiction game which had rules about as complex as chess.

I have been working on a movable grid macro in tiddlywiki that I am planning on using as a menu or alternate to the story river layout, but it could be used for chess once it is cleaned up a bit more and the logic for the rules is put into it.

As it is the thing I made uses just core widgets and some css and you can build a checkers or chess board with it, but there isn’t any rules checking so you can move pieces however you want.

I think that the host I use for my demo wikis is having caching problems or something like that so the example wiki isn’t showing up, I will post here when I figure out how to fix it.

1 Like

I have seen a chess plugin before. Not much logic but you can play against it, and possibly win. I will share If I find it.

It is an interesting idea. TBH I’d benefit not so much by live gaming as live illustration of Kasparov’s moves 


Just a comment
TT

My hosting thing decided that it would work again, so here is the site with the demo.

https://ooktech.com/jed/TiddlerGrid/

3 Likes

Ha! Very neat. One could do a bunch of things with that. Tx!

1 Like

This is great Jed, the eventcatcher/table combo has a lot of possibilities for games and I’ve noticed with some experiments of my own that, when hosted on Bob, it allows multi-player connections. i.e 2 players can move pieces on the same game from different machines on the same network. (At least on my local network, I haven’t tried it on an internet exposed wiki).

There is a lot to study and learn from in your macro. Thanks a lot. Not everything works for me yet on mobile/tablet (can’t drag the pucks on an ipad or android, but can drag the icons in the example below it). It might be the ‘mouse up/down’ that the touch screen doesn’t like, I’m not sure. I have had success with ‘on click’ with eventcatcher in my own experiments but I don’t have the ability to implement drag and drop and my mobile doesn’t like it anyway.

If you’re interested the experiment is here.

https://wattaged.github.io/popmap/#Popmap

Try it on a tablet or mobile and tap the first button on the ‘dash’ - set active pin to 1, close and tap the screen to move the pin about.

It’s not a game but It’s another example of game-like action using eventcatcher with a table. I guarantee that you are much better equiped to develop these possibilities. As you will see my ‘code’ is a mess and I am currently stuck on fixing pin positions relative to different screen sizes. Progress has stalled. I will study your methods and maybe try and take it further.

Best wishes

3 Likes

Apologies for necroposting, I found the thread by searching on Google. While I’m not interested to play chess in TiddlyWiki, a TidlyWiki alternative to a chess database like scid is certainly something I’d be very tempted to use. A TiddlyWiki that could do stuff like:

  • importing games in PGN format
  • importing positions in FEN format
  • letting me navigate a game by displaying an inline chess board with position interactively updating on the board after each move
  • letting me annotate a game by adding comments and variations
  • having separate tiddlers for unique positions identified by full or partial FEN strings, some rudimentary search through positions, not necessarily full featured CQL etc

That sounds quite doable, integrating tools like chessjs and chessboard.js Annotations might be awkward if they’re not just to be folded into the PGN but if they can be kept separate, it would be useful. (“Fischer said this about that game. Here was Spassky’s take. And years later, Kasparov analyzed it to find this variant. My own analysis (with a little help from Stockfish) looks like this.” All pointing to the same PGN tiddler.)

The big difficulty is that I would expect a good chess database to be able to search positions. So this might be able to answer that, “yes, this position was reached in Tal-Korchnoi, 1992 (id #1234567), move 39.” That would mean that importing a PNG would also involve searching through the game, and finding the FEN for every move, and probably have tiddlers that tied positions to game move numbers (or plies):

title: gp/8675309
tags: GamePosition
game: game/12345
ply: 40
position: pos/98765
title: game/12345
tags: Game
white: Adolf Anderssen 
black: Lionel Kieseritzky
date: 1851
pgn: 1. e4 e5 2. f4 exf4 3. Bc4 Qh4+ 4. Kf1 b5 5. Bxb5 Nf6 6. Nf3 Qh6 7. d3 Nh5 8. Nh4 Qg5 9. Nf5 c6 10. g4 Nf6 11. Rg1 cxb5 12. h4 Qg6 13. h5 Qg5 14. Qf3 Ng8 15. Bxf4 Qf6 16. Nc3 Bc5 17. Nd5 Qxb2 18. Bd6 Qxa1+ 19. Ke2 Bxg1 20. e5 Na6 21. Nxg7+ Kd8 22. Qf6+ Nxf6 23. Be7# 1-0

This is widely known as The Immortal Game...
title: pos/98765
tags: Position
fen: r1b1k1nr/p2p1ppp/n2B4/1p1NPN1P/6P1/3P1Q2/P1P1K3/q5b1 w kq - 1 21

It sounds interesting, and I wish I had time to work on it!

That sounds quite doable, integrating tools like chessboard.js

I’m no JavaScript programmer, but curiousity took over and I had a quick look at the source code. To me it looks like it does:

  1. provide an API to parse FEN strings
  2. generate HTML code that draws the board
  3. manipulate the DOM to insert code generated in 2. using jQuery
  4. provide some animation functionality for implementing autoplay and interactively moving pieces over the board via drag-and-drop

Since being able to use this as parametrized TiddlyWiki JavaScript macro for only drawing a static board from a FEN string as input data only requires 1. and 2., hypothetically, what would have to be done to be able to use chessboard.js as TiddlyWiki JavaScript module? Some kind of heavy source code surgery to either decouple the part that does 3. and 4., or just extract everything related to 1. and 2. as new TiddlyWiki compatible module?