Please send sample pgn with pv as comment to mgemuh at gmx.deFerdy wrote:Finally implemented here.
http://www.chess.x10host.com/pgn4web/index.html
I rewrite the pgn output of ChessGUI to a different format, now the pv (taken from TLCV_File.txt output from ChessGUI) is embeded as part of move comment, so now I get pgn and pv at the same time, send it to server via ftp, then extract the pv via pgn4web custom function, and just use a javascript to display the pv on the page, no more server scripts needed.
I think Matthias Gemuh author of ChessGUI can easily incorparate this change, adding pv to the move comment.
Live broadcast of engine pv
Moderators: hgm, Rebel, chrisw
-
- Posts: 3245
- Joined: Thu Mar 09, 2006 9:10 am
Re: Live broadcast of engine pv
My engine was quite strong till I added knowledge to it.
http://www.chess.hylogic.de
http://www.chess.hylogic.de
-
- Posts: 27790
- Joined: Fri Mar 10, 2006 10:06 am
- Location: Amsterdam
- Full name: H G Muller
Re: Live broadcast of engine pv
The best way to add PVs to the PGN is as 'recursive variation'. Then PGN processing software can also walk through the PVs. If you hide them in a comment, they will just be ignored.
-
- Posts: 4833
- Joined: Sun Aug 10, 2008 3:15 pm
- Location: Philippines
Re: Live broadcast of engine pv
I will just post here.Matthias Gemuh wrote:Please send sample pgn with pv as comment to mgemuh at gmx.deFerdy wrote:Finally implemented here.
http://www.chess.x10host.com/pgn4web/index.html
I rewrite the pgn output of ChessGUI to a different format, now the pv (taken from TLCV_File.txt output from ChessGUI) is embeded as part of move comment, so now I get pgn and pv at the same time, send it to server via ftp, then extract the pv via pgn4web custom function, and just use a javascript to display the pv on the page, no more server scripts needed.
I think Matthias Gemuh author of ChessGUI can easily incorparate this change, adding pv to the move comment.
-
- Posts: 6991
- Joined: Thu Aug 18, 2011 12:04 pm
Re: Live broadcast of engine pv
Nice!Ferdy wrote:Finally implemented here.
http://www.chess.x10host.com/pgn4web/index.html
I rewrite the pgn output of ChessGUI to a different format, now the pv (taken from TLCV_File.txt output from ChessGUI) is embeded as part of move comment, so now I get pgn and pv at the same time, send it to server via ftp, then extract the pv via pgn4web custom function, and just use a javascript to display the pv on the page, no more server scripts needed.
I think Matthias Gemuh author of ChessGUI can easily incorparate this change, adding pv to the move comment.
Did you have to change your engine to make it work?
-
- Posts: 6991
- Joined: Thu Aug 18, 2011 12:04 pm
Re: Live broadcast of engine pv
But... but...but... Graham want clocks, let's give Graham clocks.Ferdy wrote:Wow it looks greatRebel wrote:Better now with Chrome?Ferdy wrote:I am using chrome and it seems like the live pv is not consistent, after forced refresh it would show the pv before the move is made on the board but later, the pv is no longer updated. If you forced to refresh again, the live pv will show up and on later moves the live pv is no longer updated again. So I need to press the refresh button every time I wanted to see the live pv displayed.Rebel wrote:Got it to work.
http://rebel13.nl/pgn4web/live1.html
Currently for version 241 only and the hopping needs a fix, point is, it is doable and quite easily.
Basically you can put anything in the file, even tell random jokes to entertain the audience in case the game is in a boring stage.
http://rebel13.nl/pgn4web/live1.html
And now Graham will complain he wants graphical clocks.
-
- Posts: 41423
- Joined: Sun Feb 26, 2006 10:52 am
- Location: Auckland, NZ
Re: Live broadcast of engine pv
Rebel wrote:But... but...but... Graham want clocks, let's give Graham clocks.
http://rebel13.nl/pgn4web/live1.html
And now Graham will complain he wants graphical clocks.
Remember that I use ChessGUI and not Arena, so that might count against me anyway.
gbanksnz at gmail.com
-
- Posts: 593
- Joined: Sat Aug 20, 2011 9:43 am
Re: Live broadcast of engine pv
The problem is making something which works with more than one GUI. InBetween, or something similar, which is between the gui and the engine would give you independence from the GUI and/or the engine logs.Ferdy wrote:How do you show to a web page the engine pv's during broadcast?
I wrote something last year which parsed arena's debug file and then fed this to node.js via ssh. It showed pv output, the refresh rate was limited by how quickly new lines of pv data could get to the web server. Was much smoother than longpolling.
Was using something like this on the machine which ran arena:
Code: Select all
#!/bin/bash
arenaLog='/home/arena/arena.debug'
a=`(stat -c%s $arenaLog)`
d=1
while true
do
if [[ $a == `stat -c%s $arenaLog` ]]
then
sleep 0.11;
else
gamedataARRAY=(`grep tbhits $arenaLog|tail -1| sed 's/.*info //g'`)
#echo ${gamedataARRAY[3]} # fourth element
for i in ${!gamedataARRAY[@]}
do
iplus1=$(( $i + 1 ));
if [ "${gamedataARRAY[$i]}" = 'depth' ]
then
depth="${gamedataARRAY[$i+1]}"
if [[ "$d" -gt "$depth" ]]
then
echo "d > depth -- d=$d depth=$depth"
echo "SEND A RESET $d $depth"
d=$depth
reset=1;
else
reset=0
echo "d <= depth -- d=$d depth=$depth"
d=$depth
fi
fi
if [ "${gamedataARRAY[$i]}" = 'time' ]
then
time="${gamedataARRAY[$i+1]}"
time=$(( $time / 1000 ));
time=`(date -u --date="@$time"|cut -b15-19)`
fi
if [ "${gamedataARRAY[$i]}" = 'tbhits' ]
then
tbhits="${gamedataARRAY[$i+1]}"
#pv="${testarray[@]:6}"
fi
if [ "${gamedataARRAY[$i]}" = 'nps' ]
then
nps="${gamedataARRAY[$i+1]}"
nps=$(( $nps / 1000 ))
nps=`(printf "%'.0f\n" $nps)`
fi
if [ "${gamedataARRAY[$i]}" = 'nodes' ]
then
nodes="${gamedataARRAY[$i+1]}"
nodes=`(printf "%'.0f\n" $nodes)`
fi
if [ "${gamedataARRAY[$i]}" = 'cp' ]
then
cp="${gamedataARRAY[$i+1]}"
cp=`(echo "scale=2;$cp"/100|bc -l|sed -e 's/^\./0./' -e 's/^- \./-0./')`;
fi
if [ "${gamedataARRAY[$i]}" = 'pv' ]
then
#pv="${gamedataARRAY[$i+10]}"
#All elements following element[0].
#echo ${arrayZ[@]:1} # two three four five five
#Only the two elements after element[0].
#echo ${arrayZ[@]:1:2} # two three
pv="${gamedataARRAY[@]:$iplus1:6}"
fi
if [ "${gamedataARRAY[$i]}" = 'hashfull' ]
then
hashfull="${gamedataARRAY[$i+1]}"
fi
done
line=`(echo "<i id=d>$depth</i> <i id=t>$time</i> <i id=n>$nodes</i> <i id=nps>$nps kN/s</i> <i id=cp>$cp</i> <i id=pv>$pv</i>")`;
if [[ $reset == 1 ]]
then
ssh -p$sshport -C $sshuser@$sship "echo ' ' >> gamedata;echo ' ' >> gamedata; echo ' ' >> gamedata;echo ' ' >> gamedata;exit"
reset=0
else
echo "$line"|ssh -p$sshport -C $sshuser@$sship "cat >> gamedata;exit"
fi
date
sleep 0.4;
a=`(stat -c%s $arenaLog)`
fi
done
index.js
Code: Select all
var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);
Tail = require('tail').Tail;
app.get('/', function(req, res){
//send the index.html file for all requests
res.sendFile(__dirname + '/index.html');
});
http.listen(3001, function(){
console.log('listening on *:3001');
});
// send 'msg' to client & console every 1000ms
setInterval( function() {
var tail = new Tail("test.txt");
tail.on("line", function(data) {
io.emit('line', data);
console.log('line', data);
});
var msg = Math.random();
// io.emit('message', msg);
// console.log (msg);
}, 500);
Code: Select all
<html>
<head></head>
<body>
<div id="message"></div>
<div id="line"></div>
<script src="/socket.io/socket.io.js"></script>
<script>
var socket = io();
socket.on('message', function(msg){
console.log(msg);
document.getElementById("message").innerHTML = msg;
}
);
socket.on('line', function (data) {
console.log(data);
document.getElementById("line").innerHTML = data;
});
</script>
</body>
</html>
package.json
{
"dependencies": {
"express": "^4.13.3",
"socket.io": "^1.3.6"
}
}
-
- Posts: 4833
- Joined: Sun Aug 10, 2008 3:15 pm
- Location: Philippines
Re: Live broadcast of engine pv
No. I reformat the livepgn that is sent to the server, added [%pv moves...] to the move comment of the last move in the live pgn.Rebel wrote:Nice!Ferdy wrote:Finally implemented here.
http://www.chess.x10host.com/pgn4web/index.html
I rewrite the pgn output of ChessGUI to a different format, now the pv (taken from TLCV_File.txt output from ChessGUI) is embeded as part of move comment, so now I get pgn and pv at the same time, send it to server via ftp, then extract the pv via pgn4web custom function, and just use a javascript to display the pv on the page, no more server scripts needed.
I think Matthias Gemuh author of ChessGUI can easily incorparate this change, adding pv to the move comment.
Did you have to change your engine to make it work?
This [%pv moves...] can be extracted using pgn4web custom function.
-
- Posts: 4833
- Joined: Sun Aug 10, 2008 3:15 pm
- Location: Philippines
Re: Live broadcast of engine pv
ChessGUI can, the option to output it has to be activated so that it will output [%clk...Rebel wrote:Only if ChessGui has PGN clock support, Arena hasn't. From the PGN4WEB documentation:Graham Banks wrote:Nice!
Any chance of clocks being added?
Code: Select all
Clock information as provided by the DGT chessboards in PGN move comments, such as {[%clk 1:59:59]}, and in the PGN header, such as [WhiteClock "2:00:00"], [BlackClock "2:00:00"] and [Clock "W/1:59:59"] is displayed in the following sections: <div id="GameWhiteClock"></div> <div id="GameBlackClock"></div>
-
- Posts: 4833
- Joined: Sun Aug 10, 2008 3:15 pm
- Location: Philippines
Re: Live broadcast of engine pv
Thanks for the post.Jesse Gersenson wrote:The problem is making something which works with more than one GUI. InBetween, or something similar, which is between the gui and the engine would give you independence from the GUI and/or the engine logs.Ferdy wrote:How do you show to a web page the engine pv's during broadcast?
I wrote something last year which parsed arena's debug file and then fed this to node.js via ssh. It showed pv output, the refresh rate was limited by how quickly new lines of pv data could get to the web server. Was much smoother than longpolling.
Was using something like this on the machine which ran arena:And something like these two files, index.html and index.js, on the web server:Code: Select all
#!/bin/bash arenaLog='/home/arena/arena.debug' a=`(stat -c%s $arenaLog)` d=1 while true do if [[ $a == `stat -c%s $arenaLog` ]] then sleep 0.11; else gamedataARRAY=(`grep tbhits $arenaLog|tail -1| sed 's/.*info //g'`) #echo ${gamedataARRAY[3]} # fourth element for i in ${!gamedataARRAY[@]} do iplus1=$(( $i + 1 )); if [ "${gamedataARRAY[$i]}" = 'depth' ] then depth="${gamedataARRAY[$i+1]}" if [[ "$d" -gt "$depth" ]] then echo "d > depth -- d=$d depth=$depth" echo "SEND A RESET $d $depth" d=$depth reset=1; else reset=0 echo "d <= depth -- d=$d depth=$depth" d=$depth fi fi if [ "${gamedataARRAY[$i]}" = 'time' ] then time="${gamedataARRAY[$i+1]}" time=$(( $time / 1000 )); time=`(date -u --date="@$time"|cut -b15-19)` fi if [ "${gamedataARRAY[$i]}" = 'tbhits' ] then tbhits="${gamedataARRAY[$i+1]}" #pv="${testarray[@]:6}" fi if [ "${gamedataARRAY[$i]}" = 'nps' ] then nps="${gamedataARRAY[$i+1]}" nps=$(( $nps / 1000 )) nps=`(printf "%'.0f\n" $nps)` fi if [ "${gamedataARRAY[$i]}" = 'nodes' ] then nodes="${gamedataARRAY[$i+1]}" nodes=`(printf "%'.0f\n" $nodes)` fi if [ "${gamedataARRAY[$i]}" = 'cp' ] then cp="${gamedataARRAY[$i+1]}" cp=`(echo "scale=2;$cp"/100|bc -l|sed -e 's/^\./0./' -e 's/^- \./-0./')`; fi if [ "${gamedataARRAY[$i]}" = 'pv' ] then #pv="${gamedataARRAY[$i+10]}" #All elements following element[0]. #echo ${arrayZ[@]:1} # two three four five five #Only the two elements after element[0]. #echo ${arrayZ[@]:1:2} # two three pv="${gamedataARRAY[@]:$iplus1:6}" fi if [ "${gamedataARRAY[$i]}" = 'hashfull' ] then hashfull="${gamedataARRAY[$i+1]}" fi done line=`(echo "<i id=d>$depth</i> <i id=t>$time</i> <i id=n>$nodes</i> <i id=nps>$nps kN/s</i> <i id=cp>$cp</i> <i id=pv>$pv</i>")`; if [[ $reset == 1 ]] then ssh -p$sshport -C $sshuser@$sship "echo ' ' >> gamedata;echo ' ' >> gamedata; echo ' ' >> gamedata;echo ' ' >> gamedata;exit" reset=0 else echo "$line"|ssh -p$sshport -C $sshuser@$sship "cat >> gamedata;exit" fi date sleep 0.4; a=`(stat -c%s $arenaLog)` fi done
index.jsCode: Select all
var app = require('express')(); var http = require('http').Server(app); var io = require('socket.io')(http); Tail = require('tail').Tail; app.get('/', function(req, res){ //send the index.html file for all requests res.sendFile(__dirname + '/index.html'); }); http.listen(3001, function(){ console.log('listening on *:3001'); }); // send 'msg' to client & console every 1000ms setInterval( function() { var tail = new Tail("test.txt"); tail.on("line", function(data) { io.emit('line', data); console.log('line', data); }); var msg = Math.random(); // io.emit('message', msg); // console.log (msg); }, 500);
package.js:Code: Select all
<html> <head></head> <body> <div id="message"></div> <div id="line"></div> <script src="/socket.io/socket.io.js"></script> <script> var socket = io(); socket.on('message', function(msg){ console.log(msg); document.getElementById("message").innerHTML = msg; } ); socket.on('line', function (data) { console.log(data); document.getElementById("line").innerHTML = data; }); </script> </body> </html>
package.json
{
"dependencies": {
"express": "^4.13.3",
"socket.io": "^1.3.6"
}
}
I am new to this thing, and is working on windows, I tried to experiment it (based from Ed's project) on free account host and not able to run server script like node js. I have a working example here.
http://www.chess.x10host.com/pgn4web/index.html
It just show one pv at a time or every 1 sec, pgn with pv is sent to the sever, then read the pv via javascript and display it on a page the rest of the pgn is handled by pgn4web.
So how this works? You read arena log, create a data according to your needs and send it to server, server runs the node js, further processing the data. How the board is displayed on the page? does it use pgn4web?