coding chess
coding chess
coding chess
Reminds me of how I made tic tac toe game for my first university assignment 🤣
YandereDev coding chess.
Also who has a variable to store an input and decides to name it "player"?
Thank you! That was driving me nuts.
Someone editing a tutorial without knowing what they're doing
They've still got a long way to go
Tldr Estimated total number of legal chess positions is (4.822 ± 0.028) * 10⁴⁴
"John Tromp and Peter Österlund estimated the number of legal chess positions with a 95% confidence level at ( 4.822 ± 0.028 ) × 10^44, based on an efficiently computable bijection between integers and chess positions."
%95 confidenece level? Did they make a poll?
Is this the same person who coded the odd/even function?
I have a better odd/even function:
bool isEven( long long x ) { if ( x < 0 ) x = -x; if ( x == 1 ) return false; if ( x == 2 ) return true; return isEven( x - 2 ); }
This will work for both negative numbers and arbitrarily large integers. I've tested it up to 26 but I'm pretty sure it will work up to infinity.
Though serious question: Why are these forums coded in such a way that they ignore single newlines? How hard is it to replace a newline with a br tag?
Edit: added two spaces, should look much better.
Edit2: just looks a bit better lol
Edit3: better now?
It’s Markdown syntax. You can actually format it nicely in a code block:
bool isEven( long long x ) { if ( x < 0 ) x = -x; if ( x == 1 ) return false; if ( x == 2 ) return true; return isEven( x - 2 ); }
You do that by adding above and below it. To force single line breaks, you can terminate your sentences with two spaces, or a backslash.
I love the use of recursion. Slick.
For large numbers, you might get a stack overflow. Depends on whether the compiler recognizes that it's a tail recursion and then handles it appropriately.
As for why Lemmy ignores single newlines, that's because it uses Markdown for its comment syntax, which happens to handle newlines that way. If you want a single newline to display, you have to add two spaces at the end of the line.
Here, you really would have wanted to use a code block, though, which you can create with backticks
``
like
so.
``
Normally, this would display "like so." in a monospace font and handle newlines as you expected:
like so.
Some quirk of this version of Markdown I think.
Try putting two spaces at the end of a line before your single newline.
What no theory does to a mfer
Something my DE needs to understand
I've seen someone code that way. Not since high school, but that's a way that some people think coding works when they start out writing code.
This person was trying to write a game in (trigger warning: nostalgia) QBasic and had it drawing kindof a Pacman kind of character. And in pseudocode basically what he was doing was:
// Draw character with mouth open at (100, 100) moveCursorTo(100, 100) drawLineFromCursorAndMoveCursor(116, 100) drawLineFromCursorAndMoveCursor(108, 108) drawLineFromCursorAndMoveCursor(116, 116) drawLineFromCursorAndMoveCursor(100, 116) drawLineFromCursorAndMoveCursor(100, 100) // Wait for half a second. sleepSeconds(0.5) // Draw character with mouth closed at (101, 100) moveCursorTo(101, 100) drawLineFromCursorAndMoveCursor(109, 100) drawLineFromCursorAndMoveCursor(117, 108) drawLineFromCursorAndMoveCursor(109, 116) drawLineFromCursorAndMoveCursor(101, 116) drawLineFromCursorAndMoveCursor(101, 100) // Wait for half a second. sleepSeconds(0.5) // Draw character with mouth open at (102, 100) moveCursorTo(102, 100) drawLineFromCursorAndMoveCursor(118, 100) drawLineFromCursorAndMoveCursor(110, 108) drawLineFromCursorAndMoveCursor(118, 116) drawLineFromCursorAndMoveCursor(110, 116) drawLineFromCursorAndMoveCursor(102, 100) // Wait for half a second. sleepSeconds(0.5) ...
He hadn't gotten to the point of working in user controls. (Like "change direction to 'up' when user presses the 'up' key" or whatever.) And understandably had no idea how that would work if/when he got that far.
And now they'll have to fix their board, for it is wrong. h3 is a white square.
Reminds me of when I downloaded Tic Tac Toe for my graphing calculator in high school. It wasn't this verbose, but the original author copy pasted the logic for each turn. Even I knew this was awful, so I refactored it to use a loop.
what if you write an algorithm that will produce the necessary code for each possible move, so you don't have to type them all manually
Non-monospaced font for programming. Ya'll know this is satire.
When I was learning c++ in high school, I made a working 10x10 implementation of Conway's Life before I had learned about arrays.
Even then I didn't do it like this. Just had 200 variables for the front and back buffers, and one big function with individual checks for each grid coord variable to check it's neighbors.
Btw, is there a cli chess game with such characters as symbols?
I imagine there are a few out there, but unicode has chess symbols so it's certainly easy enough to do if you have a language, font, and terminal that supports it.
What no theory does to a mfer
If it works, it works.
someone should have started with tingo i mean bingo
Reminds me of my lottery number randomizer in VB 3.0 I calculated 10 rows and checked each input box against the others without any loops, and then each row was just copy pasted. 🤦