Page 1 of 3
Improving your code development skills
Posted: Fri May 21, 2021 1:40 pm
by wiak
Tip of the day: Chess
Play chess often and you will develop your strategical, tactical, and pattern matching abilities all of which are core programming skills. A complex bit of programming is like a complex chess game - you have to remember where things are, the positions, the patterns. Over time you become expert at recognising patterns and their repetition, even when they are somehow represented differently, still you can see the underlying pattern or algorithm used. And like chess, there are generally complex relationships between the different parts of a program, a symphony that if conducted well leads to some desired end or other.
Drawback: the time taken playing chess takes from the always too short time you have have available for the thousands of hours of coding you should be getting on with.
However: better to spend less hours writing better and more cleverly constructed efficient code than just plugging away for hours on end, duplicating, cherry-picking, stealing, re-coding, writing cumbersome long-winded, hacked, fragmented, spaghetti 'programs', which are almost indecipherable for others to interpret (sometimes on purpose), whether the result 'works' to some extent or not.
Nice game chess. I wish I had more time to play it. Similar to Linux programming also in that you have almost as much chance to make money playing chess as you do open-source programming (possibly more chance playing chess since can do podcasts and get far more followers of that than similar Linux podcasts and the like - people like to be entertained and chess can be entertaining - Linux not so much, at least not for so many).
Re: Improving your code development skills
Posted: Fri May 21, 2021 7:33 pm
by Clarity
As I use to play Chess often, I find the "best" for me and use with kids is Checkers. Its both timeless and gives the best instructions for logical thught process that kids love. It leads them to clarity in coding logic. In the time it takes to play one chess game against the computer, I could play many checker games using the same logic against the computer.
The difference: Chess is a 6-level caste system game while Checkers is a 2-level caste game. But the logic skillset is exactly the same.
Lighthouse, by @TaZoC, produced the ONLY PUP that included it for the many Lighthouse versions he produced his 32+64 bit PUPs.
I wish it was/could be brought over in PUPs in the Menu>Games(FUN) area. Its extremely small and fun.
Re: Improving your code development skills
Posted: Sat May 22, 2021 3:22 am
by Grey
In the old days, I was the champion of the school. Now, sometimes only play with my retired neighbor. Some years ago, a neighbor told me that all schoolchildren on smartphones would only play chess. ..... Yes, of course, for sure everyone will be - I assented to him But all is not lost, a chess tournament is taking place on the Town Day.
Earlier in my town people played chess in droves right on the street. Now, near the car service stations workers play backgammon and dominoes, but not chess.
wiak wrote: ↑Fri May 21, 2021 1:40 pm
chess can be entertaining - Linux not so much, at least not for so many
Interesting comparison
Re: Improving your code development skills
Posted: Sun May 23, 2021 1:34 am
by Grey
A fresh and funny case. The deputy chief of staff of the Russian presidential administration said yesterday that DOTA 2 and Chess are difficult games. But DOTA 2 is better because it is a TEAM game. For the second day there have been disputes about which game is better. I don't even know how to react
Re: Improving your code development skills
Posted: Sun May 23, 2021 2:07 am
by rockedge
In Hamburg they hold a chess tournament among the schools. There is a lake in the middle of the city called the Alster. All the schools on the left side play against the schools on the right side of the lake. For one day all the schools are closed and each school sends a team to the convention center, where it is held. Chess was taught at my son's school and had a team. He came in 2nd in the 2007 Hamburg Open Youth Chess Tournament at 11 years old. He played in the final against a 17 year old and lost. I taught him to play around 4-5 and now I can not beat him. Last time I won a game he was 12.
Re: Improving your code development skills
Posted: Sun May 23, 2021 2:50 am
by Grey
rockedge wrote: ↑Sun May 23, 2021 2:07 am
In Hamburg they hold a chess tournament among the schools.
Yes, this is a good tournament system. Hamburg and Saint Petersburg are twin cities or Partnerstädte and in general are somewhat similar. And the systems are almost the same.
Re: Improving your code development skills
Posted: Sun May 23, 2021 6:32 am
by wiak
rockedge wrote: ↑Sun May 23, 2021 2:07 ammy son...I taught him to play around 4-5 and now I can not beat him. Last time I won a game he was 12.
I'm continuing to try and hold back the tide, and aside from one major glitch I was succeeding to do so. I taught my two daughters and two sons chess around 5 years of age and the girls (who are the eldest) were school team chess captains. However, they rarely managed to beat me, nor the boys. However, last time my younger daughter visited here from her current home in London she beat me in the only two games we played then (despite the fact I had taken up playing again - online - and she never played at all normally any more...). Oh well, aside from that loss, which I have had no chance to amend (since she has returned to London, and online games would not suffice) I remain the king in our house (tho perhaps that loss means I am desposed).
My father also taught me to play when I was 4 or 5, and by the time I was near to teenage he could no longer beat me. It didn't stop him trying - I remember playing him nineteen games in a row one evening and defeating him in every game (I understood the way he played and what he hated to defend against, so it was quite easy for me despite him otherwise being quite a good player really...).
Later in life, I once visited Fiji and there were many backpackers playing chess regularly on a remote offshore island there. I only played one game - against a young German guy, and I lost badly (my excuse is that I was ill with a fever at the time...). Anyway, the same guy visited me in New Zealand and over the course of a few days we played 49 games... He lost every game, apart from one, which he managed to draw, but he failed to win despite my having blundered away my queen... - he asked incredulously "how come you didn't manage to beat me in Fiji?". Anyway, I didn't - so that complete Fiji match belongs to him. Of course, I enjoyed my revenge since it was clear to me on Fiji that he thought I was an idiot at chess, and I think he imagined that Scottish people are likely to be pretty hopeless at the game, which relative to Russians I am sure we are...
However, at chess, I am not so careful nowadays, and I take crazy risks (because I enjoy dramatic positions/sacrifice), which I never used to - and have become too lazy to be bothered trying to think ahead more than a couple of moves - and I've also become pretty slow when I try to analyse positions, whereas as a teenager I seemed to think positions/combinations through at lightning speed. I (half) hope all my children manage to consistently defeat me one day, but I remain determined to make that as difficult as possible for them, and psychologically they remain at the disadvantage of imagining I am almost unbeatable (alas online games prove that is far from true - but, in defence, I find it difficult to take online play seriously whereas face-to-face I try a LOT harder). I definitely find more complex programming issues a bit like chess - with so many combinations, but so many faulty lines of logic too easy to step into.
Re: Improving your code development skills
Posted: Sun May 23, 2021 8:24 pm
by Grey
Now I don’t know, but there used to be good children's books about chess. In the late 70s and early 80s, there were books by the Bulgarian writer Nikolay Miziyski. He had a cycle of chess novels and stories. The general essence is that one wise and good-natured old man of 70 years old tells stories to children living in the neighborhood in the yard under the shade of a linden tree. The most interesting thing is that the heroes of the stories, for various reasons, can only move according to the chess rules. And the heroes are different - sheriffs and Indians, Italian nobles, gladiators, eastern emperors.
I still have a book of this series "Hands up, Your Majesty!" (printed in 1980).
- Miziiski.jpg (28.81 KiB) Viewed 4388 times
My favorite story is Suicide in Florence. In fact, this is a three-move reverse checkmate(selfmate) or Zimmer's problem. But with a beautiful story in which a young Italian duke, out of love, wants to be killed by his rival, so that he would be put in prison and the woman would not be given to anyone. Such a children's story !
This is the starting position:
- selfmate_0.png (186.01 KiB) Viewed 4388 times
But the book publishing house of the city of Rostov-on-Don spoiled all the reading for the children, because the book was printed almost on toilet paper and with poorly read chess notation But I think the solution is this:
1. Bb2-a1 Ka2:a1
2. Qe1-c3+ Ka1-a2
3. Qc3-b2+ a3xb2#
Re: Improving your code development skills
Posted: Mon May 24, 2021 3:55 am
by 6502coder
wiak wrote: ↑Fri May 21, 2021 1:40 pm
Drawback: the time taken playing chess takes from the always too short time you have have available for the thousands of hours of coding you should be getting on with.
Instead of playing chess games, you could just solve chess puzzles. These give you most of the "pattern recognition" training benefits. Admittedly, puzzles don't give you training in strategical planning the way playing complete games does, but puzzles take just a few minutes.
One unusual kind of chess puzzle that I particularly like is "retrograde" problems. These are puzzles in which you are presented with a position and a question whose solution requires reconstructing the previous moves that resulted in the given position. I once showed some of these to some fellow programmers, none of whom were more than casual chess players, and they all found retrograde problems fascinating. Those interested should check out the books by the logician Raymond Smullyan, "The Chess Mysteries of Sherlock Holmes" and "The Chess Mysteries of the Arabian Knights."
Re: Improving your code development skills
Posted: Wed May 26, 2021 7:21 am
by wiak
6502coder wrote: ↑Mon May 24, 2021 3:55 am
wiak wrote: ↑Fri May 21, 2021 1:40 pm
Drawback: the time taken playing chess takes from the always too short time you have have available for the thousands of hours of coding you should be getting on with.
Instead of playing chess games, you could just solve chess puzzles. These give you most of the "pattern recognition" training benefits.
Yes, not bad at all. 'Retrograde' sounds interesting. However... One of the brain-enhancing effects I believe comes from playing chess is the stress of competition between two human minds (which is a benefit that simply does not come from playing against computer itself). Admittedly, if your hands are already shaking from drinking too much coffee, you are probably better to avoid that game of online chess you were planning to engage in (and especially if it is close to bedtime, cos you may have difficulty sleeping from either coffee or late night chess, or from complex computer programming for that matter...).
Re: Improving your code development skills
Posted: Wed May 26, 2021 7:30 am
by wiak
Grey wrote: ↑Sun May 23, 2021 8:24 pm1. Bb2-a1 Ka2:a1
2. Qe1-c3+ Ka1-a2
3. Qc3-b2+ a3xb2#
Yeah, they should maybe have just played Ba3 and taken things from there. Actually, though I understand algebraic notation I'm still psychologically stuck with old P-K4 type notation (so BxP) and my favourite chess book was 'Chess Fundamentals' by Capablanca, which used that old notation (I also really loved Nimzowitsch 'My System', though his 'system' wrecked my chess playing in practice for years... and probably still causes me to play some crazy moves sometimes...).
Re: Improving your code development skills
Posted: Wed May 26, 2021 8:50 pm
by 6502coder
Here's an example of a very simple retrograde analysis problem. Clearly, at some point in the past, the White Queen was captured. But what square was it captured on?
Caveat: unlike ordinary chess puzzles, retrograde problems are not about two players trying to beat each other. They are purely exercises in logic. Thus, while one can assume that all moves made in a retrograde problem followed the strict rules of chess, those moves did not have to "make sense" from a competitive point of view.
- retroProb.jpg (27.97 KiB) Viewed 4256 times
Here's a more difficult puzzle. The Black King is somewhere on the board, but he's invisible. White has mate in one. What's the move?
- retroProb2.jpg (19.68 KiB) Viewed 4256 times
(In both diagrams, White is at the bottom, as usual. Both problems are from Smullyan's books, cited in my previous post.)
Re: Improving your code development skills
Posted: Thu May 27, 2021 4:59 am
by Grey
6502coder wrote: ↑Wed May 26, 2021 8:50 pm
The Black King is somewhere on the board, but he's invisible. White has mate in one. What's the move?
Is the white king exactly on f8?
Re: Improving your code development skills
Posted: Thu May 27, 2021 6:36 am
by wiak
6502coder wrote: ↑Wed May 26, 2021 8:50 pmWhite has mate in one. What's the move?
...
(In both diagrams, White is at the bottom, as usual. Both problems are from Smullyan's books, cited in my previous post.)
I haven't seen the book, but I think that second problem is easy: P x R (promote pawn to a Knight and discovered check via the rook)
Immediate EDIT: But I'm wrong, cos King if where I thought it was could take the Knight on b7... sigh
Immediate EDIT2: Oh no it couldn't cos a pawn protects that Knight... whew.
Re: Improving your code development skills
Posted: Thu May 27, 2021 11:31 am
by Grey
I also thought that the black king is on c8, but he can go to the d7 square. But if there is a mistake and the white king on e8, then checkmate can be made in three ways: kill the black rook with the white one, kill the black rook with the white pawn, or the knight jumps from b7 to d6.
Re: Improving your code development skills
Posted: Thu May 27, 2021 1:28 pm
by wiak
Grey wrote: ↑Thu May 27, 2021 11:31 am
I also thought that the black king is on c8, but he can go to the d7 square. But if there is a mistake and the white king on e8, then checkmate can be made in three ways: kill the black rook with the white one, kill the black rook with the white pawn, or the knight jumps from b7 to d6.
The black king is on c8. It is as I said above, P x R (i.e. Pb8) but don't ask for Queen, ask for Knight (Horse). The black king is then in (discovered check) from the Rook on c7 and the two Knights hold the squares d7 and d8 so it is checkmate.
Re: Improving your code development skills
Posted: Thu May 27, 2021 1:30 pm
by wiak
wiak wrote: ↑Thu May 27, 2021 1:28 pm
Grey wrote: ↑Thu May 27, 2021 11:31 am
I also thought that the black king is on c8, but he can go to the d7 square. But if there is a mistake and the white king on e8, then checkmate can be made in three ways: kill the black rook with the white one, kill the black rook with the white pawn, or the knight jumps from b7 to d6.
The black king is on c8. It is as I said above, P x R (i.e. Pb8) but don't ask for Queen, ask for Knight (Horse). The black king is then in (discovered check) from the Rook on c7 and the two Knights hold the squares d7 and d8 so it is checkmate. It is the new Knight on b8 that aims at the d7 square and the Knight on b7 that aims at the d8 square, hence it is checkmate via that discovered Rook check.
Re: Improving your code development skills
Posted: Thu May 27, 2021 2:29 pm
by Grey
wiak wrote: ↑Thu May 27, 2021 1:28 pm
ask for Knight
Yes, turning into a knight solves the problem
Re: Improving your code development skills
Posted: Thu May 27, 2021 4:20 pm
by Grey
By the way, the first problem looks like the children of a player playing with white pieces stole both bishops from their father before the game even started Or maybe the cat did it The position is artificial, but still funny.
Re: Improving your code development skills
Posted: Thu May 27, 2021 5:33 pm
by Jafadmin
Re: Improving your code development skills
Posted: Thu May 27, 2021 7:07 pm
by 6502coder
Wiak's solution is correct, but...
It's true that the Black King must be on either c8 or d7, but nobody has yet explained WHY that is the case. I suppose one could argue that without the Black King being on either c8 or d7, a mate in one is not possible. For that I must take the blame in the way I phrased the problem. The fact is, regardless of whether or not White has a mate in one, the Black King must be on c8 or d7.
The reasoning is as follows. It's White to move. Therefore, the Black King cannot be in check. So the Black King is not on d8.
Next, we know that the Black King either is or isn't on c8 (The Law of the Excluded Middle). If it ISN'T on c8, then the White King is in check (since we've already ruled out the Black King being in the way at d8). And the only way that check could have happened is if the Black King moved to allow the Black Rook to give discovered check. And the only place the Black King could have moved TO is d7. Thus the Black King must be on either c8 or d7.
No takers yet for Problem 1? I thought this would be even easier.
BTW the reason I think retrograde problems are relevant to code development is that they're like debugging. You are presented with a situation and have to figure out, after the fact, how it happened, using careful logical analysis.
Re: Improving your code development skills
Posted: Thu May 27, 2021 8:37 pm
by Grey
6502coder wrote: ↑Thu May 27, 2021 7:07 pm
If it ISN'T on c8, then the White King is in check
This is enough without any other reasoning, because now it is White's move
Re: Improving your code development skills
Posted: Thu May 27, 2021 10:01 pm
by Grey
6502coder wrote: ↑Thu May 27, 2021 7:07 pm
No takers yet for Problem 1? I thought this would be even easier.
Somehow lazy. Oh, I recently compiled in Fossapup the strongest chess engine Stockfish(13th version) optimized for SSE4.1 processor instructions. And resolved dependencies for PyChess so that there is a graphical interface for the engine.
So what? I’m even too lazy to try to let all this software solve the problem and to appropriate for me their achievements in case of success
Re: Improving your code development skills
Posted: Fri May 28, 2021 1:02 am
by wiak
Grey wrote: ↑Thu May 27, 2021 10:01 pm
6502coder wrote: ↑Thu May 27, 2021 7:07 pm
No takers yet for Problem 1? I thought this would be even easier.
Somehow lazy.
In my case, I didn't attempt problem 1 because I'm suddenly too busy playing online chess (losing and winning inconsistently). I had a go at answering Problem 2 because I thought I saw the solution right away, but for some reason didn't see any immediate solution to Problem 1 (and laziness then took me over also). I was in the middle of programming new WeeDogLinux stuff when I accidentally came across a chess blog online and that tempted me to suddenly play an online game - hence all coding I was doing put on the shelf and forgotten about... so much for 'Improving your code development skilss'...
Re: Improving your code development skills
Posted: Fri May 28, 2021 2:56 pm
by 6502coder
I understand. Real Life intrudes.
It's a shame though because Problem 1 is a better (i.e. more typical) example of a retrograde puzzle than Problem 2. As i mentioned, retrograde problems are typically NOT "find the mate" problems. A chess engine doesn't know what do with Problem 1 because the question posed has nothing to do with evaluating positions. On the other hand, the solution is VERY EASY for a human, once you've seen how a typical retrograde puzzle works
Re: Improving your code development skills
Posted: Fri May 28, 2021 5:55 pm
by Grey
6502coder wrote: ↑Fri May 28, 2021 2:56 pm
It's a shame though because Problem 1 is a better (i.e. more typical)
I liked number two more
6502coder wrote: ↑Fri May 28, 2021 2:56 pm
A chess engine doesn't know what do with Problem 1
But you can combine yourself with the engine. Robocop and Paul Verhoeven were able to do this back in 1987
I said above that the cat stole a white bishops - there were no bishops at all So only the white queen and knight are killed. On the contrary, black bishops are killed. The white queen can leave only through the square where the second white knight is now. But first, the white pawn must defeat the black bishop. He could come out only if the black pawn killed someone on e6, and this is the white knight, because the queen has not come out yet. This means that the queen has been overwhelmed by the pawn on h6.
That's how the White Queen was killed(reconstruction of events) :
Glory to the Queen! In the name of Bender Bending Rodriguez! All power to the robots!
- Robocop_directives_0.png (230.12 KiB) Viewed 4262 times
Re: Improving your code development skills
Posted: Fri May 28, 2021 6:10 pm
by 6502coder
Correct!
If I may restate your solution minus the cat, for those who might still be a bit confused:
Two Black pawns have made captures. White has lost 4 pieces, but both Bishops clearly died in bed because they could never have moved. So the White Queen is one of the two pieces that was captured by a Black pawn, the other being a Knight. The Queen could only have gotten out by way of a2, which means that first the White a-pawn captured something on b3, which could only have been the Black c8 Bishop. Before this, Black's d-pawn had to capture something on e6, to let the Bishop out. This must have been White's Knight, so the Queen was captured on h6.
Magic cats are not necessary, because both White Bishops could of course have been captured by Black's Knights.
Re: Improving your code development skills
Posted: Fri May 28, 2021 6:42 pm
by Grey
6502coder wrote: ↑Fri May 28, 2021 6:10 pm
Magic cats are not necessary, because both White Bishops could of course have been captured by Black's Knights.
They just jumped in and kicked the defenseless Bishops with their hooves But this means that the White Queen did not care the defense of her Kingdom. She deserved to end up like this.
And with cats it is also interesting
Re: Improving your code development skills
Posted: Fri May 28, 2021 9:24 pm
by 6502coder
If you keep talking about CATS on a PUPPY forum, you might run the risk of being "captured" yourself!
Re: Improving your code development skills
Posted: Wed Jun 16, 2021 1:41 pm
by wiak
Not been developing any code for a while now. Having not been playing any chess at all really for almost thirty years I've been playing non-stop since starting this thread (starting the thread pretty much being my reaction to that attempt). My rating seems to have gone down from thirty years ago (oh what a surprise) - main problem being occasional blunders or annoyingly missing a pretty obvious combination with some of that being a result of now playing too slow and getting into time trouble... sigh. However, I've had a few successes too. I'm currently trying to edge over my highest reached rating since starting to play again - but it is a bit of one step forwards, two back..
I've promised myself if I manage to exceed best yet recent rating, I'll suspend play and get back to code development... but... yesterday I just needed to win one more game and that would have been achieved, but of course I then lost two games and have had to play several more to get back to a similar situation tonight where one more game and I may exceed my previous best rating. I had to beat a much higher rated player tonight to reach that state - he was from Moscow, and I find that East European players are pretty much always tricky to beat (like alone not lose against), and Russians more than any... so was happy to win. I'm hoping I get some lesser ranked player when I try tomorrow to creep over that ratings level I have so I can be released back to code development... I'll probably try too hard and blow it again. Problem with losing after gradually climbing the ranks, I find, is that the fall can become dramatic (loss after loss)... It is all a matter of psychology at times like that. Then I get truly mad at myself, and start winning again... Luckily that is the mood I was in when I played that significantly higher ranked Russian guy tonight and I noted he had never been beaten by such a low ranked player as myself before and I actually out-played him, so my hopes are on a high. If you note that I have vanished again (not coding) then that will possibly mean that got trounced again... Please, please, don't give me another higher ranked Russian to play tomorrow - I'm Scottish - make it somebody from England and please, please, don't let me lose. Really, I don't have a clue why I am currently torturing myself playing games of chess...