Coder Social home page Coder Social logo

board display about fbuci HOT 49 CLOSED

mdoege avatar mdoege commented on September 24, 2024
board display

from fbuci.

Comments (49)

mdoege avatar mdoege commented on September 24, 2024

Make sure your framebuffer resolution is 1920x1080 or change the code accordingly.

Also, you don't need to be root. Just add yourself to the video group like the README says. At least on Arch this works...

from fbuci.

tissatussa avatar tissatussa commented on September 24, 2024

Make sure your framebuffer resolution is 1920x1080 or change the code accordingly.

i have no idea how to do that on Xubuntu .. however, i often work in terminal and i can find and edit config files.

Also, you don't need to be root. Just add yourself to the video group like the README says. At least on Arch this works...

i saw that info, but it's also unknown to me : how to add a user (not root) "to the video group" ?

from fbuci.

mdoege avatar mdoege commented on September 24, 2024

I think you just need to take your screen resolution and put it in line 18 of fbuci.py. Note that the board needs 1000x1000 pixels, so if your resolution is lower than 1080p, it will not work.

As for adding to the video group, I think you have to google how this works on Ubuntu. On Arch you can just edit /etc/group as root.

from fbuci.

tissatussa avatar tissatussa commented on September 24, 2024

I think you just need to take your screen resolution and put it in line 18 of fbuci.py. Note that the board needs 1000x1000 pixels, so if your resolution is lower than 1080p, it will not work.

well, i found my resolution is 1680 x 1050 (although this seems a little weird) and so i adjusted line 18 ..

As for adding to the video group, I think you have to google how this works on Ubuntu. On Arch you can just edit /etc/group as root.

yes, i found that config file and i added my user name just as i see it on other lines of that file .. then i even rebooted .. now, indeed i can just do python3 ./fbuci.py and play chess, but no graphics .. the framebuffer device /dev/fb0 can be accessed and it seems i have all required modules installed .. but i get no error : the img/ folder exists and contains the images .. should i see the board INSIDE terminal ? I never saw such ..

from fbuci.

tissatussa avatar tissatussa commented on September 24, 2024

btw. i used the default xfce4-terminal and also Konsole (KDE) but both show no graphics.

from fbuci.

tissatussa avatar tissatussa commented on September 24, 2024

btw. the functions draw_board() and draw_square() are processed .. i added some print() to test this .. i have no errors .. PIL is installed.

from fbuci.

mdoege avatar mdoege commented on September 24, 2024

You need to run this program in the Linux framebuffer terminal, not under X Window! The framebuffer is what you see before X starts, with the Linux boot info scrolling by quickly. So you would need to exit X Window first somehow or not start it in the first place: https://wiki.ubuntu.com/X/NonGraphicalBoot

If you want something that runs under X, take a look at https://github.com/mdoege/pygameUCI You need a USB gamepad or joystick for that one though...

from fbuci.

tissatussa avatar tissatussa commented on September 24, 2024

mmm .. i'm unfamiliar with "Linux framebuffer terminal" .. i also found https://www.kernel.org/doc/html/latest/fb/fbcon.html and i try to understand and make it work .. thanks!

from fbuci.

tissatussa avatar tissatussa commented on September 24, 2024

OK, i found https://unix.stackexchange.com/questions/23363/command-line-to-return-to-the-gui-after-ctrl-alt-f1 and indeed : Ctrl-Alt-F1 brings me to the Linux Framebuffer terminal .. this way i also found the w command :

roelof@roelof-HP-Elite-x2-1012-G2:~$ w
 21:26:47 up 7 min,  2 users,  load average: 0,32, 0,46, 0,29
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
roelof   tty7     :0               21:19    7:30  32.58s  0.32s xfce4-session
roelof   tty1     -                21:22    4:04   0.08s  0.03s -bash

so, i should be able to return to the Xubuntu GUI by Alt-F7 and...it works! Now, in the framebuffer terminal (after login) when i do python3 ./fbuci.py i can play chess and i see SOME graphics ! But they are distorted .. probably my W x H settings are not good .. i will look into this .. i'm close now, i think !?

from fbuci.

mdoege avatar mdoege commented on September 24, 2024

Yes, a distortion probably means something is wrong with the resolution setting in line 18.

I completely forgot about Ctrl-Alt-Fx switching. But that is a nice and simple method.

I use startx from the console, so to get back to the console I can just quit my window manager.

from fbuci.

mdoege avatar mdoege commented on September 24, 2024

P.S. Maybe lower xoff in line 19. E.g. "xoff, yoff = 500, 100 # screen offset"

from fbuci.

