Check out Glinski's Hexagonal Chess, our featured variant for May, 2024.


[ Help | Earliest Comments | Latest Comments ]
[ List All Subjects of Discussion | Create New Subject of Discussion ]
[ List Earliest Comments Only For Pages | Games | Rated Pages | Rated Games | Subjects of Discussion ]

Comments/Ratings for a Single Item

EarliestEarlier Reverse Order LaterLatest
Interactive diagrams. Diagrams that interactively show piece moves.[All Comments] [Add Comment or Rating]
💡📝H. G. Muller wrote on Tue, Sep 13, 2016 03:58 PM UTC:

I was still adding a paragraph to my previous post; be sure not to miss it. You can use the diagram elsewhere, but you would have to copy the image files and JavaScript file that are present on CVP, or fully link to those.

BTW, the underlying JavaScript can actually do more than what is needed to just power the diagrams as used on CVP. It also supports functions to collect a game, and navigate through it. You would just have to put buttons in the HTML to activate these functions. See for instance http://hgm.nubati.net/variants/elven, where I use the diagram on my own website. You can also copy that HTML page, and then replace the diagram in it by your own from the Design Wizard.


Aurelian Florea wrote on Tue, Sep 13, 2016 04:10 PM UTC:

Ok, thanks! I actually know nothing about JS but i'm good with general programming so I guess i'll handle myself!

In the meantime, I think I inadvertently posted 2 variants I did not suppose to, How do I delete them?


Aurelian Florea wrote on Tue, Sep 13, 2016 04:51 PM UTC:

Ok, I have no clue how to do what you've just said on my computer, if you have the time to tell me the baby steps, or let me send you the html code that the wizard has done, make work on your machine and then send me the result i'll owe you a beer, in my first trip to US, or your first trip to Romania


💡📝H. G. Muller wrote on Tue, Sep 13, 2016 05:48 PM UTC:

OK, here it comes! Copy the text below to a file, ad save it on your computer as 'trial.html'. If you then open that file with your browser it should show an interactive diagram for Elven Chess. Then you can try replacing the diagram definition inside the file (the pink part) by what you get from the Design Wizard for your own variant. You will have to change the definition of graphicsDir to http://www.chessvariants.com/graphics.dir/alphaerie , (i.e. replace the ".." in the location by the URLof the CVP website) and the link to the JavaScript source (in the first line) to http://www.chessvariants.com/membergraphics/MSinteractivedia/betza.gif (or leave that line in place, as it is already written that way in the HTML below).

Note that in this context the legend belonging to the diagram is not hidden below it, but placed openly next to it. This is caused by the presence of a 'table' element with id="pieceTable" (highlighted in green) elsewhere on the page.

<html>
<head>
<title>Elven Chess applet</title>
</head>

<body>

<div id="rules" style="display:none">
<h1>Elven Chess</h1>
<div onclick="OpenDiv('rules')">
<p><a href="http://http://www.chessvariants.org/index/msdisplay.php?itemid=MSelvenchess">Elven Chess</a>
is a Chess variant on a 10x10 board that features four new pieces next to the usual FIDE set.
HERE YOU CAN PUT A LONG DESCRIPTION OF THE RULES
</p><p>
<u>Less</u>...
</p>
</div>
</div>
<table cellpadding="20" border="0"><tr><td valign="bottom">

<p id="message">Move by click-click or drag-drop:</p>

<script type="text/javascript" src="http://www.chessvariants.com/membergraphics/MSinteractivedia/betza.gif"></script>
<div style="float:left;margin:0 40px 20px 0;">
<div id="diagram">
files=10
ranks=10
promoZone=3
promoChoice=NBRQ
graphicsDir=http://www.chessvariants.com/graphics.dir/alfaerie/
whitePrefix=w
blackPrefix=b
graphicsType=gif
squareSize=54
symmetry=none
pawn::::a3,b3,c3,d3,e3,f3,g3,h3,i3,j3,,a8,b8,c8,d8,e8,f8,g8,h8,i8,j8
knight::::b2,i2,,b9,i9
bishop::::c2,h2,,c9,h9
rook::::a1,j1,,a10,j10
queen::::f2,,e9
king::::f1,,e10
warlock::::e2,,f9
elf::BW:promotedbishop:g2,,d9
goblin::RF:promotedrook:d2,,g9
dwarf::K:man:a2,j2,,a9,j9
</div></div>

