/robowaifu/ - DIY Robot Wives

Advancing robotics to a point where anime catgrill meidos in tiny miniskirts are a reality.

Canary has been updated.

Build Back Better

Sorry for the delays in the BBB plan. An update will be issued in the thread soon. -r

Max message length: 6144

Drag files to upload or
click here to select them

Maximum 5 files / Maximum size: 20.00 MB


(used to delete files and postings)

Have a nice day, Anon!

C++ Learning Classroom Chobitsu Board owner 02/11/2023 (Sat) 02:56:07 No.19777
Keep your eyes on the prize edition --- Notice: I'm going to have to put a hiatus on this project until at least this Summertime 2024 (probably later). A) There seems to be only a little interest in it right now by anons. B) Right now in my life I have too much else on my plate that needs attention. C) In the meantime, whenever I'm here I'll still be happy to answer any questions anons have for the first 11 classes so far, or for anything in the textbook thread also. I hope to be back with this later, Anons. Cheers. --- • v231125 week-thirteen, lecture: semester-end catchup (N/A) - this week's reading assignments: N/A - reading review: N/A - reading preview: PPP2 ch12 - this week's assignments: (N/A) --- So, we're done with the STL semester, this is just a decompress week to wrap up any questions you might have left/turn in your work catchup. We'll take a break until sometime in the new year, where we'll pick back up with creating C++ GUIs using the FLTK library. Merry Christmas season Anons, please enjoy the break. --- • Our classroom's textbook thread is here : (>>18749) - you'll find a link in that OP to an archive of all the code examples therein, for your local study • This course material is primarily derived from Bjarne Stroustrup's college freshman textbook Programming -- Principles and Practice Using C++, 2e (aka, PPP2) https://www.stroustrup.com/programming.html - please obtain a copy of that book for yourself, as you'll need it to complete this course successfully --- >note: if you see the thread pinned, it (should) mean we're nearby to help, so ask away! --- • BTW, we'd like to get some feedback from the class participants about this C++ programming class. Specifically, I have a few questions and I seek ideas & advice from Anons how to approach these needs: - How to best run our classroom using (only) this IB? - How to give out exercises & assignments, & receive solutions? - How to assign grades? - How to manage the asynchronous nature of IB communications, student-to-instructor (and vice versa)? - How to utilize the textbook thread well, since it (mostly) contains already-worked solutions? - How to do tests? - How to manage a final group project together? What should that project be in fact? - Any other advice or suggestions you think would be helpful. Please post your recommendations for these topics ITT Anon, thanks! :^) --- >unless otherwise-noted, everything ITT is MIT (Expat) licensed >copyright 2023-2024
Edited last time by Chobitsu on 02/05/2024 (Mon) 12:10:03.
>>26196 Lecture 09 ends 9
>spare reserve
>spare reserve
>spare reserve
how do you make a vector with function pointers? im trying to make a callstack
>>26201 trying to do vector<int *(int, ...)>func(5) but it prints an entire page of garbage as an error message cant even read any of, with an array its fine though int (*func[5])( int, ... )
>>26201 >>26204 >im trying to make a callstack Neat! I'm not on a box I can do a quick check for you, but it seems to me this should probably work: vector<int (*)(int, ...)> func(5) I'll take a look at it sometime tomorrow when I'm better able to. BTW, since you're using C++ you can probably take advantage of that and go all the way to creating a full class for your Callstack with all the bells & whistles neatly packaged up?
>>26206 I'm not into C++, so I can't help you directly. But if you would use the Opera browser for your project, then you could use chatGPT (3) in the sidebar the whole time. I'm having positive experiences with it, asking about Python, libraries, examples, Emacs shortcuts, fixing some code, making it shorter ... As I said, not C++ but Python, though it might work for C++ as well. With an account on sites like Poe.com you can also ask bigger models on their site.
>>26201 >how do you make a vector with function pointers? Here's a quick example using C++11 lambdas, Anon. Hopefully this will get you kickstarted : >callstack_main.cpp // build & run : // g++ callstack_main.cpp -std=c++14 && ./a.out #include <functional> #include <iostream> #include <vector> using namespace std; // a couple of arbitrary void functions : void prt_num(int i) { cout << i << '\n'; } void prt_dbl_num(int i) { cout << (i * 2) << '\n'; } int main() { // an empty vector of void functional types vector<function<void()>> funcs; // store a few lambdas (aka, 'closures') into the container : funcs.push_back([]() { prt_num(42); }); funcs.push_back([]() { prt_num(700); }); funcs.push_back([]() { prt_num(9'001); }); funcs.push_back([]() { prt_dbl_num(42); }); funcs.push_back([]() { prt_dbl_num(700); }); funcs.push_back([]() { prt_dbl_num(9'001); }); // execute all stored functionals, beginning to end for (auto const& fn : funcs) fn(); } >output: 42 700 9001 84 1400 18002 Try that (adapting it to your specific usecase ofc), then let me know how it goes please. Cheers. :^) >>26211 Thanks NoidoDev! That's good advice, and much appreciated. Cheers. :^) >=== -edit code example
Edited last time by Chobitsu on 11/05/2023 (Sun) 15:57:55.
>>26215 nice thats what i needed, ty
>>26221 Great. Please post results when you've perfected everything Anon. BTW, now you're rolling with things, I'd suggest you investigate std::stack[1]. I believe you'll find all the semantics you want all there for you in a purpose-designed C++ container. Cheers. :^) 1. https://en.cppreference.com/w/cpp/container/stack
>>26222 thanks was just playing around and made a simple regex engine, the ugliness is unavoidable i think#include <functional> #include <iostream> #include <vector> #include <cstring> using namespace std; class regex { public: struct { const char *ptr; int cur, len; }Text; struct { int cur, len; }Match; const char *expr; int cur; vector<function<int()>> funcs; void reset( void ) { Text.cur = 0; } int mChar( const char c ) { return ( Text.ptr[ Text.cur ] == c ); }; int mAny( void ) { char c = Text.ptr[ Text.cur ]; return ( c != '\n' ) & ( c != '\0' ); }; int mOpt( void ) { int m = funcs[ ++cur ](); Text.cur -= !m; return m + !m; } int mMulti( class regex *Left, class regex *Right, int greedy ) { int m; int save = Left->Text.cur; Right->Text.len = 1; do { m = Left->funcs[ Left->funcs.size() -2](); Left->Text.cur += m; Right->Text.len += m; } while ( m ); Left->Text.cur = save; Right->Text.ptr = &Left->Text.ptr[ Left->Text.cur ]; Right->Text.cur = 0; Right->exec(); int ret = Right->Match.cur + Right->Match.len ; if ( greedy ) do { ret = Right->Match.cur + Right->Match.len ; m = Right->exec(); } while ( m ); return ret; } int exec( void ) { if ( Text.cur >= Text.len ) return 0; for ( cur=0; cur<funcs.size(); cur++ ) { int m = funcs[ cur ](); if ( m ) { Text.cur += m; continue; } cur = -1; Text.cur = Match.cur + 1; Match.cur = Text.cur; if ( Text.cur >= Text.len ) break; } Match.len = Text.cur - Match.cur ; return Match.len; }; void bind( const char *text, int len ) { Text.ptr = text; Text.len = len; Text.cur = 0; } void compile( const char *expr ) { funcs.clear(); this->expr = expr; int len = strlen( expr ); for ( int i=0; i<len; i++ ) switch ( expr[i] ) { case '\\': // escape ++i; default: // char funcs.push_back([this,expr,i]() { return mChar( expr[i] ); } ); break; case '.': // any funcs.push_back([this]() { return mAny(); } ); break; case '?': // zero or one if ( !i ) break; case '*': // zero or more funcs.push_back( funcs.back() ); funcs[ funcs.size() -2 ] = [this]() { return mOpt(); } ; if ( expr[i] == '?' ) break; case '+': // one or more class regex *Right = (class regex *)calloc( sizeof(class regex), 1 ); Right->compile( &expr[i+1] ); funcs.push_back ( [this,Right,expr,i]() { return mMulti( this, Right, ( expr[i+1] != '?' ) ); } ); return; } }; }; int main() { class regex Expr1 = {}; Expr1.compile( "t5?.+?st\\?.x+ s.*enX*d" ); Expr1.bind( "afsd test?xxx sqwe enp end? @@", 12 ); int m = Expr1.exec(); printf( "\033[1;7;93m str = '%s' \n\033[0m" "\033[1;7;96m expr = '%s' \n\033[0m" "\033[1;7;92m pos=%d len=%d \n match = '%.*s' \n\033[0m", Expr1.Text.ptr, Expr1.expr, Expr1.Match.cur, m, m, &Expr1.Text.ptr[Expr1.Match.cur] ) ; }
>>26231 Wow very nice stuff Anon! Some clever things going on there. Also, very cool to me personally seeing you embracing the benefits of C++ . I too trod a path of C first, then C++. They are definitely different ways of thinking about & doing things, but IMO the further along you get in the journey towards mastery of C++, the more you wind up mostly :^) appreciating much the language has to offer. >tl;dr Eventually this language becomes rather fun to use (explicitly one of Bjarne's major stated goals) and the power of free abstractions simply can't be beat! or ignored, IMO. :^)
Lecture 10 begins 1
>>26325 Lecture 10 ends 9
>spare reserve
>spare reserve
>spare reserve
Open file (80.73 KB 1079x791 virginityiscool.jpg)
>>26326 My C++ teacher docs points on my assignments when I add lying berries to my programs but don't use them. Like if i had <fstream> but didn't have any files read in the program. I just copy and paste from a large list and then slap it in my program. I wish he didn't do that but oh well. As a programmer, is it bad programming practice to add certain lying berries to your program if you don't use them? like adding <string> to your program but not having any strings?
>>26365 >As a programmer, is it bad programming practice to add certain lying berries to your program if you don't use them? like adding <string> to your program but not having any strings? Please define 'lying berries' for me a bit clearer, Anon. As to adding superfluous #includes, it simply adds slightly to the compilation process workload (by expanding the entire text of the string library and all it's dependencies in-place as a preprocessing step). Otherwise it has no effect on the compiled binary in either size or runtime. OTOH, it's certainly considered bad form to do so, as well as adding anything unnecessary to the code in the file you're working on. At the small scale you're likely to encounter as a student, these are relatively trivial concerns. Once you're coding professionally, you may be working on 1M+ line codebases (such as a robowaifu's), and such faux pas can be a real nuisance. Best to take your instructor's advice in this specific matter Anon. He's just trying to prepare for the real world in this case.
Open file (15.24 KB 292x268 terrydavissmile.jpeg)
>>26366 >Please define 'lying berries' for me a bit clearer, Anon. Sorry, I was just joking around. libraries sounds kind of like "Lying berries" so I thought it was funny. Thanks for clearing that up for me, I just wanted to know if he was right and it turns out it is. Another reason I wanted to do that is because It's sort of like a signature of mine. Like "oh hey look at all these extra libraries added on , this is definitely anon's work. " One of my biggest fears with my programming classes is to get accused of using AI. I know it happened at a university in Texas recently.
>>26369 >Thanks for clearing that up for me Nprb, I'm glad you're asking about such things since it helps clear up misconceptions in the beginner's minds (this is a classroom thread after all heh). For example, most students think that the compiler is somehow involved with the runtime operation of their programs. It isn't. The binary runs without any compiler interaction at all. Stuff like that. >One of my biggest fears with my programming classes is to get accused of using AI. I know it happened at a university in Texas recently. Honestly, that's their problem IMO, not yours. Just find a consistent naming/commenting/formatting style (please use clang-format, kthx) and that should go a long way for you while you're a student. >also, > based schizo pic saved. :^)
Open file (15.36 KB 576x294 2023-11-13_10-48-26.png)
Open file (15.92 KB 591x304 2023-11-13_10-49-09.png)
>>26365 >>26366 One other thing I might add; the reference sites will tell you about which libraries are needed, for which standard C++ facilities you need. For example, here's vector:[1] > #1 and map:[2] > #2 1. https://en.cppreference.com/w/cpp/container/vector 2. https://en.cppreference.com/w/cpp/container/map
>>26392 why arent there just man pages for c++ like with libc
>>26394 nvm saw theres a libstdc++-10-doc package its just not installed by default
>>26394 >why arent there just man pages for c++ like with libc Yeah, it's an issue. Here's a hack: https://github.com/jeaye/stdman
Lecture 11 begins 1
>>26485 This completes our second phase of the class. That's it for this year, Anons! See you in the new year where we'll pick up with PPP2 ch12 & GUIs. :^) Lecture 11 ends 8
>spare reserve
>spare reserve
>spare reserve
A NEW VERSION OF BJARNE STROUSTRUP'S FRESHMAN TEXTBOOK HAS JUST DROPPED! [1] This is really encouraging to me r/n, Anons. It was such a long delay for this update, that I had finally given in and figured that Bjarne was too tired to focus on education for the language any longer thus my own feeble attempts to take up that mantle, such as they are. :^) BUT NO. He fooled me, heh. :D PPP3 is out now (already have my ebook, and the print copy is on the way lol), and there are a couple of big changes: * The book has been cut basically in half! About a dozen PPP2 chapters were removed for this edition, and are now freely available on the book's site for download as .pdf files. * The underlying graphics library is no longer based on FLTK, but on Qt. This is a significant change for those 5 chapters, I expect (I'll let you know). Lots of ppl had trouble getting FLTK working properly on their machines -- and Qt has slick, pre-built installers for many platforms -- so this will likely be a benefit for most Anons learning this most important language to us, through this textbook. SO... Since I was basing this entire class on PPP2, I'll now have to rethink where we're going with it. Very likely I'll lock this thread and the textbook thread permanantly -- and redo the entire thing for PPP3. :^) This will also include the rentry copy of the work. So this means a LOT of additional, new work on my part that I hadn't planned for this year. So, for now, and until further notice, this class is cancelled. I imagine I may be able to pick it back up during the upcoming Winter semester with the new content, but maybe it'll have to be a year from now instead, Lord willing (I currently have a lot on my plate already). Also, I'm not sure how to manage it here on /robowaifu/ now that I myself can't even post files here any longer lol. Maybe we'll put it on Trash instead? Regardless, this is very good news for /robowaifu/ and other Anons. We're going to need probably at least a dozen Anons skilled in programming with C++ here, to pull off our good opensauce robowaifu's 'minds'. Anything that makes learning this powerful systems-programming language easier is quite helpful in this regard. Man, what a great timeline -- this is encouraging! Cheers, /robowaifu/ . :^) --- >" An Introduction to Programming by the Inventor of C++ >Programming: Principles and Practice Using C++, Third Edition, will help anyone who is willing to work hard learn the fundamental principles of programming and develop the practical skills needed for programming in the real world. Previous editions have been used successfully by many thousands of students. This revised and updated edition >Assumes that your aim is to eventually write programs that are good enough for others to use and maintain >Focuses on fundamental concepts and techniques, rather than on obscure language-technical details >Is an introduction to programming in general, including procedural, object-oriented, and generic programming, rather than just an introduction to a programming language >Covers both contemporary high-level techniques and the lower-level techniques needed for efficient use of hardware >Will give you a solid foundation for writing useful, correct, type-safe, maintainable, and efficient code >Is primarily designed for people who have never programmed before, but even seasoned programmers have found previous editions useful as an introduction to more effective concepts and techniques >Covers a wide range of essential concepts, design and programming techniques, language features, and libraries >Uses contemporary C++ (C++20 and C++23) >Covers the design and use of both built-in types and user-defined types, complete with input, output, computation, and simple graphics/GUI >Offers an introduction to the C++ standard library containers and algorithms " --- GET STOKED with me, /robowaifu/ !! TWAGMI :DD --- 1. https://stroustrup.com/programming.html >=== -fmt, prose edit
Edited last time by Chobitsu on 04/28/2024 (Sun) 01:00:32.
>>31023 Maybe this will interest you, maybe not, but it sure looks interesting to me. And so you will at least think about it, "...Written in C for maximal compatibility (C++ compatible)..." Which I know makes you happy. Look at this killer GUI library. It looks great AND it even runs on microcontrollers including the ESP32(which is how I found it) LVGL - Light and Versatile Graphics Library https://github.com/lbcb/LittlevGL Look at the live demos below in a browser. They look really good. Maybe...instead of the huge library they are using in the book you could cut a great deal of effort and time out by using a nice little package. https://lvgl.io/demos This liberty is really impressive, especially that they can fit so much into such a tiny library. Size will be at a premium in waifus. Most of the computing power will be likely sucked up, eventually, by AI routines. It even supports the RTOS that can be used in microcontrollers. Like it or not any sophistication at all in a waifu is more than likely going to have some small RTOS. If only to make things easier to manage all the timing. Here's a cool ESP32 demo https://github.com/lvgl/lv_port_esp32 I wonder, wild ass wondering, if some of the structure of this, since they pack so much into such a small library, could not be repurposed for facial features??? Not that you use this library itself but maybe the structural ideas behind it. I can't remeber where I saw it but there was some graphic with all the various facial emotions displayed by humans and there were not too many. Maybe there could be 10 or 20 and then the rest would be mixes or blends of these basic emotions. Combined with a little slight randomness it could fake real emotion with a tiny library that was fed "emotion state keywords". All the rest would be coordinated at the low level by various muscle actions from the keywords controlled by the library.
>>31046 Really interesting stuff, Grommet. I'll certainly look into this! Cheers. :^)

Report/Delete/Moderation Forms