tissatussa avatar tissatussa commented on September 24, 2024

i've done it !
now i see your board in the framebuffer terminal !

it seemed i had the wrong screen dimensions .. my screen can do a high resolution 2736 x 1824 (this is the highest in the display resolution list and it has a star *) but i set 1680 x 1050 because normally that's enough .. i don't like very small texts etc. .. but i guessed the framebuffer terminal needs the high default value, so i did :

fbw, fbh = 2736, 1824 # framebuffer dimensions

i can not provide a screenshot (can i ?) but it's working now.
thanks for your help, i learned a lot today ..

from fbuci.

mdoege avatar mdoege commented on September 24, 2024

You're welcome. Great to hear that it is working now!

You can also select a larger font for the framebuffer, which is nice for higher resolutions. On Arch, I can set it in /etc/vconsole.conf, e.g. "FONT=solar24x32". The default console font is tiny at 1080p on my 24" screen.

You can take a screenshot of the framebuffer with the fbgrab utility...

from fbuci.

tissatussa avatar tissatussa commented on September 24, 2024

thanks, i will study that and try it .. in the meantime i played a game and won within 30 moves .. without being able to screenshot yet, i wrote the moves by hand .. you'd like it https://lichess.org/qgRFqH28 :

[Event "human vs engine"]
[Site "Holland"]
[Date "2022.10.02"]
[White "Roelof Berkepeis"]
[Black "nimTuroChamp"]
[Result "1-0"]

1.e4 e6 2.Qe2 Nc6 3.Nf3 h5 4.d4 d5 5.e5 Bd7 6.h3 Bb4+ 7.c3 Bf8 8.Be3 a5 9. a4 Nh6 10.g4 hxg4 11.hxg4 Ra6 12.g5 Rb6 13.gxh6 Rxh6 14.Bxh6 gxh6 15.Qc2 Bc8 16.Bb5 Bd7 17.Qh7 Bc8 18.Qg8 Ke7 19.Nbd2 Bd7 20.Nf1 f6 21.exf6+ Kxf6 22.Ne3 Qe8 23.Ng4+ Kf5 24.Qh7+ Kxg4 25.Ke2 e5 26.Rag1+ Kf4 27.Rh4+ {And Black 'resigned' .. it's mate on the next move.} 1-0

from fbuci.

mdoege avatar mdoege commented on September 24, 2024

Alas, poor nimTuroChamp! I knew him well, Horatio. But then he blundered away his Rook and lost. So sad. :)

Of course you could add automatic PGN output after every move to fbuci.py. My Python engines do this: https://github.com/mdoege/PyTuroChamp/blob/bc761fa02bcef8d3d52f08a3b724a4bf68e4f3f3/ptc_xboard.py#L109

from fbuci.

tissatussa avatar tissatussa commented on September 24, 2024

yes, i just added some extra code to log the moves : fbuci.zip and i added some comments. Cheers !

from fbuci.

tissatussa avatar tissatussa commented on September 24, 2024

btw. i don't like the purple last-move color .. how can it be changed ?

from fbuci.

mdoege avatar mdoege commented on September 24, 2024

fbUCI/fbuci.py

Line 20 in 766c3ee

hicolor = (100, 0, 100, 100) # highlight color (RGBA)

from fbuci.

tissatussa avatar tissatussa commented on September 24, 2024

sure .. tnx.

from fbuci.

tissatussa avatar tissatussa commented on September 24, 2024

i'm still experimenting and learning about the framebuffer terminal .. i found 'fbterm' and i installed it on my Xubuntu (just with the default Synaptic package manager) and eg. now i'm able to change the font size by editting ~/.fbtermrc .. your fbUCI seems to work in fbterm, but i expected scrolling also : when playing a game and many moves are made, no vertical scrolling can be done and the output becomes invisible .. i have to press Enter many times to see the last moves .. is this normal ? Can scrolling be enabled when using a framebuffer terminal ? Or is my approach not right ? I read fbterm should be compiled (!?) with an option to enable 'GPM' but all this seems complicated to me and maybe not needed at all ? BTW. can a framebuffer terminal do text selection by mouse anyway ? Do alternative framebuffer terminal apps exist ?

from fbuci.

mdoege avatar mdoege commented on September 24, 2024

I think simple framebuffer graphics like from fbuci.py are always static and cannot scroll.

There are also web browsers and image viewers for the framebuffer. I am not sure about other terminals. But in the web browser, e.g. links2, you can definitely use the mouse too if GPM is installed.

