#programming
1 messages · Page 223 of 1
not using the api or macros, released source code, reduced tokens by huge amount already??
this dude is so real
commands to cute chess
holy shit
damn, bro playing on hard mode
he means no api
who's gonna tell bro I'm compiling with -std=c23
wdum
variable types must be declared
no implicit int
no having i; as a declaration of i

needs to be int i;
also for functions, and for function inputs
also: variable names can be as long as you want
they'll still count as 1 token
long numbers also count as 1 token
is my cmakelists file not the same as that? or have a done a massive oops
On the positive note, macros are going to have a field day existing with #define ONE 1, #define ZERO 0, #define TWO 2,
not really, that's still gonna need two tokens?
someone also tell Smeagle that it's about token count, not character count...
error: type of "minimax" not declared
error: type of "d" not declared
error: type of "a" not declared
error: type of "b" not declared
error: type of "m" not declared
you don't need to have single-variable names without any spaces anywhere 
this too
or use auto if you're a pussy
mb, thought {ONE TWO ZERO 1} would parse
auto's face when I #define PBoard Board *
it's a thing in c23
oh fr?
^
yes
hmmm.
auto already existed in C but with a different and useless meaning
I think it will, but surely the spaces count?
they extended it to have the C++ meaning as well
this could save me like 2 tokens
anyway I think smeagle should be ok still, they just might have to gain a few tokens
afaik auto was always implicitly there with the original storage class meaning 
guys I'm goated
gotta add those types
I mean this looks pretty good no?
That's one for testing, because the list with spaces would be 3 tokens each
its probably a lot more golfable in C
1699...
and then you use macros 
you could save a bunch by adding the chess api from shiro, probably
that's also true but if you're really committed to not doing so
though I have to admit, I'm not sure how your current code gets the board from the chess host
calculating legal moves without the api is not that fun
Wait, I don't need to install the C toolchain to test the token count
would expect it to cost like 500 tokens minimum
accounting for the complexity added by en passant and castling
Laptop get over here I'm writing sudocode
if they want to challenge themselves then that'd be really cool
^
yeah but i dont do that lmao
a minimal legal moves implementation is no joke
pseudocode
fair, they're rare anyways
is that a bug
oh I see
I would just make the bool an int
I'm still more than mildly tempted to force something to assume I have popcnt so I get a mild board evaluation speed boost
are you passing a bool where it expects an enum?
should work the same and the warning will probably go away
im calling is_white and passing it to chess_get_bitboard
yes
oh, yeah that's probably fine
i mean it'll compile and probably work
i'll try to compile lets see what g++ says
it'll probably give you a warning
with the slight side effect that the program would have invalid instructions if shrio didn't have popcnt
you're safe to ignore it though
warnings are good
but 
just set target cpu to native in Cargo.toml 
genius