<p>
<input type="button" onclick="FlipView()" value="Flip View">
<input class="step" type="button" onclick="Seek(0)" value="|<">
<input class="step" type="button" onclick="Seek(10001)" value="<">
<input class="step" type="button" onclick="Seek(10002)" value=">">
<input class="step" type="button" onclick="Seek(10003)" value=">>">
<input class="step" type="button" onclick="Seek(10000)" value=">|">
</p>

<h2 id="players">Elven Chess: local game</h2>

</td><td valign="top" width="150">

<p onclick="OpenDiv('rules')">
Pawns promote on reaching the last 3 ranks, to Q, R, B or N.
It is forbidden to trade Warlocks.<br>
<u>More</u>...
</p>

<table id="pieceTable" border="1"></table>

<p onclick="OpenDiv('betza')">
Click here to define your own piece moves
</p>
<div id="betza" style="display: none">
<p>
<i>Type a move definition below, and then click<br>
on the move above you want to replace.</i>
</p>
Betza string: <input type="text" id="definition" name="Betza" onkeydown="if(event.keyCode == 13)DefinePiece(0);">
</div>
</td></tr><tr><td colspan="2">

OTHER STUFF YOU MIGHT WANT TO HAVE ON THE PAGE

</td></tr></table>
</body>
</html>


Aurelian Florea wrote on Tue, Sep 13, 2016 06:00 PM UTC:

Well, it doesn't show a diagram of elven chess, but the own text of the html, this is what it happens when I try to upload it on the website, too. What am I doing wrong?


💡📝H. G. Muller wrote on Tue, Sep 13, 2016 06:10 PM UTC:

What happens when you paste the URL that is given by the src= of the script tag into the address field of your browser?


Aurelian Florea wrote on Tue, Sep 13, 2016 06:16 PM UTC:

It says: "The image [...] cannot be displayed because it contains errors" where [...] stand for the content of the src=


💡📝H. G. Muller wrote on Tue, Sep 13, 2016 06:35 PM UTC:

That is the correct response; it means it could read the file and inspect its contents. (It is not really a .gif file but a .js file that I renamed to .gif, because the CVP submission form did not allow me to upload .js files. So it is not surprising the Browser does not recognizeit as a valid GIF image file.)

That makes it strange that the text of the diagram description is not replaced by the diagram. Because this is what the JavaScript is supposed to do. I suppose you do see the diagram on the Elven Chess article on CVP, and on http://hgm.nubati.net/variants/elven ?


Aurelian Florea wrote on Tue, Sep 13, 2016 06:39 PM UTC:

Yes, I see the diagram there.


Aurelian Florea wrote on Tue, Sep 13, 2016 06:42 PM UTC:

I solved it, for some reason using open office instead of notepad does that, now I'll try to paste my own code!


Aurelian Florea wrote on Tue, Sep 13, 2016 07:01 PM UTC:

The graphics are wrong, but the script works! For images it shows just cracked images!


Aurelian Florea wrote on Tue, Sep 13, 2016 07:14 PM UTC:

It works great for the other game, the one with archbishops!


Aurelian Florea wrote on Tue, Sep 13, 2016 07:18 PM UTC:

It works now, have you done something HG? or I just copied stuff wrong the first time?


💡📝H. G. Muller wrote on Tue, Sep 13, 2016 07:37 PM UTC:

Must have been a copying error. I was just reformatting my earlier posting that showed the required HTML, adding borders and background coloring to it, but not changing anything substantial.


Aurelian Florea wrote on Tue, Sep 13, 2016 07:38 PM UTC:

Now I can actually play games, thank you H.G., I see now how silly they look. Thank you very much! It's now getting late here. See you soon!


💡📝H. G. Muller wrote on Fri, Sep 23, 2016 06:51 PM UTC:

I have added a nice improvement to the ShowMoves(N) function associated with the diagram. Before, this function used to show the moves of the Nth defined piece that was defined, on an empty board. And if you invoked it again for the same piece, it restored the original board position. So that you could attach it with an onclick="ShowMoves(N)" to a HTML element that describes the piece in your submission text, to make clicks on it interactively show the moves.

The new feature works for variants with Shogi-style promotions (i.e. where you defined a non-zero promoOffset P to relate each unpromoted piece N to a unique promoted partner N+P). When you invoke the function a second time with the same N it shows the moves of the promoted piece.  It only reverts to displaying the origial position when invoked a third time. For unpromotable pieces the second invocation already makes the board revert to the original position, as before.

In addition it now always shows the name of the piece it displays the moves of in the message above the board. A good place to see it in action is the Chu Shogi article.


Aurelian Florea wrote on Sat, Oct 8, 2016 12:01 PM UTC:

All your work the passed weeks with the diagrams is great, but I must ask:

1.Do they support hexagonall mappings?

2.Do they suport Xiangqi style rivers?

I think the short answer to both questions is no. Any hope for these facilities soon?


💡📝H. G. Muller wrote on Sat, Oct 8, 2016 03:22 PM UTC:

I am not sure what you mean by 'Xiangqi-style rivers'. As for graphical representation, Xiangqi is played on grid-points rather than squares, and the diagram will never be able to do that, as it is just a HTML table with images in the squares and lines between the squares. So displaying a River is just a tiny detail of something it cannot do in the first place.

If you mean that you just want certain pieces to be limited to a fraction of the board, this is already possible. The latest .js script for the diagram checks if there exists a user-supplied function BadZone(file,rank,piece,color). If there isn't, it assumes any piece can venture anywhere on the board. But if there is, it only accepts moves where the fuction returns 0 for the destination square.

To indicate the zones by coloring of the board the user can similarly supply a function Shade(file,rank), which returns a color.

So to do Xiangqi (with a western-style board) the HTML page defining the diagram would need to contain the extra text

<script>
function BadZone(x, y, piece, color) {
  if(piece = ELEPHANT) return (color ? y < 5 : y > 4);
  // cases for King and Advisors
  ....
}
function Shade(x, y) {
  var color = 0;
  if(y > 4) color = !color; // board halves
  if(x > 2 && x < 6 && (y < 3 || y > 6) color = !color; // palace
  return color;
}
</script>

As for hexagonal boards: this is currently definitely not supported. It would not be totally impossible to support something close to it in the current framework, however. The board must be a HTML table, which means rectangular cells. But it is possible to have cells extend over more than one column in HTML. So by doubling the number of columns, and then alternately fuse odd+even or even+odd on different ranks, you would get a masonry-like pattern which should be close enough.


Aurelian Florea wrote on Sat, Oct 8, 2016 03:51 PM UTC:

Thanks, It's nice to know for future projects!


Aurelian Florea wrote on Mon, Oct 10, 2016 02:48 AM UTC:

I've noticed somthing odd with my diagrams for small apothecary 1 chess (the ones on my computer that use the javascript). The griffin, and griffin only shows grey pseudo-check moves. This can't be right and needs fixing.


Aurelian Florea wrote on Mon, Oct 10, 2016 02:49 AM UTC:

And the queen in small apothecary 2!


💡📝H. G. Muller wrote on Mon, Oct 10, 2016 07:39 AM UTC:

Ah, this is a consequence of the new way to handle the royal piece. The diagram must think Griffin and Queen are royal. By default the last-defined piece is royal. If you don't want that, you can add a line

royal=N

to the diagram definition, with N the ordinal number of the King.


Aurelian Florea wrote on Mon, Oct 10, 2016 07:40 AM UTC:

Ok, thanks!


Aurelian Florea wrote on Mon, Oct 10, 2016 07:47 AM UTC:

You were correct,H.G., I did written royal=3 (as was my case) and I'm fine!


Aurelian Florea wrote on Sun, Mar 5, 2017 06:19 AM UTC:

H.G.

Diagrams don't seem to work anymore, just code appears!


25 comments displayed

EarliestEarlier Reverse Order LaterLatest

Permalink to the exact comments currently displayed.