If you want scrolling graphics in a terminal, you could look into sixel graphics. I have experimented a bit with sixel graphics under X. However, if you put many sixel graphics into a terminal, one after the other, performance can become a problem. Also, the Linux console does not support sixels right now, so this is only something for X-based terminals.

from fbuci.

tissatussa avatar tissatussa commented on September 24, 2024

mmm .. and how do YOU use the fbuci output when playing ? Do you encounter the same 'problem' when many moves are played and displaying them has reached the bottom of the screen ? Or is fbuci.py just simple and it's not a bug but a feature ?

i found links2 in my Synaptic and installed it .. i also have to study GPM and install it, i guess.

from fbuci.

mdoege avatar mdoege commented on September 24, 2024

For me, the left side of the screen with the moves scrolls up when full, but the right with the board stays fixed in place and does not scroll. So redrawing is only necessary after switching virtual consoles.

fbuci.py calls the clear command in line 28 to clear the screen. I hope other distros have this too. Otherwise you can press Ctrl-L to clear the screen before starting the program.

from fbuci.

tissatussa avatar tissatussa commented on September 24, 2024

i'm beginning to understand .. i use 2 monitors, one is the default notebook display (which is small but has a high resolution), the second is my main monitor, about 37 inch, so rather big .. indeed, my notebook display shows the behaviour you describe : it scrolls up when full (i didn't mention this until now, sorry) .. i guess my resolution setting of the second big monitor are not OK when using a framebuffer terminal. I have to look into that again ..

btw. the logging of moves in my editted fbuci.py was incomplete : now i added fLog.flush() after writing a move to game.pgn, otherwise that file is only filled with the moves after fbuci.py has quit.

from fbuci.

mdoege avatar mdoege commented on September 24, 2024

Well I am glad you don't have to stare at that 12" Surface Pro 4 display all day. :-)

I think the framebuffer remembers where characters are printed on screen and only scrolls up that rectangle. So keep your terminal lines short and make sure the screen is cleared first. Otherwise the board will scroll up too.

from fbuci.

tissatussa avatar tissatussa commented on September 24, 2024

thanks.
another thing about the fbuci.py script : it seems 's' can show the Score but nothing happens : it shows 'unknown' every time i try .. this happens with NTC and also SF .. however, when using NTC and SF in CuteChess, the score IS shown, eg. '0.02' etc. .. it's all about result.info.get("score", "unknown") which is a python-chess command (i know, i coded some app with that nice Python module). Am i missing something ? Is it a bug ?

from fbuci.

mdoege avatar mdoege commented on September 24, 2024

Python-chess may have changed its UCI engine API a bit since I wrote fbuci.py. Looking at https://python-chess.readthedocs.io/en/latest/engine.html#playing, apparently result is an instance of chess.engine.PlayResult() and info is an instance of chess.engine.InfoDict. I still don't understand why it prints unknown though.

Maybe try to change line 136 so it prints the complete result.info dictionary instead. Then you can see if the score is in there or not...

from fbuci.

tissatussa avatar tissatussa commented on September 24, 2024

yes, i also had other troubles with python-chess concerning versions .. seems familiar, i will look into this and let you know how i solved it .. i also want to add info of the time spend on each move, like CuteChess does.

from fbuci.

tissatussa avatar tissatussa commented on September 24, 2024

btw. i just talked to my brother (also a Linux fan) and asked him about Framebuffer terminal .. he'd never heard of that .. however, /dev/fb0 did ring a bell by him .. then he asked me : why should anyone write an application using framebuffer terminal ? What's the advantage ?

from fbuci.

mdoege avatar mdoege commented on September 24, 2024

All that information should be in the info line from UCI engines, so the only question is how python-chess stores that info in its dictionary...

Python-chess is indeed a bit of a moving target in terms of their API. They like to break things. So for bigger projects like Picochess, it is usually better to stick to an older python-chess version that works for them.

from fbuci.

tissatussa avatar tissatussa commented on September 24, 2024

yes, i once managed to use several python-chess versions next to eachother .. i have to investigate how i did that though .. i remember it's something with using env.

from fbuci.

tissatussa avatar tissatussa commented on September 24, 2024

btw. this evening i will play my weekly chess game at my club, OTB (Over The Board) .. will be continued!

from fbuci.

mdoege avatar mdoege commented on September 24, 2024

And I am probably going to watch that 2014 film about Bobby Fischer starring Tobey Maguire on German TV ("Servus"). Sounds like a chess-filled evening for both of us...

from fbuci.

tissatussa avatar tissatussa commented on September 24, 2024

nice ! you mean "Pawn Sacrifice", see https://www.imdb.com/title/tt1596345/
i once copied that film ..

