#programming

1 messages · Page 195 of 1

real sierra
#

grab new

#

new .h as well just now

trim valve
#

those work

sage crag
#

shirpo do you want hblang bindings ReallyInnocent

real sierra
#

token counter doesnt support hblang in reality

#

so prob cant use

sage crag
#

Awkward token counter PR

#

needs fix

real sierra
#

token counter does need a fix

#

last updated 4 years ago

#

trying to update any of the dependencies is hell tho

#

tried

sage crag
trim valve
#
(gdb) bt
#0  __syscall_cancel_arch () at ../sysdeps/unix/sysv/linux/x86_64/syscall_cancel.S:56
#1  0x000079721bca00ec in __internal_syscall_cancel (a1=a1@entry=105616026212552, a2=<optimized out>, a3=a3@entry=0, a4=a4@entry=0, a5=a5@entry=0, a6=a6@entry=4294967295, nr=202) at ./nptl/cancellation.c:49
#2  0x000079721bca0847 in __futex_abstimed_wait_common64 (private=<optimized out>, futex_word=0x600ea5b998c8, expected=0, op=<optimized out>, abstime=0x0, cancel=true) at ./nptl/futex-internal.c:57
#3  __futex_abstimed_wait_common (futex_word=0x600ea5b998c8, expected=0, clockid=0, abstime=0x0, private=<optimized out>, cancel=true) at ./nptl/futex-internal.c:87
#4  __GI___futex_abstimed_wait_cancelable64 (futex_word=futex_word@entry=0x600ea5b998c8, expected=expected@entry=0, clockid=clockid@entry=0, abstime=abstime@entry=0x0, private=<optimized out>) at ./nptl/futex-internal.c:139
#5  0x000079721bcac5ff in do_futex_wait (sem=sem@entry=0x600ea5b998c8, abstime=0x0, clockid=0) at ./nptl/sem_waitcommon.c:111
#6  0x000079721bcac698 in __new_sem_wait_slow64 (sem=0x600ea5b998c8, abstime=0x0, clockid=0) at ./nptl/sem_waitcommon.c:183
#7  0x0000600e713cd878 in start_chess_api () at /home/owobred/neuro/other/chess-tournament/target/debug/build/chess-api-8324e014b9d4855d/out/chessapi.c:1544
#8  0x0000600e713cdaa3 in chess_get_board () at /home/owobred/neuro/other/chess-tournament/target/debug/build/chess-api-8324e014b9d4855d/out/chessapi.c:1601
#9  0x0000600e713867e7 in chess_api::Board::get () at chess-api/src/lib.rs:285
#10 0x0000600e71386068 in chess_bot::main () at chess-bot/src/main.rs:7

200iq, I debugged it after it stalled

sage crag
#

sem_waitcommon

#

!nothing

stiff micaBOT
trim valve
#

unless I have a major skill issue you should just need to run cargo run in the root directory and the bot will be ran

tender river
trim valve
#

(or well, not ran)

#

beware rust people, I have never made bindings before

#

so it will be scuffed

sage crag
#

are these enums

#

correctly typed

trim valve
#

hm?

sage crag
#

no repr C?

trim valve
#