then have to cast
is this a cast
tbh I'm pretty sure Shiro's CPU supports SSE4, Rust is just very conservative with the defaults
should be
that is a cast yes
if that fails then there's always chess_is_white_turn(board) ? WHITE : BLACK
worse
which will work for sure
cant cast piecetype
just use the enum value
can you just do KING instead
works here too looks like. alright
C++ 
do i need to make a function to convert piecetype to bool 
stupid ass enums smh
other way I think
what if i pointer cast it
^
this is probably easiest
* (T *) &t is probably more tokens than ternary
does something like !!chess_is_white_turn(board) work?
it's still a bool tho
need to convert it to PlayerColor not to bool
ah i see
idk why the conversion is being so upset
if you're converting PlayerColor to PieceType, I'd be very concerned ngl
my brain is half shut down I don't even remember typing that
idk why this is slightly funny to me
it's free real estate
but what if my super secret bot search method gets leaked and then everyone uses it 🥺
im too scared to release my source code in case someone improves it more than I do
I know that if I release my code I will be safe because anyone who codes better than me will be writing C anyways and despise rusts syntax
i'm not sharing mine because it was all written before the tournament rules and the silly little -std=c23 was there (also it's never been tested) ((also also it's probably dogshit))
just gonna do a full rewrite i think
maybe carry over the neural net and eval function
and then redo the search method
Added a #define _ONE -1, as well. From 199 tokens to 167
how many -1's do you HAVE
Well it is all 4 defines
On the other hand... I only did line 4
is -1 actually two tokens
Yep
why...
Unfortunately no macros in Kotlin
i just have a #define n1 -1 lol
kotlin is fine i think
I would just find the unsigned int equivalent
0b11111111111111111111
competitive enough on its own
and use that
Yeah it makes up in having an insane STD
I may be stupid but what is a token (I'm a python dude)
fuck that's smart
roughly speaking, a word or punctuation character
interesting
a unit of parsed language
int myVar = 1; --> ["int", "myVar", "=", "1", ";"]
in this case, a token is whatever the toknt thing says it is
might as well go for 0xFFFF...
One example of Kotlin STD being insane here in my patched in anti-stalemate
string of 8 billion characters? yeah that's 1 token
parsers chop text/code up into more digestible pieces; tokens
def main(): -> [def, "main", open_paren, close_paren, colon]
1 single comma? yeah that's also 1 token
For the lols, defines for 0, 1, -1, 2, decrease line 4 from 199 tokens to 167
why define 0
This code is cursed but also small
I just realised I'm a chess player and a programmer and have no idea what I'm doing still. this'll be fun
I still haven't started any work on my bot 
dw neither have i
getLegalMoves(newBoardState).apply { if (this.isEmpty()) scoreCpy -= 99999999 }.forEach {
Kotlin STD silliness
I do have most of the JS bindings done tho...
i'm a comma HATER so i personally do this because i'm deranged
js bindings 
just reading that ending makes me very confused
surprisingly simple with Deno tbh
(I haven't actually tested them yet)
ah wait i need spaces
Well make sure you're definitely passing Move s by value, I got tripped up by that for a bit
maybe its luck i'll check more
nice mate 
yeah, I did notice that
i feel like this is bordering on using strings for non-stringy purposes
tbh the larger issue will be properly representing a Move without copying it twice...
it's not evaluating
you can just merge them all into one string constant to save even more tokens
did t see the 64-bit token rule
then you're fine 
totally valid for the use case if those are storing what I think they are
1 long long long?
long long long long long
loooooong loooooooong maaaaaaaaaaaaaaan
windows: yeah looks like an int to me
how long is a long long int if a long long could long long int
I just copied it twice to have a different binding on the native and Kotlin sides
Just cleaner
I don't like it 
the network is hungry
"best i can do is 16 bits"
You may not like it but it's the cleanest solution
i must feed it many hex codes
but I think I'll just do a copy first and see if it actually affects performance
before i had them all hidden away in a single massive string of parameters lol
then i saw that annoying rule
truly unfortunate
i wonder if i can find a way to compress them later.
Yeah that was my doing
damn it iggly
so what actually are those long longs?
i could have had INFINITE parameters for my neural net
ah
ternary parameters for a neural network, packed into ulongs
Shiro said they were going to check for exactly that anyways, so I just put it on paper
imagine making the chess bot with a backdoor where you can control what it does directly
question for the C nerds, is Move 24 bytes?
cheating? most definitely
funny? most definitely
"Move"?
the Move struct
does vscode let you hover over the struct for that info
I know rust does
can't do that in JS lmao
I think it's 8 + 8 + 4 + 1 + 1
that's 22 bytes, which doesn't exactly align to anything
i mean depending on compiler & options it may also align to like 16 bits in which case it'd be 32 bytes

Oh, no, it's 8 + 8 + 1 + 1 + 1

not mating anymore 
its over
well fuck me I guess, bc depending on the compiler not to fuck with the alignment is kinda futile
just test the alignment and size in c using the same flags as the readme says it uses
I'll just trust what bred got, surely it won't result in anything bad
otherwise it's Shiro's fault
my best bet would be that C packs the bools into one byte with masking but it's probably implementation defined
chayleaf idk if ur here rn but ik you live here, so i wanted to tell you that i noticed that you are in the infinite free wil gif
Yeah that's how the JVM accepts them
Using Byte instead of Bool is way more reliable
bool? more like boooooooooo
fuck bool

lol that reminds me
iirc c++ does some shenanigans with vectors of booleans
oh this thing
it actually is 24 bytes, at least on Windows with MSVC...
bitflags
they should have just put it in a different type
to be honest
vector => vector
bitflags => bitflags

makes sense I think?
it's 8 + 8 + 1 + 1 + 1, alignment of 8 bytes because uint64 so 24 bytes with padding 
well yeah, but who knows how the compiler would fuck with it
what did they think 
trusting a C compiler not to do something stupid is like trusting Shiro not to have a birthday today
"Let your plans be dark and impenetrable as night, and when you move, fall like a thunderbolt."
poor shiro
are compilers allowed to mess with structs like that
I thought alignment and such are defined as part of the target, so they should at least be consistent on one platform
yes, compilers can mess with structs however they like unless you define a specific alignment
dinkdonk Shiro go specify the struct alignment
all the c spec guarantees is that members are stored in order and that sizeof(T) includes padding
iirc
it allows compilers to insert padding or do alignment, but its up to them what they do with it
oh also it obviously defines that accessing members with a.b or a->b is safe

ye, the specific alignment for each type isn't given by the spec I think, it's given by the target
but surely if the spec guarantees that fields are in order and are aligned then it's consistent as long as the same alignment is used for everything? 
struct A {
uint8_t b;
} __attribute__((aligned(16)));
struct C {
uint8_t d;
uint16_t e;
} __attribute__((packed));
alignment determined by the compiler, therefore it may vary from compiler to compiler and from target to target
therefore padding bytes may vary and therefore the whole struct size
is this the view of the C spec or are there actual differences in alignment between compilers for the same target
its why things like sizeof(Struct) exist rather than just deciding its sizeof(uint8_t) + sizeof(uint16_t)
by-and-large there will be no difference between compilers on the same target
especially with the main two gcc and clang
though clang's is more up to llvm, and who knows what llvm is doing

ye, this is basically what I was getting at
I'm not sure if for the C spec the concept of a "target" even really exists, but for LLVM it certainly does
C is technically platform-agnostic so it doesn't specify anything here, but the actual compilers do
-# kinda
yup pretty sure the c spec doesnt define any platform things except for behaviour that must be followed on all platforms
cpu arch + abi + os are for compilers and toolchains
c spec is for c
actually this is a notable case
abi may force different alignment
as well as cpu arch
os is less common but im sure something of that kind happens too since long means different things on windows and linux
tldr do not assume anything about the size or alignment of the move struct
well that's nice but that doesn't really work
if we get a raw pointer and a move count, how are we supposed to pick out moves from the array the pointer points to if we don't know the size of Move
shiro can add __attribute__((packed))
to the def of the struct
or shiro could provide a better api for moves

y'know what, I'll create an issue for exactly that
surely your ffi backend has methods for extracting fields from a struct
it doesn't, no

because structs don't have a concrete representation if you don't specify it
surely you can just specify the field types and the ffi backend can figure out how that translates on your system tho
__attribute__((packed)) wont really pessimise performance that much, and it would guarantee alignment on most compilers
well no, how would it know what it translates to?
Is Chess fixing done yet? I TETOed too much
how does it for every other ffi implementation
ffi backend work on .so, not .c
the structs are opaque to ffi
this works, but only if you glue half a C compiler into your language (like Rust does)

so adding __attribute__((aligned(N))) and __attribute__((packed)) to Move would fix this?
for reasonable N that is
that a bool was one bit

one or the other
a logical boolean is one bit, its true
I spent wayyyyy too much time on this Finnish TETO thing
yes but a Boolean does not take up one bit of space in any sane language as much as they tried to convince me they did 😭
to argue semantics, for the language the boolean is one bit
for the platform it is not
I guess, but that clearly wasn't what either of us were meaning at the time
bool is typically defined (per-platform) as the minimum addressable size of the platform
true true
packed will ignore alignment (removes all padding bytes), and aligned(N) will set the alignment
packed is typically equivalent to aligned(1) so im not sure the reason for it existing
if the alignment is larger than some of the fields, the padding is after the actual field value, right?
aligned() works on bytes and not bits so as per the c spec packed and aligned 1 should be equivalent 
depends on endian
well assuming little endian bc pretty sure nobody here has a big endian CPU
this can be done
pick one or the other though
i dont think they play nicely together
will do packed
ideally packed for abi compatibility
simpler
yay
might pessimise performance a bit but oh well
do I still have to create the issue for you to not forget?
should be negligible
unaligned memory accesses 
if you make a PR I can approve it soon
just add a couple bytes of padding at the end of the struct 
otherwise will take a bit of time
manual padding 
a bit
packed structs have ub?
program memory is typically aligned to 1 byte anyway 
The Dark Arts of Advanced and Unsafe Rust Programming
Me when my entire array reading function explodes
its defined behaviour (in c) 
FFI devs telling me the problems are my fault and I should add UB to the API to fix it
you should use #[repr(C, packed)]
no no, there's no UB in the c code
rust skill issue
it joke
ah
You better not break my code ```kt
fun getLegalMoves(board: Board): Array<Move> {
val len = IntByReference()
val movesPtr = nativeBindings.chess_get_legal_moves(board.value, len)
val moves = Array(len.value) { i ->
val offset = i * MoveByPointer().size()
MoveByPointer(movesPtr.share(offset.toLong())).toMove()
}
nativeBindings.chess_free_moves_array(movesPtr)
return moves
}
rust
a uint64 read should be 8 byte aligned, no?
the reason its UB is because some cpus dont allow unaligned accesses
it will totally break your code
(sorry)
If you break it you're responsible for fixing it too
sorry when i said 1 byte i actually meant 4096 byte 
since that's the typical page size

send a PR that sets __attribute__((aligned(4096)))
I was told the API was meant to be unchanging
With no breaking changes
it wont impact most systems, since the os gives out aligned memory usually of the max alignment for the platform or the page size
And changing the sizes of things in memory would definitely be a breaking change
Make forced alignment a compile flag disabled by default or something
I love C
it's great that it's become the standard for FFI everywhere, even though there may be no C code involved at all
truly amazing 
would you rather have "unknown so anything can happen" for the size or "known but have to change the code a bit now"?
I would like the current existing and fully functional behavior that JNA has no trouble with so make the patches optional
Compile flag or something
JNA makes the same assumptions I'm making, that it aligns to 4 bytes
with typical alignment yes
I'm 99% sure that this is only true for memory given to userspace from the kernel
allocators can do whatever they want with that as long as they respect struct alignment 
I recommend making changes to the API optional and disabled by default unless you can confirm existing bindings work with them fine
the biggest issue with unaligned reads is partial loads, crossing page boundaries, and crossing cache-line boundaries
which, really arent a huge issue most of the time on modern cpus
userspace allocators can do whatever they want, yes.
Anyway I need to sleep soon-ish probably, so you better not break my code in the meantime
too bad
mods, break his code
Like really please don't break my code
all code shall be broken
I need my code not be broken
1 + 1
shiro can you make it so the struct layout is random and you have to infer it every time
I hate dealing with raw memory access as-is so I may not have the motivation to fix memory issues
Rust has this as a feature 

-# or rather, the reference compiler does
I just want to build a silly Chess bot in peace and not have to worry about my core API breaking in the middle of it
idk how badly bindgen would implode
Like if you change the memory alignment AT LEAST make it optional and disabled by default
bindgen should be fine, since it reads the C code

that's the one thing that probably won't get broken 
would be surprised if bindgen didn't deal with packed structs before
I mean, Shiro could "just" add manual padding to actually make it 24 bytes always
bc I'd imagine it's 24 bytes everywhere now, just not guaranteed
it should be, ye
at least it's 24 on Windows

Just please don't break my Kotlin bindings and I'll let you do whatever you want, as long as I can just compile a new SO and throw it in as-is
I'd rather avoid breaking changes to every existing bindings just to support another, but it sounds like not specifying the alignment is a proper issue for cross-platform compatibility
so I'm willing to make a change to the C API to specify the alignment
Make it a compile flag PLEASE
let's put it this way
you don't know what alignment my system uses
or how my system will align or size this struct
Or confirm that it works with my bindings I don't want to deal with the mess of rebuilding the bindings and redoing all that again
without defining the alignment, there is zero guarantee your bindings even work on my system
i am here to unfortunately announce
#define SEED ((__TIME__[6] - '0') * 10 + (__TIME__[7] - '0'))
enum { RAND_VAL = ((unsigned long long)(SEED) * 1103515245ULL + 12345ULL) & 0x7fffffffULL };
typedef struct {
long x;
short y;
unsigned c;
} __attribute__((aligned(1 << (RAND_VAL % 4)))) Erm;
this works




Shiro can you ban that person, they're commiting crimes against humanity
Well, you said a Linux system and compiled with GCC
And that is the configuration I am using so mine should be safe
Just, try to figure out a way to make it work with whatever GCC on Linux compiles which seems the most sensible
in theory you can also make all bindings that don't support inferring the struct layout from the definition (like whatever daavko is doing) invoke a C compiler to find out 
nobody says GCC on one Linux system will do the same as GCC on another one
if you're willing to answer the resulting hate mail
That seems weird
But like it works with JNA so surely it's standard enough, right?
no, JNA just assumes the struct will look a certain way and it happens to work out
Well try to make the changes make it so the assumption is guaranteed to be true since if JNA makes that assumption it can be semi-safely assumed other language bindings make the same assumption
Just don't break my bindings I don't want to deal with them any more I just want to make a Chess bot

for most bindings it doesn't matter because they just follow whatever GCC and LLVM do 
but if your languages FFI doesn't do that for some reason then yeah, it's an issue
I mean, it probably does, but I wouldn't know
I don't know, just make sure it works with all the existing bindings
Don't break stuff for no reason
If you can avoid breaking stuff, then do so
I don't think I've ever really looked at JS bindings to C APIs
it's JS though, so surely there's a way 
fyi bun ffi embeds tcc
Anyway as usual I'm extremely stressed by changes that may break my stuff
and uses that for bindings
Deno specifcally, JS has no specific standard for FFI
yeah, and it doesn't do structs at all at this time 
So if you could just confirm you'll try to not break things I would be satisfied and could sleep
compat wise definitely go with node bindings but they're a pita
holy shit doom emacs is so much easier to use than whatever I had going on with my config
i mentioned that here before yeah
the changes should be minimal, and if you aren't doing anything that relies on the particulars of the move struct layout it should be okay
Well my code relies on its size
And probably anything else that reads the moves array
if you're cold, they're cold, put them in the chess api
it's necessary to ensure that bindings will work the same on all platforms, and thus that they'll work on my system
if your system happens to work the same as mine already then it probably won't affect anything
if it does affect something then your bindings would've broken on my system
that's my understanding
Well since everyone's bindings so far seem to work fine make the changes reflect what is happening with the bindings now rather thann doing something that breaks things
I'm not trying to make changes that break things that should obviously not be the goal
since they usually use a helper lib for conversion of types, many runtimes implement that and support them
regardless if it’s v8 or not
Well I may just be paranoid, I do not want to deal with more memory issues
diff --git a/src/main/kotlin/MoveByPointer.kt b/src/main/kotlin/MoveByPointer.kt
index 8513792..9e0e346 100644
--- a/src/main/kotlin/MoveByPointer.kt
+++ b/src/main/kotlin/MoveByPointer.kt
@@ -16,6 +16,10 @@ open class MoveByPointer() : Structure() {
@JvmField
var castle: Byte = 0
+ init {
+ setAlignType(ALIGN_NONE)
+ }
+
fun toMove(): Move = Move(this)
override fun toString() = "Move(from=${from}, to=${to}, promotion=${promotion}, capture=$capture, castle=$castle)"
here, problem solved 
I don't want to recompile for a change in the API preferably, so could you maybe instead align to what is expected by default on the API side?
What do you MEAN not possible?
FFI uses .so or .dll
struct information only exists in the .c file

yeah, it has to be reflected in the consumer code
adding manual padding to make the size 24 bytes again should keep existing bindings (mostly) working on x64 Windows and Linux and would avoid any performance impact from unaligned reads
small downside is that it will probably break elsewhere unless bindings are adjusted to match the new definition in the C header but who cares 
at that point just remove the alignment
it will not avoid performance impact of unaligned reads because
the speed difference is negligible at best
Well removing the alignment would 100% break stuff
the padding will also be unaligned
are we talking about the move struct
yes
that's the only struct that any of the bots can actually interact with
everything else is behind pointers
yeah it’s in an array if you change that you should pad
the issue is that just removing the alignment actually does break stuff for existing bindings
well I'll let you all figure out how you want it to be fixed given you, the bindings maintainers, are the main stakeholders here
Yeah, the one annoyance that annoys binding makers
the performance stuff is just a bonus
I mean it's either breaking some of the bindings now, breaking some of the other bindings now, or maybe breaking some of the bindings during the actual tournament...
just keep the paddings uninitialized, how hard can it be 
performance impacts from changing the move struct are unimportant given it applies to every API user
ultimately, the move struct being a byte or two larger is not going to be what makes your bot win or lose
so don't worry about performance
but I need every nanosecond
compatibility is the key issue here
the move struct should actually get smaller
Well yeah it's a difference of the bot running or crashing
just update the bindings with the appropriate alignment of (1 or no alignment)

if you're going to break anyone's code go break everyone's at least
I don't want to have to deal with that any more
alignment to 8 bytes
I just want my code to work
write bindings also requires maintain bindings
ultimately only you are affected if you dont want to update them 
Well I expect the API I was told would not change, to not change and explode things, an avoidable breaking change is dumb
do you depend on the actual size anywhere explicitly because from what i saw going through the kotlin bindings it's all up to jna to figure out
which requires exactly one line to be added
it's more specific, manually adding padding breaks only some bindings on only some platforms 
but ye, things will break regardless
or 3 with some nicer formatting
Well this is the cloests
AND way too much compiling and removing and replacing files
And restarting stuff
I hate restarting stuff
class FFIStruct : Structure(Structure.ALIGN_NONE) {
...
}
note to self, do not unprivate the repo that leaks both my school and my home coordinates down to the meter
or something
this is provided by jna so it's a non-issue
actually good point, even better than what i had 
Well then simply make it be what JNA thinks it is
._.
Why remove alignment when you can just make the alignment consistent instead?
what JNA thinks is also platform-dependent
removing alignment is making alignment consistent

sorry to say, but JNA is not the only consumer of the C API in existence
also "what JNA thinks" is not exactly well defined
Well it's a bad way because it breaks everything
diff --git a/src/main/kotlin/MoveByPointer.kt b/src/main/kotlin/MoveByPointer.kt
index 8513792..3640110 100644
--- a/src/main/kotlin/MoveByPointer.kt
+++ b/src/main/kotlin/MoveByPointer.kt
@@ -4,7 +4,7 @@ import com.sun.jna.Pointer
import com.sun.jna.Structure
@Structure.FieldOrder("from", "to", "promotion", "capture", "castle")
-open class MoveByPointer() : Structure() {
+open class MoveByPointer() : Structure(Structure.ALIGN_NONE) {
@JvmField
var from: Long = 0
@JvmField
new diff, there you go
no, it prevents random breakages in the future
for one breakage now
that is easily fixed

I just hate dealing with these kinds of things when I just want to have fun and make a Chess bot
everyone does, but not adding this change means some of those bots could fail to run in the final tournament when submitted if the bindings only work on specific platforms
am i wrong for saying dont write bindings if you dont want to maintain them 
that's the risk this change would address
I did not sign up for stressing out about memory alignment
then don't stress about it??????????
you dont need to
you change one (1) line
and be done

Well then keep the memory alignment
everyone here seems to be suggesting you need to make a one line change
So I don't need to stress about it
that is not stress worthy
❓
I don't even know any more, I'm too tired for this mess and dealing with more versioning mess
are the bindings public? can someone just submit a PR?
Updating this stuff is a whole massive process that is a worthy competitor to the post-karaoke sync
what
what, git pull?
post-karaoke sync literally is one shell script for me 
I think people here would be very happy to help with changes if they do end up being needed
toast literally already posted the diff 
you need to do practically no work for your bindings to continue functioning, this is not a huge change
Yes, but that won't magically compile them, recompile 12 bots of which 9 I no longer even have the code for with the new bindings, submit a new release with the recompiled code and restart my IDE
why would you need to recompile 12 bots 
you only need to recompile the bot you are working on
Because that's how many I have made?
and they are prototypes yes?
ok so, you made the issue 
is it even programming if you arent making more issues for yourself?
certified spacebar heating moment
I don't know, manually going in and replacing the bindings related class files seems like a massive pain
one (one) file
No
one (one) line in fact
At least 9 * classFileCountInCompiledBindings files
Manually replaced in JAR files which is also fiddly
I think super box is saying the old bots are jar files right now, and they don't have the source code that built them, so they would need to modify the jar contents directly
YES
yeah but, those bots wont be any different
you dont need to recompile it
just keep two versions of the bindings
unless the .so is built in
no, if the .so is built in that's even better
I do if I want them to work with the upcoming new fixes
Like the fix to the castling bug
can i ask why you dont have the source code

Because I made changes to make a new version
if you used version control this wouldnt be an issue 
Ver10 is built on Ver9 is built on Ver8 and so on
And you expect me to use that for a fun project? I only use it for big serious projects
Git for everything
no vcs => lose code
If you change the bindings that will be a massive pain
I hate git too
but always a good idea to keep a copy of code you still use
I just copy to another file
Well how could I know the bindings I was told WILL NOT CHANGE would change
its a hobby chess tournament, there are no guarantees
if you don't care about Git and proper version control then at least regularly copy the folder
it won't give you branches and commits and all the good stuff but at least you have a version history
-# I do both
i dont know who said the bindings couldnt or wouldnt change, but that does seem like a strong assertion to make considering bug history
I apologise for changes, certainly I've worked to minimize any changes required to the chess API
but I will note that this is a change to the header file
Shiro when I was making the bindings and was told anything in the chessapi.h would not be changed
well shiro was wrong 
stable bindings dont exist
did shiro know alignment was a thing (to consider) at that point
shiro certainly did not foresee such an issue, otherwise it would have been fixed at the time when the bindings were made

the intention is to make as few breaking changes to the .c and .h files as possible
should've explicitly defined the memory layout of all structures in a separate document smh /s
but ultimately this is my first time doing something like this and planning ahead for the variety of issues that supporting every language and platform entails is rather challenging
this is why you have an rfc process 
there's a reason semver dictates that before version 1.0.0, any breaking change is allowed 
Well try to keep the alignment change as non-breaking as possible then, try to keep the alignment the same as whatever it most likely is now and hopefully it works for most bindings
Those that it doesn't work for fix it, those that it does carry on
this is why a change log exists on the GitHub repo, in the front page readme, to document these major changes
er no 
yes, this is a pretty important change
forcing the struct to be packed will reduce the amount of work for everyone else and reduce the chance that it breaks when shiro has to compile it
I'm open to other suggestions to resolve this but ultimately the Move struct needs to be well-defined cross-platform
this is just not really how it works
keep the alignment the same as whatever it most likely is now
the current alignment and struct layout is not well defined, there's not really a way to keep it
unfortunately this is the only solution that works universally 
Well I would think the safest option would be aligned to 8 bytes
there's plenty chance that this change doesn't break existing bindings
you end up with broken bindings in that case too 
and if it does, it should be a very easy fix
if you hardcode it to 8 bytes
very unlikely it doesnt break existing bindings
oh really?
yes, but the fix is a 1 line change
I can test the rust bindings if you want shiro
And hours of pain and suffering to replace files in files
I would've thought many systems would assume the packed size anyway, or if bindings use an FFI library that the library would just infer the field locations anyway
I would guess most systems assume 8-byte aligned size
im going to be evil 
just dont do that?
I need to though, if I want updates to the API that fix broken stuff
ultimately you lost the source code anyway so you cant submit that bot to begin with
since you can only submit source code and not compiled files
Well I use those bots as test cases to see if I'm improving or getting worse
if bindings use an FFI library then they very likely just assume whatever C does by default, not the packed representation
that's why it works in the existing bindings already 
you can still do that though, your existing bots dont change behaviour
if they end up being worse you don't need them and if they end up better you can't submit them anyway
you dont need to replace them or their bindings
I don't even know any more, it's just a massive pain to deal with all this
I really need sleep
so will this break bindings using those libraries?
will python ctypes for example no longer work as documented
yes, with 1 line fix 
realistically changing it to packed will break all bindings
yes, that's the whole issue here 
everyone needs to specify packed representation to match the C header

ctypes. Structure This is the base class you inherit from when you want to define a Python class that represents a C structure
i think this is ai generated, this is garbage 
it reads really strange
concerning lack of packed from bindgen

wait this is almost certainly a skill issue
attribute packed comes after struct definition
Pain
initialization dependent on field order
Python my beloved

fwiw, sorry for breaking everyone's bindings by bringing up the alignment issue 
thank you C for letting me put __atribute__ somewhere meaningless and still compiling, very cool
I hate whoever did that now and especially whoever decided packed was the best option rather than explicitly aligned
That's gonna cause me so much pain
packed is explicitly aligned
- you lost your source code files, all you have is compiled bots
- you cant submit them because they are precompiled
- you can only use them for testing
- after bindings change, you can still use them for testing, as long as you dont update their bindings
- you wont get bugfixes, but you dont have the source code, so frankly it's your own mistake, sorry.
So annnoyinng
I'm too tired to deal with this this took 1 hour of my meant to be sleep time
I was way too stressed about things breaking to go to sleep, that's the main issue

So especially with me being tired I think I exceptionally hyperfocused on making things stay compatible

is there even anything stopping you from just using the old version with your old bots and use the new one moving forward?
am i missing something
exactly what i said

you only need the .so don't you
yup
no you're not missing anything, this is possible

The castling bug I want fixed?
I don't want random broken castling moves breaking my results
i would praise anyone if they had a LLM that could play chess without hallucinating position past move 20
your old bots are already broken, they just stay broken 

I don't even kknow any more, I just need to sleep or something
couldn't you also keep the old header and use the new fixed c implementation
yes literally
unless shiro does some really cursed stuff inside there
would result in a slightly funny version of the chess API library but yes that would work too 
Shiro current situation
worst case you can rebuild the newest version of the library with just the packed representation for Move reverted
Gn
is that a single pawn
shiro is in a losing position 
At this point I may just do that eventually I don't want to deal with replacing files in a jar file
Alright now sleep for real surely maybe
Yes
man brotli compression suuuuuuuucks
🫸 ♟️
are you compressing with good settings 
brotli i found was comparable or better than zstd and lzma for packed binary data when i was testing
its for hyperspectral image compression
Shiros 1500 elo bot will carry the pawn trust
1500 elo is a strong term
one too many 0s
isn't brotli the one meant for web stuff
you would do better with a dedicated image compression algorithm
brotli is google's compression
they have multiple for different purposes
yup
oh totally, but UNP wants us to test however many different compression algorithms, make a decision matrix, and justify our choice.
we are pretty sure we are gna use bzip2 tbh
you tried zstd?
is there something other than cutechess that can find things that exist?
not yet, just trying to basically verify that the benchmark util works before we do higher loop numbers
my first choices are typically
- zstd,
- lzma,
- xz,
- bzip2,
- gzip,
- and brotli
zstd my beloved
you will need to care to set the correct compresion parameters for each compression
they use different numbers and it can be confusing
you need to pack it into an executable
✅ zstd best
depends on your data
i do wanna quickly confirm
deno.exe is an executable
ive had both lzma and brotli outperform it on packed data
unless you need giga compression and can accept slow decompression, then mabe lzma or xz
packed will for sure fix the alignment issue?
yes but this is the wrong way of doing it
yes
there's nothing implementation-specific about it?
and is it needed on the enums as well
shouldnt be
what's wrong about running an exe with arguments?
enums are just a typedef and constants so i doubt it's needed but
nope, c encodes all enums as 32 bits unless you specify otherwise

because the arguments are being considered part of the path
that's how that typically works
we ideally want time efficient, space efficient, and power efficient- but we know getting all 3 is unlikely. we also need it to be reliable, as this is for a satellite
all 3 is impossible 
yeaaa
time efficient is the same thing as power efficient for most machines
space efficiency is inversely proportional to time efficiency
integer and pointer sizes are still implementation-specific I think but for Move in particular there shouldn't be an issue 
packed fixes the only the alignment issue but everything else is already be taken care of, surely 
so as a result the struct layout should be the same everywhere
time efficiency is likely what we'd be able to sacrifice most on as we could allow it to compress for longer while we arent in our downlink period
LZMA I understand but brotli is surprising to me
i would recommend defining your enums with a specific integer though
like this
typedef enum : uint8_t {
variant
} CoolEnum;
thats possible?
im learning so much about C
that shouldn't break anything right
at least to my knowledge
brotli is competitive from my testing one very specific set of data 
if you set it to uint32_t then yes it should be fine
ill just do that then
Compressor,Image specs (res/bands/depth),Iterations,Compress time total (us),Compress time min (us),Compress time max (us),Compress time mean (us),Compress time std dev (us),Original size (B),Compressed size min (B),Compressed size max (B),Compressed size mean (B),Compressed size std dev (B)
brotli,2048x1088/96/10,1,768889350.000,768889350.000,768889350.000,768889350.000,0.000,427819008,215436765,215436765,215436765.000,0.000``` 50% size reduction, dang!
well, got it to work through a batch file... still stupid, but at least it does random moves now
i recommend it
just so ffi struggles less
i think its less common to be able to set the backing integer of enums in ffi
ctypes and rust both have that capability but others im not sure
please tell me I am reading the compress time total wrong
no. no you are not.

it did take 12.8 mins.
nerd
im sending the results to Space Software Dad so he can get that in the sheet but yea
phrrr
he says, in the programming channel

after inciting an hour long discussion about struct alignment because he wanted to make JS bindings
which work btw
v8 bindings? 
nice try
i'll take that as a yes
3^2
-# edited
it said 9 when i typed it


v9 engine


powering the all new chromium 2
holy cheeto hair evil
ye dipped in dust
welp imma head out now, ttyall later
whenever i come here i lose years off my life due to stress of communicating with programmers


(hi its me programmers)
0
and therefore making the gods of ableos happy

i come here and feel underqualified 
?
well, most people here arent either

it's A
actually it's B
actually you're all wrong it's C
nope answer was 92

i am just starting out after all ...
maybe those solutions work but let me introduce you to D
week ago
confidently incorrect or being obstinate or having an issue that only exists for one person
or speaking to a lion only for the lion to eat your face off
programmers

my issues are usually me not knowing convenient language features or not wanting to obey best practices for hobbyist test code
best practices are subjective and i will kill you if you dont follow my advice to exact letter 
chessapi doesn't compile for me at night when using my dad's handrolled c compiler he wrote 35 years ago after your recent change. i demand it be rolled back
the chessapi doesn't compile for my stm32, please rewrite the entire stdlib
it is the only way

hobbyist test code best practices is do what you want unless you like reading
i started porting semicolons bf interpreter to rp2040 but i just forgot i was doing that one day
chess api and cutechess failed to run on my breadboard with custom riscv cluster compute unit

please patch
the unspoken cost is that you can never get help with bugs because people will get lost on 2 hour tangents about how you should rewrite the entire codebase 
shiro the api doesnt support sending chess moves via light rays
my cpu doesnt have any electrons only photons
please help
qubits will not be supported by the chessapi
quantum computers are too busted for chess anyway
shrioooo can you restructure the entire api to be SOA instead of AOS so it plays 1% more nicely with simd
chess is one of the problems that qc is very good for
simd
the most cmd shiro has in chess api is
how are you gonna enforce the no simd rule
i look at your code and if it spawns a thread then you die
i thought the rule was no multiprocessing
simd is not threads
what
simd is not threads
shiro
the actual wording of the rule is
... or otherwise run code in the background/in parallel ...
so no simd
shiro am I banned from using bitboards
technically simd isnt running code in parallel its just one instruction

bitboards are legal
because I am accessing each position in the board in parallel
NO CODE PARALLEL simd first two letter "single instruction" 
simd does not require running code in parallel
it only processes data in parallel 
(multiple data)
are you doing simd on the cpu 
what
if its on the gpu thats parallel to the cpu code
yes thats what simd is

instructions must be no longer than 4 characters long 
what if the gpu call was blocking 
also what do I name my bot...
bot bot
there will be no gpu calls

well Deno has a large stdlib...
eitherway shiro I think you fundamentally misunderstand what simd is
I wonder if there's webgpu stuff in Deno...
there is no fucking way you just typed that out too but beat me to pressing enter
simd => perform instruction on wide register
i know what simd is im just trying to make a point that its not allowed

but why
stop beating me up for semantics wins
i dont wanna make the rules longer over a silly clarification
what if I coarce the compiler into autovectorization
is that suddenly simd and banned
i agree simd is perfectly legal by this definition
no no as the rules currently are simd is allowed
not as like, a semantic thing
but because simd is literally the same as regular execution
oh hey, Deno has @std/webgpu 
except with larger numbers

well yeah then on cpu its fine
simd just mean "single instruction multiple data", as in, its an instruction that executes on larger cpu registers than 64 bits
just target x86-64-v3 
surely your algorithmic complexity isnt vastly more important
thank you for keeping NNs viable. this certainly will be fun
simd is actually a huge difference though
yeah in terms of tokens 
actually released his own source code?