i won my game with Black .. it was a hard struggle against a 1550 player (me about 1800) : https://lichess.org/5QOPdK9H/black .. i was worse the whole game, but he didn't manage to create a win.

from fbuci.

mdoege avatar mdoege commented on September 24, 2024

Nice game! That shows some Carlsen-like dedication to turn a lost game around like that. ;)

Yes, that's the film. I have a Fischer-Spassky reproduction chess set, so I suppose I had to see it. The movie was alright. There is some bitching online that certain chess and historical details were wrong, but when I see a Hollywood movie I do not expect a historical documentary. Clearly they could have tried to find an actor who looks more like Bobby Fischer, but I suppose Maguire produced it, so he just gave himself the role.

Unfortunately the scenes with Russian dialog were not subtitled on German TV, so I could only guess what Spassky (Schreiber) was saying. But the screenplay is online as a PDF, so I will just read that to see what I missed.

from fbuci.

tissatussa avatar tissatussa commented on September 24, 2024

i made a new version of fbuci.py : fbuci_221005a.zip
the score issue is solved .. i added many comments in the source .. engine.play() needs a 'info' attribute in the python-chess version .. i also did some small fixes and enhancements .. config settings at source top can be extended.

lately i also found the nice chess python script https://github.com/rafaelvleite/centipawn_loss_calculator .. concerning the recent chess cheating scandal : how accurate were the moves of a game ? I saw the Brazilian coder Rafael Vicente Leite in a recent YT clip of Hikaru Nakamura, and i found his concerning GitHub project .. but the coding seems (too) simple -might have been a weekend project- and i adjusted many things :
centipawn_loss_calculator_221005a.zip it also uses the python-chess module .. i guess you can use this script out of the box ..

from fbuci.

mdoege avatar mdoege commented on September 24, 2024

How does uploading these ZIP files work? I am a bit concerned that random GitHub users can apparently upload arbitrary content and host it under my repo. If you want to contribute to projects, please fork them under your own user name and push commits there. How can I delete these ZIPs?

I have looked into centipawn loss for possible difficulty levels for adapt.py, so users could set their Elo. But in the end it seemed to be only reasonably well defined for grandmaster strength > 2400 Elo and not < 2000 Elo, the range I was looking for.

The only part about the Niemann affair I don't understand is why there is so much controversy. Obviously he cheated and he confessed it, so I don't get why Carlsen is suddenly portrayed as the bad guy in some media coverage.

from fbuci.

tissatussa avatar tissatussa commented on September 24, 2024

I will comment on the Niemann case later .. about the ZIPs : i just drop them into the comment box, i guess they are uploaded into a folder on the server just for this issue communication section, so don't worry .. you can edit (my) comments and remove them, i guess, it's just a path to the file .. i never seriously created or forked any github project, sorry, i don't know how to push etc .. the functions and steps are hard to understand at first ..

from fbuci.

tissatussa avatar tissatussa commented on September 24, 2024

it's not fully clear to me how centipawn loss should work .. i tested that script with different ratings on the same game but the result was no different .. maybe this script does not regard the ratings, although we see Rating in the output .. shouldn't centipawn loss be relative to the player rating ?

from fbuci.

tissatussa avatar tissatussa commented on September 24, 2024

i think the media and video streamers do focus too much on the issue .. it's a hot topic though, and now it's fully discussed .. also how to prove and act upon it .. i think Magnus overreacted at first .. their characters might conflict also .. Hans has fantastic ideas, but this genious can lose too .. i personally don not think he cheated OTB .. Magnus always wants to win .. he tries to reach 2900 rating OTB .. but lost that Niemann game .. ease of using engines will be addressed now, it's important for the future of chess.

from fbuci.

mdoege avatar mdoege commented on September 24, 2024

If you want to contribute to GitHub projects, you have to learn how to commit, push, and start a pull request. Forking itself is just one button press. Either learn the command line tools or use a GUI helper. Uploaded ZIP files with code, even if the code is good, will be probably be ignored by most maintainers. Forks and pull requests are the GitHub process.

Niemann's playing strength seems to wane suddenly as soon as a broadcast delay is introduced. And he confessed to cheating in other games, so he has zero credibility. Liar, liar, pants on fire.

And yes, Magnus always wants to win, but that is precisely what I like about him. And it is besides the point. This is about Niemann, not Carlsen.

Has this become another one of those US vs Europe things because Niemann is American and Carlsen is Norwegian? Is that why this is pushed so much in the media?

from fbuci.

tissatussa avatar tissatussa commented on September 24, 2024