(keep in mind I'm currently bringing in my own copy of the api because I am too lazy to fetch it from shrios repo)

sage crag
trim valve
#

wait I might be stupid on that front

tender river
#

it uses bindgen

trim valve
#

ye those aren't the ones that go through ffi

tender river
sage crag
tender river
#

shiro use more macros neuroGun

trim valve
#

just like

#

don't sleep all night so you don't remember

trim valve
#

or I can actively un-leak and neither of you can read the repo

#

:3

tender river
#

evilHyperYay macros

sage crag
#

shimo bitboard.c could be 30% of the size if you use macro

tender river
trim valve
#

what have I done

tender river
#

theres like so many ifs with just this

rigid snow
trim valve
#

shrio can you just prematurely execute me

tender river
sage crag
sage crag
#

part of me wants these to be macros too but it doesnt do anything colonthree

#

ye my chess bot now

trim valve
#

konii about the back up the entire chess bot api in screenshots before shiro wakes up

sage crag
#

its ok i already memorised the whole api

#

@tender river evilAware

tender river
#

no codegen UNFOCUS

trim valve
#

yeah ok let board = chess_api::Board::get(); is hanging forever

tender river
#

honestly why even have that

#

Board* is a singleton

#

so it shouldnt be passed via function arguments at all

#

functions should just access the global Board* by themselves

#

hiro can use that function internally if he wants to

trim valve
#

the thing that confuses me is you can free the board

trim valve
#

also I'm mirroring the python api atm

sage crag
#

ye ye but

tender river
#

i would fix the api but

trim valve
#

imo it makes sense if you read the comments

sage crag
#

the api global

trim valve
#

but also yeah its odd

sage crag
#

its ok its just a beta api Awkward

stark needle
#

first time i see this

#

it's an apple llm

sage crag
#

somehow i think it may be apple intelligence

stark needle
trim valve
trim valve
real sierra
rigid snow
tight sparrow
#

programming can i borrow shiro

#

its important

trim valve
#

i wish shiro

real sierra
#

ok guest additions finally installed on vm

#

now i can copy paste from it to here

#

but also wtf has it done to my res

#

480p screen

trim valve
#

iirc it means you can resize the window

#

or something

#

instead of having to manually change res

real sierra
#

WICKED yes

#

this is so much better now

trim valve
sage crag
#

macro not dangerous macro your friend

real sierra
#

macro danger

trim valve
#

marco

real sierra
#

copy paste my friend

tender river
#

shiro cant use macro used to java evilSMH

real sierra
#

^

#

bugfix first then code quality

sage crag
#

macro is a micronutrient

real sierra
#

working ugly better than pretty broken

tender river
sage crag
#

prevent code duplication prevent stupid mistake

tender river
#

its easier to bugfix deduplicated code

real sierra
#

i dont make stupid mistake

#

i too good at coding

sage crag
tender river
sour mason
#

idk if anyone can help, but I‘ve been trying to tokenize a tfds dataset recently but the tokenization functions from tfds and tf dont seem to be available? did they get removed in a later version or smth? anyone knows?

real sierra
#

or

small light
#

why are you nerds such nerds

trim valve
#

that pastes.dev link is a trace

#

or do you want more

tender river
sour mason
tender river
#

haent programed in days

sour mason
real sierra
#

i didnt realize

#

OK i have concluded this makes no sense

#

the mutex is blocking despite it being the first time it hits it

tender river
sage crag
real sierra
#

who locked my mutex Susge

trim valve
#

fwiw shiro I'm just sending ```
uci
isready
ucinewgame
position startpos moves f2f4
go wtime 300000 btime 300000 winc 0 binc 0

real sierra
#

.....

#

pepeS might've found the bug

#

i could've sworn i had this

sage crag
real sierra
sage crag
#

uninitialised value

#

use-before-init

tender river
#

use after init

pulsar edge
#

hi shibo

#

damn he left neuroSad2

sage crag
pulsar edge
#

hi konii

real sierra
#

@trim valve pushed new

pulsar edge
#

hi shibo

real sierra
#

hi scrub

pulsar edge
#

how long is the tourney gonna run for

tender river
real sierra
#

a month is the plan

pulsar edge
#

ic

#

hi chayleaf

sage crag
#

1 month

#

more than enough time for me to make an abomination

pulsar edge
#

shiro how are your commits this wrong ICANT

real sierra
#

wdym this wrong

pulsar edge
#

your commit message says you added a function to the chess api

#

but it doesn't actually show up until 3 commits later

real sierra
#

see next commit

sage crag
real sierra
#

i didnt look at my file explorer right

#

i just pushed chessapi.c

#

but it was the old copy sitting in the python directory

pulsar edge
#

can I criticize your commit messages

real sierra
#

im the only one looking at them

#

not meant for understanding by mortals

#

ls

pulsar edge
#

it would be nice if C changes were C: <message> and the python changes were Py: <message>

real sierra
#

this isnt the terminal

sage crag
#

shrmo give me push access

real sierra
#

the C and python files are totally disjoint

pulsar edge
#

thats my point

real sierra
#

oh wait

#

no i did include two in a commit

#

oopie

real sierra
trim valve
pulsar edge
#

prefix the commit message to make it easier to tell what a commit is modifying

real sierra
#

bred officially the first person to make a chess bot other than me

real sierra
#

im experimenting with doxygen rn but realizing it might not support every language

#

i dont wanna use it for only half the docs

tender river
#

i fully support this

#

shiro can't keep getting away with

pulsar edge
tender river
sage crag
#

we will catch

real sierra
real sierra
pulsar edge
#

uh I had class this morning

real sierra
#

semi important change for you, a chess_free_moves_array func was added

#

so you dont need to import libc for free anymore

pulsar edge
#

god I'm gonna have to write a cmake file for the C# impl

#

eck

sage crag
tender river
pulsar edge
real sierra
#

doxygen default config has helpful comments

#

almost too many

#

thing is 3000 lines with the comments

sage crag
#

i would fix shiro api but im too busy not fixing shiro api

real sierra
#

id rather people dont need to download a dll

pulsar edge
#

the C# impl needs to link against the C dll

real sierra
#

doesnt sound very portable

trim valve
#
2025-09-15 23:33:30.732<--1:thread 'main' (109966) panicked at chess-api/src/lib.rs:364:18:
2025-09-15 23:33:30.732<--1:unsafe precondition(s) violated: slice::from_raw_parts requires the pointer to be aligned and non-null, and the total size of the slice not to exceed `isize::MAX`
2025-09-15 23:33:30.733<--1:This indicates a bug in the program. This Undefined Behavior check is optional, and cannot be relied on for safety.
2025-09-15 23:33:30.733<--1:note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
2025-09-15 23:33:30.733<--1:BytesRead > 0
2025-09-15 23:33:30.733<--1:n > 0
2025-09-15 23:33:30.733<--1:-- LiesThread.Execute terminated --
2025-09-15 23:33:30.733<--1:thread caused non-unwinding panic. aborting.
#

I may

#

have a bug

real sierra
#

that one

#

is not me i think

trim valve
#

also unrelated but ```
2025-09-15 23:38:52.9791Start calc, move no: 200
2025-09-15 23:38:52.980-->1:position startpos moves e2e4 a7a5 g2g3 g8f6 f1b5 c7c5 h2h4 h8g8 b5a6 g7g6 d1h5 g8h8 h5d5 b7a6 d5c6 a8a7 g1e2 a7c7 e1f1 a5a4 f1e1 h7h6 h1h2 c7c6 d2d3 h8g8 g3g4 d8a5 e2c3 c6e6 e1f1 f8g7 b1d2 c8b7 b2b4 a5b5 c3e2 f6e4 c1a3 g8f8 a1c1 e4f6 e2f4 b5c6 f4e6 c6h1 f1e2 f6g8 h2h1 f7f5 e6c7 e8f7 c1f1 d7d6 d2b3 b7e4 f1a1 e4f3 e2f1 g7f6 c7e6 f3h1 b4b5 c5c4 g4f5 h1e4 e6f4 e4h1 a3b2 a4b3 b2f6 b3b2 f4g6 b2a1q f1e2 d6d5 f2f3 a1e1 e2e1 e7e5 f3f4 h1g2 f6e7 h6h5 e7f8 a6b5 e1d1 g2e4 f8g7 f7e8 c2c3 e8d8 d1c1 d5d4 a2a3 e5f4 c1d2 d8c7 g7d4 e4f5 d4f6 b8c6 f6d4 c6e5 d4a7 f5c8 d2e2 c8g4 e2d2 c7c8 g6e5 c8d8 a7b8 g8h6 e5d7 d8d7 b8e5 h6f7 d2c1 f7h8 c1d2 b5b4 d2e1 f4f3 e1d1 b4a3 e5h8 d7c8 h8d4 c4d3 d4b6 c8b8 b6c5 g4h3 c5b6 h3c8 c3c4 c8f5 c4c5 b8c8 c5c6 f5g4 b6a5 a3a2 c6c7 a2a1n d1e1 g4f5 a5d2 a1c2 e1f1 c2a1 f1e1 f5h7 d2c3 h7g8 c3d2 a1c2 e1d1 c2e1 d1c1 c8d7 c7c8r d7d6 c8b8 d6e7 d2c3 g8a2 c3d2 a2c4 b8b7 e7e8 c1d1 c4b5 d2g5 b5a6 b7b6 f3f2 g5e7 f2f1b d1c1 d3d2 c1d2 a6d3 d2c1 e8e7 b6b4 f1h3 b4e4 e7d7 e4e5 d7c8 c1d1 e1c2 e5e3 h3e6 e3d3 c2a3 d3b3 e6g4
2025-09-15 23:38:52.980-->1:go wtime 300000 btime 300000 winc 0 binc 0
2025-09-15 23:38:52.981<--1:BoardMoves::as_slice {start: 0x5d4872f4d640 len: 16}
2025-09-15 23:38:52.981<--1:info currmove a3b1
2025-09-15 23:38:52.981<--1:bestmove a3b1
2025-09-15 23:38:52.9811---------> Arena:Illegal move!: "bestmove a3b1" ()

#

this happened

real sierra
#

Concerned that might be my fault

#

ill have a look

trim valve
#

don't worry it very helpfully has the move list

#

(2k5/8/8/7p/6bP/nR6/8/3K4 w - - 3 101 is the FEN)

#

currently hunting for the crash again

real sierra
#

adding macros to bitboard.c where reasonable

tender river
real sierra
#

i dont suppose you can nest macros

tender river
#

you can

real sierra
#

pogs

tender river
#

macros can call macros

#

including dependency injection

#

when a macro is expanded it temporarily gets disabled

#

as in, a macro cant be expanded in its own expansion

#

thats basically the only limitation

#

also you should use ident concatenation in some cases

real sierra
#

gotta admit

#

this is a bit smaller

tender river
#

you can pass all 4 directions from all_dirs to each invocation

#

so the macro can access diametrically opposing directions

#

or 8 i guess

real sierra
#

the bb slide commands still have to be custom tho

#

since they're tuned per direction

#

not copy-paste

#

uh

#

should i have put the macros in the header

sage crag
tender river
real sierra
sage crag
#

including symbol

real sierra
#

no all 8 of these functions are different

tender river
# real sierra wdym

#define all_dirs(x)
x(n, e, s, w)
x(e, s, w, n)
x(s, w, n, e)
x(w, n, e, s)

real sierra
#

catdespair wtf is that

opaque sigil
#

Thus the macrofication begins neuro7

real sierra
#

why would i do that

sage crag
#
#define DO_THING(a, sym, b) ((a) sym (b))

DO_THING(1, +, 2)
DO_THING(1, *, 2)
opaque sigil
sage crag
real sierra
#

oh i see

sage crag
#

i use in vm

real sierra
#

i did opposite

#

or same?

tender river
tender river
#

so you can access diametrically opposing dirs

opaque sigil
#

The idea is that you have a list of things with the assumption that there's a macro
And then you just define said macro to be whatever you need neuroPogHD

tender river
#

so you can rotate the dir by an arbitrary degree in the macro code

real sierra
#

nope im totally lost

sage crag
#

you shimo

#

not lost

real sierra
#

SMH trying to get me to use more macros when i already finished macroifying everything

sage crag
#

awa

opaque sigil
#

Just be careful with macros shiro since they don't have symbols

sage crag
#

use more macros to use less macros neuroCatModeOn

real sierra
#

all trolling

sage crag
real sierra
#

removing all macros

sage crag
tender river
#
#define flip(n, ne, e, se, s, sw, w, nw) case dir_ ## n: return dir_ ## s;
switch (dir) {
_all_dirs(flip)
}
sage crag
#

use computed goto SMH

#

(not do that)

tender river
sage crag
sage crag
tender river
#

flips the direction assuming _all_dirs passes all 8 dirs to x

sage crag
real sierra
#

and shouldn't

tender river
real sierra
#

why would i do that

sage crag
tender river
real sierra
#

you dont seem to get it

tender river
real sierra
#

wait

#

maybe you do get it

#

no you dont Bruhgi

#

im sure you can find some sequence of 3 or 4 macros that generates this but why

tender river
#

ye cant dedupe that

real sierra
#

its just wasting my time

#

yea this is what i meant by "tuned per function" sorry if i wasnt clear

#

i didnt mean copy paste and swap a letter

#

i meant they're actually different

#

anyway

#

feel free to figure out which macros make that

real sierra
#

probably one for ns modifications, one for ew modifications

tender river
real sierra
#

that makes sense

#

i still prob wont do that

#

im more concerned with code readability than macro shortness

tender river
real sierra
#

i confuse

trim valve
#

damn tournaments are funny

real sierra
#

do i have separate defines in the header

#

to just generate declarations

#

or can i leave those

tender river
#

dont put them in the header if they arent part of the interface

#

if they're used for definitions but not declarations

real sierra
#

i mean for this

tender river
#

honestly i'd either convert direction to enum or just keep it as is

real sierra
#

keeping OK

#

direction as enum catdespair no thx

tender river
#

better to keep interfaces explicit Neurorb

real sierra
#

agree

tender river
real sierra
#

yes

#

im not deciding which direction on the fly

#

it also faster without enum

sage crag
#

then macro FOCUS

real sierra
#

so if i define _all_dirs macro in bitboard.c

#

and chessapi.c includes bitboard.h

#

does it have access to it

trim valve
real sierra
#

or must redefine

tender river
real sierra
sage crag
#

it wont be visible by #include "a.h" though

#

i think

tender river
#

i might have misread colonthree

real sierra
#

if there's 0 moves and arena doesnt turn off the chess bot then it will try to dereference the first element of get_legal_moves and segfault

#

expected behaviour

#

not worth the tokens to avoid

tender river
#

each header is just code copypasted to include sites

real sierra
#

i was worried about that

#

worried about the opposite actually

#

keeps my defines separate which is nice

#

ok

#

time to macro nuke the chess api

trim valve
#

several

real sierra
#

keep note of all these bugs bred will fix in a min

trim valve
#

yeah

#

about to head to bed soon so like

#

I'll try and find an example

real sierra
sage crag
stark needle
trim valve
# trim valve <:neuroPogHD:1057778797056901130>
uci
isready
ucinewgame
position startpos moves e2e3 g7g6 g2g4 h7h5 c2c3 a7a6 c3c4 f8g7 f1h3 d7d5 h3g2 g7f8 d1c2 h5h4 c2d3 c8f5 g1e2 f7f6 h2h3 a8a7 g2e4 a6a5 f2f3 e8d7 e1d1 b7b5 e2g3 e7e5 d3e2 h8h7 d1e1 f8e7 h1g1 f5g4 h3g4 b5c4 g1f1 e7a3 f1f2 c7c5 f3f4 d8b6 e2c4 h7h8 b1a3 h8h5 f2g2 b6b7 a1b1 d5c4 g3f5 b7c8 b2b4 c8c6 g4h5 a7a6 e1f1 c6d6 g2g6 d7d8 e4c6 b8c6 d2d3 d6e7 a3b5 e7g7 c1d2 e5e4 b1b2 c6b4 b5c7 b4d3 b2b7 d3e1 g6h6 c4c3 f5g7 d8d7 b7b1 a6d6 d2c1 h4h3 b1a1 d7c8 c1b2 e1d3 h6h7 d3f4 b2c1 d6d4 c7b5 f4e2 f1f2 d4d5 f2f1 e2f4 a1b1 c5c4 f1g1 c8d7 h7h6 f4g2 g7e6 d5d3 h6g6 d7e8 g6g5 g8e7 g5g3 g2h4 g1f2 h4g2 e6f8 d3d4 a2a4 d4d3 b5d6 e8d8 d6c8 d3d2 f2f1 d2e2 b1b4 g2e1 g3g1 e1d3 c1b2 e2c2 g1g8 c2c1 b2c1 d8c7 c8d6 e7g6 g8g6 c7d8 d6e8 c3c2 g6g1 d3f2 b4b2 d8e7 e8g7 f6f5 b2b1 f2d1 g1g6 h3h2 g6g1 d1b2 b1a1 e7f6 g7e8 f6f7 e8g7 c4c3 f8d7 b2c4 c1b2 c2c1r b2c1 h2h1r g7e6 f7e8 c1a3 f5f4 a1d1 c4e3 f1e1 f4f3 d7f6 e8f7 e6c7 h1h2 a3c1 h2c2 f6g8 e3d1 c7d5 f7e6 e1f1 c2h2 h5h6 e4e3 g1g3 e6d6 g3g7 h2g2 g7g2 d6c5 g2g7 e3e2
go wtime 299992 btime 300000 winc 0 binc 0
#

this crashes the C bot

real sierra
#

ill look into it

trim valve
#

if I had to guess its failing to parse the board or something

#

oooh wait are you assuming a max line length

real sierra
#

CAUGHT perhaps

#

does that happen to be around

#

256 chars

#

or 1024 maybe

#

idk what the buffer was

tender river
#

shiro keep it

real sierra
#

ill just make the buffer 1GB

trim valve
#

shruge

real sierra
#

find a chess game that long

real sierra
#

its probably just over 1024

#

but it should count whitespace so

#

idk

opaque sigil
#

784 chars (without whitespace)

trim valve
#

oh wait if I copy in the go command with it then its 1028

real sierra
opaque sigil
#

wait no

real sierra
#

"surely no game will exceed this! its a whole kb!"

opaque sigil
#

so stingy with the buffers smh

real sierra
#

holy

trim valve
#

tbh I only hit this when pitting two random bots against each other

real sierra
#

honestly impressive

#

they never hit the 50 move draw?

#

or the threefold repetition?

#

ive had my own bots fight lots of times without hitting this issue

tender river
real sierra
#

anyway

#

ill bump it up to 4096

tender river
#

i wonder whats the longest game you could make

tender river
real sierra
tender river
real sierra
#

50 moves since moving a pawn or capturing a piece is the condition

#

autoclaimed by Arena*

#

not the api

#

api will just not tell the bots Tomfoolery

trim valve
#

after increasing the buffer

real sierra
#

how do i macro any of this

#

this is a problem for later

#

this is a nightmare to macro

opaque sigil
#

if you can't immediately think of a way you probably just shouldn't

tender river
#

so ~7100 moves is the theoretical maximum

trim valve
#

ok

real sierra
#

the code is just so specialized for performance

sage crag
trim valve
#

slight issue

sage crag
#

why not dynamic size

trim valve
real sierra
#

dynamic size curzed

trim valve
#

arena segfaulted

real sierra
#

ARENA SEGFAULTED?

#

wtf did you do MONKA

trim valve
#

i uh

tender river
trim valve
#

just had a tournament going between two of my bots

opaque sigil
#

try passing utf-8 neuroPogHD

#

actually

#

isn't it all ascii

trim valve
#

they were at like 480 moves last I checked

opaque sigil
#

how tf do you run into utf-8 issues neuroCry

trim valve
#

I wonder if arena has a funny hardcoded limit of 512 moves or something

#

idk the utf-8 is unrelated

real sierra
#

i need a good logo for the tournament

#

and for announcement banner

#

ideas?

#

can i just put terminator in a rook hat

trim valve
#
uci
isready
ucinewgame
position startpos moves g1h3 b8a6 b2b4 a6b8 c1b2 b7b5 d1c1 e7e6 b2e5 b8c6 e5f4 c6e7 c1b2 g7g6 b2c1 g8h6 g2g3 c7c6 h3g1 d7d5 f4h6 f8h6 b1a3 c6c5 f2f3 d8b6 c1d1 h6e3 a3c4 e3g1 f3f4 e8f8 e2e4 b6d8 d1h5 a7a5 c4a5 d5e4 a5c4 e7c6 h5h6 f8g8 f4f5 d8d4 a2a4 c6a7 f1h3 c8b7 e1f1 d4c4 f1e1 c4f1 h3f1 a7c6 f1b5 g1d4 h6e3 c6e5 a4a5 e5d3 e1e2 a8b8 e3h6 b8e8 a1e1 e4e3 c2c4 d4e5 b4c5 b7d5 f5f6 e5b8 h6e3 b8a7 e1c1 e6e5 c1b1 h7h5 b1d1 d3b4 c4d5 b4c2 h1e1 a7b8 d1c1 c2e1 e2f1 h5h4 b5c6 b8d6 d2d4 h8h6 c6b7 e8b8 d4e5 e1f3 c1c4 f3h2 f1g1 h2f1 e5d6 g6g5 e3g5 g8h8 g1f2 h8h7 g5f5 h7h8 c4h4 b8e8 h4h3 e8d8
go wtime 299992 btime 300000 winc 0 binc 0

much shorter but also crashes

#

gonna sleep now

tender river
#

good night FOCUS

sage crag
#

bad night deliv

tender river
sage crag
#

noe

#

i konii

tender river
#

i'll consider it

sage crag
#

i have already considered it for you

#

no consideration on your part is required

tender river
#

phrrr FOCUS

real sierra
#

big mistake just made

#

forgot the trailing .

#

salute whole project

tender river
real sierra
#

good thing i pushed chessapi.h like half an hour ago SAVED

real sierra
#

are you sure you grabbed the new version of the API

#

am i sure i pushed the new version of the api

#

back to shrinking my bot Happie

#

sent

#

i really thought this would work Sadgi

tender river
#

you have to create a separate macro for each arity

real sierra
#

unhelpful for shrinking my chess bot

#

but ty for explain

#

wait i genius

opaque sigil
#

am i misunderstanding or is the goal just something like this

opaque sigil
#

or do you want it to be recursive

real sierra
#

but thats just a test

#

the end use case was gonna be function definitions

#

then i could leave off the curly braces and return type everywhere

opaque sigil
real sierra
#

this is the stage of token saving im at

#

so close

opaque sigil
real sierra
#

look at that token save

#

but of course they all have the same contents with that definition

opaque sigil
#

nothing stopping you from making it more complicated

#

pass more stuff to the macro

real sierra
#

its ok

#

i might not need it

#

im mangling my everything

#

im learning the tricks

#

always use the same generic variable names everywhere

#

so you can strip common patterns into defines

real sierra
#

just a few more tokens

#

all return values are now named rv OK

#

omg im so close now just like 20 more tokens

#

5 more

#

this code is a crime

hollow spruce
#

I will hack d bus

opaque sigil
#

what are you doing shiro

real sierra
#

OPTIMIZING

#

YOU WOULDNT UNDERSTAND

hollow spruce
#

System -end crash soo much

real sierra
#

THIS IS WHAT REAL C PROGRAMMING LOOKS LIKE

opaque sigil
#

i'm a washed c programmer neuroSadge

real sierra
#

i found it

#

i found the final optimization

hollow spruce
opaque sigil
real sierra
#

now its broken

opaque sigil
real sierra
opaque sigil
#

oh

real sierra
#

any way to expand the defines and nothing else?

opaque sigil
#

specific ones? not easily

#

i guess clangd can do that

real sierra
#

gdb gave function at least

opaque sigil
#

gdb my beloved

real sierra
#

now THAT is weird

#

is legal move checking magically broke or something now

#

im so lost

#

i think the bitboard macros broke the entire API

#

great

opaque sigil
#

dope

real sierra
#

Copege but its like 200 bytes smaller it was so worth it

dense kestrel
#

actually not too bad yet

#

wait

#

why don't you compile and just give it the binary

#

i haven't the foggiest idea what the context is

real sierra
#

the context is i need my source code to be at most 1024 tokens

real sierra
#

ah

#

found it

#

i assumed !x was the same as x == 0

#

but !(-1) == true

#

its still acting

#

super weird

#

something else must be bugged

#

oh

#

because immediately after saying all that i put in x <= 0

#

putting my bot against the random bot

#

if i cant even beat this ive truly failed

#

well...

dense kestrel
#

💀

real sierra
#

please read the line

#

directly below that one

dense kestrel
#

💀

real sierra
#

thats what i thought too

dense kestrel
#

surely this is the c standard

real sierra
dense kestrel
#

The result of the logical negation operator ! is 0 if the value of its operand compares unequal to
0, 1 if the value of its operand compares equal to 0. The result has type int. The expression !E is
equivalent to (0==E).

real sierra
#

its also an enum instead of being strictly an int

#

god only knows what happens under the hood

real sierra
#

i have 8 tokens to improve this bot

#

how do i spend them Hmm

sage crag
dense kestrel
sage crag
#

in fact, -1 is the only case where ! and ~ produce the same output

#

so

dense kestrel
#

unless you're on ones complement

dense kestrel
#

like a weirdo

sage crag
#

two's complement is surely c standard

dense kestrel
#

— the corresponding value with sign bit 0 is negated (sign and magnitude);
— the sign bit has the value −(2M) (two’s complement);
— the sign bit has the value −(2M − 1) (ones’ complement).

#

indeed

#

it leaves it up to implementation to choose which one

#

Which of these applies is implementation-defined

real sierra
#

if I run out of tokens again I think my next victim is );

dense kestrel
#

have you hit all the for and while loops yet?

real sierra
#

for loops?

dense kestrel
real sierra
#

I only have for_0_i(lim)

#

no other types of for loops exist

dense kestrel
real sierra
#

yes I already did that that's what I'm trying to say

dense kestrel
#

wow i thought you meant that you kept it that long

real sierra
#

no lol that's just the macro name

dense kestrel
#

lol

#

have you removed all the new lines and spaces and tabs?

real sierra
#

#define tree_child tree->children[i] is also carrying crazy weight

real sierra
#

won't have any effect

dense kestrel
#

incredible

real sierra
#

this isn't source code length I'm trying to minimize

#

just semantic units

dense kestrel
#

wait did you define a struct for that?

real sierra
#

I need a struct for what I'm doing

real sierra
#

beo

#

you don't even know what the code does

#

🥀

dense kestrel
#

indeed

#

but i know that its always jankifiable

real sierra
#

my data structure choice is fine

sage crag
real sierra
#

adding more array indexes is not good

real sierra
#

y cannot contain a ,

#

or it delimits it

sage crag
real sierra
#

that one might work

#

nice savings

sage crag
#
#define IF(x, ...) if (x) { __VA_ARGS__; }
IF(a, b)
real sierra
#

slowly but surely we're approaching functional programming

sage crag
#

this is

#

something

real sierra
#

python programmers with no macros CatLaughingAtYou

dense kestrel
real sierra
#

but they get sorted()

olive sable
#

Goodmorning neuroWaveA

sage crag
#

IF(x, a) has the same number of tokens as if (x) a;

dense kestrel
#

wow

velvet crestBOT
#

You have unlocked new role

olive sable
#

Me

sage crag
#

#define IF(...) if (x) { __VA_ARGS__; }

#

and just assume there is some x defined

real sierra
#

not worth

#

you then need a bool x = somewhere

#

or int x =

dense kestrel
#

💀

sage crag
#

possibly, but what about a global bool ReallyInnocent

real sierra
#

you still need x =

#

so the two tokens you save are lost

#

not to mention you only save those tokens in the #define

#

and the x = is per usage

sage crag
#
#define FUNC(ident, ...) ident() { __VA_ARGS__; }

// int x() { return 0; }
FUNC(int x, return 0)

@real sierra saves 1 token ReallyInnocent

dense kestrel
#

what if you write x&&y;

#

or x||y;

sage crag
#

this also makes me realise

#

#define and &&

#

save 1 token per &&

real sierra
#

probably doesnt

sage crag
#

it does

#

i checked

#

i have tcount

real sierra
#

screenshot

#

i dont believe

dense kestrel
#

what about using ternaries

#

x?y:z;

real sierra
#

im using ternaries everywhere

sage crag
dense kestrel
#

its still eval'ed

real sierra
#

blursed

#

makes me concerned for C

sage crag
dense kestrel
#

wow

real sierra
#

there is only one instance of && in my code

#

and no instances of ||

sage crag
#

rip

dense kestrel
real sierra
#

i think i already replaced || with *

dense kestrel
#

or your if macro

real sierra
dense kestrel
#

i think its more efficient probably

real sierra
#

reasoning?

dense kestrel
real sierra
#

can you show me some code

#

an example

sage crag
#
FUNC(int main, IF(1 and 2, return 0) return 1)

//expands to

int main() { if (1 && 2) { return 0; } return 1; }

MyHonestReaction

dense kestrel
#
int uwu();
bool x = 1;
x&&uwu()&uwu()&uwu();
sage crag
#

you dont need to remove the spaces you know

#

spaces arent tokens

dense kestrel
dense kestrel
real sierra
#

but not shorter unless your condition is very simple

sage crag
real sierra
#

any complex conditions need () around them

real sierra
#

so you're only removing the if

#

and then adding && (1 token)

#

so you're net zero

dense kestrel
sage crag
real sierra
real sierra
#

only works if x is a variable

dense kestrel
#
#define q )&
int uwu();
bool x = 1;
x&&uwu( q uwu( q uwu();
real sierra
#

if x is a condition, e.g. cond 1 > 0

#

it prob needs brackets

#

or does it

dense kestrel
#

i am pretty sure it doesn't

#

if u have space

sage crag
#
#define IF(x, ...) (x) and {{ __VA_ARGS__; }}

this would work on clang or gcc

dense kestrel
#

and space isn't token

real sierra
#

no parentheses needed pogs it comes later in operator precedence

sage crag
#

the double curly brace is to get the brace to evaluate

#
auto y = {{ x; }};

ye this is a thing you can do in clang and gcc

real sierra
#

AUTO

#

I DONT GET AUTO smadg

sage crag
#

strangely these are the same number of tokens

#define IF(x, ...) if (x) BLK(__VA_ARGS__)
#define IF(x, ...) (x) and {{ __VA_ARGS__; }}
sage crag
real sierra
#

no

#

its against my principles

sage crag
#

-std=c23

real sierra
#

its c++ slop

dense kestrel
#

auto bad

real sierra
#

auto bad

sage crag
#

auto not bad

#

auto useful

real sierra
#

death before dishonor

#

auto bad

sage crag
#

why auto bad

real sierra
#

javascript feature CatLaughingAtYou

dense kestrel
sage crag
#

it not javascript feature, still strongly typed

real sierra
#

bad bad bad SMH

sage crag
#

i think you are wrong enub

real sierra
#

no like

#

no auto

dense kestrel
#

smh why use iterator when you can use pointer

real sierra
#

i spend extra tokens for no auto

tender river
#

shiro java dev

sage crag
#

must have long type name

real sierra
sage crag
real sierra
dense kestrel
#

wait

#

bruh

#

that mistake never occurred

real sierra
#

if you wanted

#

more details behind why im doing this

#

i plan to host a chess bot tournament here where your entry is limited to 1024 tokens

real sierra
burnt ridge
dense kestrel
#

this is actually very W idea

real sierra
#

you're welcome to participate

dense kestrel
real sierra
#

nuhuh no reading/writing files

dense kestrel
#

only would take a few decillion years to get the seed

dense kestrel
sage crag
#
#define IF(x, ...) if (x) BLK(__VA_ARGS__)
#define IF(x, ...) (x) and BLK(BLK(__VA_ARGS__))
#define IF(x, ...) x ? (__VA_ARGS__) : PARENS

all three of these are the same number of tokens

dense kestrel
#

i think that is fine

sage crag
#

awful

dense kestrel
sage crag
#

token counter doesnt think so

#

every one of these i replace is

#

increasing the token count

dense kestrel
#

wat

#

literally how

sage crag
#

ok for just

#define def #define

#define and &&
#define or ||
#define PARENS ()

swapping them to def reduces token count by 1

dense kestrel
#

so cost is amortized

dense kestrel
#

well not amortized

sage crag
real sierra
#

* instead of and

sage crag
#

so cost is irrelevant

real sierra
#

save 3 tokens

dense kestrel
#

i haven't the foggiest idea how you all are counting tokens

sage crag
#
#define def #define
#define BLK(...) { __VA_ARGS__; }

but swapping #define to def here increases tokens by 2

dense kestrel
real sierra
#

easy way to think of it is words + punctuation (roughly)

#

int x = 1; -> ["int", "x", "=", "1", ";"]

dense kestrel
#

wow

#

incredible

sage crag
#

and just use & or |

#

saves the same number of tokens without defines

dense kestrel
#

wait wtf why is brew installing another llvm

#

i have like installed llvm like 3 times now

#

💀

#

ts me when i just want some rust to install

sage crag
real sierra
#

2 && 1
2 & 1

sage crag
#

yes im aware that && is a terminating operator

real sierra
#

no the problem is

#

the first will be true

#

and the second false

sage crag
#

yes because it

#

terminating

#

operator

real sierra
dense kestrel
#

oh yes

#

my b

tender river
#

shro do you use the comma operator

dense kestrel
#

bozo momento

real sierra
sage crag
real sierra
#

almost every , corresponds to one removed ;

tender river
#

also declare variables as early as possible and in bulk

real sierra
#

thats irrelevant i already have #define bclose ) {

#

bclose my beloved

tender river
#

e.g. not in loop body but outside of the loop

sage crag
tender river
sage crag
#

reuse variables better

real sierra
#

^

#

if you reuse variables you can bake them into macros

#

helps reduce tokens and increase macro usefulness

sage crag
#

ye which why i suggested

#define IF(...) if (x) BLK(__VA_ARGS__)
``` but no ![koniibwaa](https://cdn.discordapp.com/emojis/1367518991865610351.webp?size=128 "koniibwaa")
real sierra
#

it good thinking but not quite there

#

needs more time in oven

sage crag
#

you need more time in oven imageremovebgpreview

real sierra
#

im stuck on hard problem

tender river
real sierra
#

how do i go from bitboard to piece type in as few tokens as possible

sage crag
#

this is opaque because i legally dont have your api

tender river
#

ye neither do i

real sierra
#

soon Prayge

#

once bred starts playing with their ai again and finds the last of the edge cases

#

contest is basically good to goo once this is done

#

i just want it thoroughly tested

tender river
sage crag
#

ye shiro replace all function with macro

#

save token

tender river
#

goto NeuroBounce

sage crag
real sierra
sage crag
dense kestrel
#

hmm if it were memory or time optim i would think it would be fine

#

but code size optimization is actually so hard ong

real sierra
#

small spoiler

#

in the Move struct, the origin and target squares are stored as BitBoards

#

where typedef uint64_t BitBoard

sage crag
#

bitboard with what info

real sierra
#

bit flip 1 = something there Happie

real sierra
sage crag
real sierra
#

they store piece locations, theres one per color-type combo

#

each bit corresponds to a board square

#

in the move struct, bitboard just store square from and square to

dense kestrel
#

what if you gave us an unsigned _BitInt(256) var;

real sierra
#

idk how go from this to piece type without just pulling all piece bitboards and checking perish

dense kestrel
#

instead for the board

#

so you can encode the actual piece as well

real sierra
#

im not using c23 im pretty sure

dense kestrel
#

unfort

sage crag
#

it so easy

#

shimo do you know about __COUNTER__

real sierra
#

token counter made 4 years ago

#

might be uncounted tokens in c23

sage crag
#

there are none

#

that im aware of

real sierra
#

maybe ill add the flag then

#

regardless, not switching bitboards from uint64_t

#

more helpful internally for them to be separate

dense kestrel
#

hmm

#

would it be that bad with 14 bitboards?

real sierra
#

14?

dense kestrel
#

pawns, knights, bishops, queens, kings, rooks, position occupancy

#

okay 13

real sierra
#

nono

#

there are only 12

#

what the bitboard stores is their occupancy

dense kestrel
#

wow

#

i see now

real sierra
#

the black pawn bitboard has bits flipped for every square containing a black pawn

#

very nice internally, lots of fast ops since its all bitwise integer math

#

unfun on token limit

real sierra
#

isnt that op

#

not that op actually Hmm

#

i was gonna use it in a for loop def but

#

actually no still op

sage crag
dense kestrel
#

#define c __COUNTER__

real sierra
#
#define for_(l) for_v(i ## __COUNTER__, l)
#define for_v(var, l) for(int var=0;var<l;var++)
sage crag
#

efine

dense kestrel
real sierra
#

bots manage their time management

dense kestrel
#

wow i forgot the header of that

tender river
#

AINTNEURWAY i saw this van gogh painting and thought "ai art" because of the palette

sage crag
real sierra
#

why not

#

OH

#

i redefined for