Has this become another one of those US vs Europe things because Niemann is American and Carlsen is Norwegian? Is that why this is pushed so much in the media?

i'm in Holland, Europe, and i never thought about that.

And yes, Magnus always wants to win, but that is precisely what I like about him.

i like that about him too.

And it is besides the point. This is about Niemann, not Carlsen.

well, Carlsen could just have continued playing .. he could insist though to investigate the game and then if cheating would be proved, his loss would be corrected. I think his withdraw was emotional.

Niemann's playing strength seems to wane suddenly as soon as a broadcast delay is introduced.

i think delay is a simple and good method. I didn't hear or read something about '-suddenly as soon as-' .. different opinions and 'proves' exist, i don't know. Remember Niemann only confessed cheating online, which is easier then OTB. Regarding OTB i think Niemann is not a liar, we'll see ..

from fbuci.

mdoege avatar mdoege commented on September 24, 2024

Carlsen is normally fairly balanced emotionally, so if he flies off the handle I am willing to give him the benefit of the doubt. He has lost badly before, but I don't remember such a scene from him.

So lets talk less about Carlsen and more about Niemann and his putative collection of Morse code-vibrating dildoes. :) I am surprised the news media are not going for the sex angle on this. Normally they love to make every story about sex somehow.

from fbuci.

tissatussa avatar tissatussa commented on September 24, 2024

yes, i saw some didoes vribrant related vids ..

do you still mind my ZIPs ? Doing a github setup like you described is good, but these are just single .py file .. i tend to learn github though .. did you know dropping of images is possible and even videos : a nice player is embedded! A few times i saw such in github issue comments .. also look at the bottom of this comment screen (when typing) : it says Attach files by dragging and dropping..

from fbuci.

mdoege avatar mdoege commented on September 24, 2024

I have never seen attached files on GitHub before. Maybe this is a new feature? Anyway, for code it is not very convenient.

Your ZIPs can stay for now. But I think it is in your own best interest to learn the proper GitHub process for submitting pull requests. A pull request can be merged within minutes if it looks okay. A ZIP file on the other hand is more in the territory of "I'll look at it when I have time", which may be never... ;-)

from fbuci.

tissatussa avatar tissatussa commented on September 24, 2024

in your code of fbuci.py i see the framebuffer dimensions are declared :

# fbw, fbh = 1920, 1080

but it seems fbh is never used in the code ?
btw. i changed the values to 2736, 1824 for my current display.

as i stated earlier, on my display the move list is not scrolling when it reaches the screen bottom .. how can i change this ?
btw. also by using fbterm i have this problem, even when changing the font size (in ~/.fbtermrc).

from fbuci.

mdoege avatar mdoege commented on September 24, 2024

Maybe the bad scrolling behavior on the external display is related to your graphics card or graphics driver? I use a desktop PC (with an AMD graphics card) and a Pi, and text scrolling works properly on both systems. Maybe ask about this in your distro forums? External laptop displays can be weird.

Yes, I suppose fbh is never used. This is my first program for the Linux framebuffer, so I started the program with only a vague idea of how it would actually work. Learning by doing. And unlike Go, Python does not flag unused variables, so it happens... :-)

I think initially I had the idea to render everything on screen, i.e. the board and move list, to a fbw*fbh-sized image and blit that to the screen after each move. But that approach turned out to be far too slow for the Pi. (For the PC it might have been OK.) So maybe fbh is a remnant of that early idea.

Originally I wanted to create something closer to the interface of Sargon or other 1970s/1980s chess programs, including the typography. But performance considerations steered me into a more Pi-friendly approach with only a few squares being updated on each move. You can still see the 1970s influence in the board labels though: Apple Garamond italic, very flamboyant. 1970s/early 1980s software often featured strongly calligraphic typefaces.

from fbuci.

tissatussa avatar tissatussa commented on September 24, 2024

clear, thanks .. learning by doing - i like that .. i feel your appraoch to (Linux) programming is same as mine : discover how things work, searching for answers and thus discovering more new things (linux framebuffer..what is that?) .. like i just discovered the tqdm module .. thus creating more things.

btw. where are you from? USA? age? chess rating? just curious ..

from fbuci.

tissatussa avatar tissatussa commented on September 24, 2024

recently i created some terminal chess program to do "test suite" evaluations with many selected 'puzzle' FENs .. it works, but the cursor movement is troublesome : TTY and print escape chars are hard to code .. i have to rewrite that code to make it work properly on any (?) terminal and maybe tqdm will be helpful .. see eg. my screencast at https://github.com/algerbrex/blunder/issues/13 (sound on!)

from fbuci.

Related Issues (1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.