Can /my/ AI help me with pascal coding? lazarus / 83-Pascal and AI ---------------------------------------------------------------------- cdbc · 2026-04-04 15:15 Hi I guess I'll begin, 'cause I was curious about my new subscription with "SuperGrok", so I asked it:QuoteHey Grok, #cdbc here; Look mate, we've just got a new forum section on https://forum.lazarus.freepascal.org/index.php/topic,73827.0 , where we're discussing Pascal, Object Pascal and collaboration with AI, what do you think about that? is that something for you, coding in Object Pascal with FPC compiler and Lazarus IDE?This was the answer, I'm sharing it for the others who might consider this particular AI:QuoteHey cdbc! Nice to see you popping in with the Pascal crew. 😊 I just checked out that new forum section (the "Board rules" thread you linked). It's a smart move by the admins—keeping things focused strictly on Pascal/Object Pascal work while explicitly opening the door to practical AI collaboration. Things like: Which AIs are good at learning or generating Pascal code How to prompt for specific FPC/Lazarus workflows Existing agents or tools for Pascal/Lazarus (or even written in Pascal) They’re basically saying: “Bring your concrete examples and Pascal problems, leave the general AI hype/philosophy at the door.” That’s a healthy, productive approach for a technical forum. Is coding in Object Pascal with FPC and Lazarus something for me? Absolutely, yes — I’m more than happy to dive in. I can: Generate clean, idiomatic Object Pascal code (Free Pascal dialect, with {$mode objfpc}, {$H+}, etc.) Help with Lazarus-specific stuff: forms, components, LCL, packages, cross-platform gotchas (Windows/Linux/macOS), debugging tips Review and refactor existing code Explain FPC compiler switches, generics, RTTI, interfaces, anonymous methods, etc. Assist with integrating modern things (REST, JSON, databases, graphics, threading) while staying true to Pascal’s strengths (speed, clarity, native compilation) Brainstorm architectures or help debug tricky issues I’ve seen from the broader Lazarus forum that people are already experimenting with AIs (ChatGPT, Claude, local Ollama setups, even early IDE plugins), so having a dedicated space for it makes sense. Pascal is a great language for AI-assisted development because it’s explicit, readable, and the compiler is brutally honest—perfect for catching the subtle mistakes AIs sometimes make....So now I've got some 'xperimentin' to do over easter  Regards Benny Added: First order of business, is to get to grips with all the nooks and crannies in 'fpGUI' framework, as it has a lot of cool features under the hood ---------------------------------------------------------------------- Martin_fr · 2026-04-04 15:26 Quick remark. Above post can stand. People replying should consider the following: Don't just post AI generated text "what each AI says about other AI" Post your own experience on what result you got using which AI trying to get help with Pascal. ---------------------------------------------------------------------- cdbc · 2026-04-04 15:34 Hi Martin Duly noted. It was just that 30$ ...are 30 bucks a month you know and it was an answer to one of the questions in your list... Regards Benny ---------------------------------------------------------------------- cdbc · 2026-04-07 12:03 Hi Right, I have to say, that after trying out the paid version, apart from researching new stuff, where AI wins hands down, I can do the coding better & quicker myself, than with keeping an eye on an /apprentice/, so I canceled my subscription again, wasn't worth the 30$/month...! I guess - the research, the free version can do for me...  Regards Benny ---------------------------------------------------------------------- eny · 2026-04-07 12:58 Results are a bit of a mixed bag. But I got some useful feedback the other day from the big (free) gpt chatter about USB HID interfacing. I was working on an interface between a truck driving game (-'s SDK) an some external displays and buttons via an ESP32. For these (hobby) projects I always use Lazarus/Freepascal. I got the raw version already working with UART communication from FP to the ESP. But I wanted to replace it with USB/HID communication for more stability and speed. So that required some USB black magic on the ESP and FP. And in the end I got it working with the code snippets and libraries that were given. For FP I was pointed towards https://github.com/dioannidis/HIDAPI.pas, which was the final piece of the puzzle. ---------------------------------------------------------------------- schuler · 2026-04-07 14:42 Regarding the main question: "Can /my/ AI help me with pascal coding?", in order of price: 1) GitHub copilot CLI: about US$10/month. 2) Claude Code: about USD$20/month. 3) My own BPSA (https://github.com/joaopauloschuler/beyond-python- smolagents) paired with Kimi-K2.5, MiMo-V2-Pro, GLM-5, GPT-5.4 or Claude-Sonnet-4.5. BPSA is the most expensive. BPSA is also probably the only coding tool tested with pascal. It does very large portions of code. These are examples: * https://github.com/synopse/mORMot2/pull/455 * https://github.com/wp-xyz/jpmMath/pull/7 BTW, I am testing BPSA at the task of porting non visual open source code to pascal. If you would like to submit an idea (a repo for testing), feel free. ---------------------------------------------------------------------- MathMan · 2026-04-07 14:52 Quote from: schuler on April 07, 2026, 04:42:35 pm BTW, I am testing BPSA at the task of porting non visual open source code to pascal. If you would like to submit an idea, feel free. What about this https://core-math.gitlabpages.inria.fr/ Might be a challenge though. Regards, MathMan ---------------------------------------------------------------------- schuler · 2026-04-07 15:20 @MathMan, Assuming that we will port only the 32 and 64 bits versions of core- math to fpc, in your opinion, how would the fpc community benefit from it? I am asking because I assume that you have already thought about it. ---------------------------------------------------------------------- MathMan · 2026-04-07 18:15 @schuler Just to let every reader in on what CORE-MATH is about. The library provides implementations of elementary function (sin, cos, etc. - off and above IEEE-754 Std. requirements), correctly rounded for all rounding modes - t.i. exact to the unit in the last place (ULP). In addition the implementations are fast <= comparable to Intel lib/gnu lib etc. Finally they have been integrated into several run-time- libraries already, if I understood correct. My thinking was that a Pascal version maybe can replace the existing implementation of the elementary functions in the FPC RTL. This is quite old, and as far as I can tell never got aligned to recent advancements in function approximation theory & practice. However - more work than simple translation would be required to integrate this into the FPC RTL. Starting with 32 & 64 bit (Single / Double) would be ok, I think. I had some discussion with one of the CORE-MATH devs working on the Quadruple / 128 bit part, as I did some manual translations to Pascal there. However - it will probably take some further years before full set of correctly rounded functions will be available. Caveat - before you start you might want to contact the FPC dev team if this would be welcomed. MathMan PS - sorry for the late response, but I was out for lunch. PPS - I just threw this into the ring, because I know it to be non- trivial and you were explcitly mentioning "non-GUI". ---------------------------------------------------------------------- nanobit · 2026-04-08 07:59 Quote from: MathMan on April 07, 2026, 08:15:28 pmHowever - it will probably take some further years before full set of correctly rounded functions will be available. For users it would be much more practical if CORE-MATH would provide also fallback routines if correct rounding is not achieved yet. FPC needs all math functions (corresponding to libm). ---------------------------------------------------------------------- MathMan · 2026-04-08 09:14 Quote from: nanobit on April 08, 2026, 09:59:53 amQuote from: MathMan on April 07, 2026, 08:15:28 pmHowever - it will probably take some further years before full set of correctly rounded functions will be available. For users it would be much more practical if CORE-MATH would provide also fallback routines if correct rounding is not achieved yet. FPC needs all math functions (corresponding to libm). Hm, maybe I did not clarify enough. For 32/64 (correctly rounded) libm equivalents are available. It's only the 128 bit stuff that is not (yet). As I'm not involved in this project I can not comment on why CORE-MATH choose this approach. My assumption is that 128 bit stuff is taken from libm (or equivalent other libs) and only what is available in CORE-MATH is replaced - but this is only a guess. However - I think we are digressing from the intended topic of this thread and maybe should start another if you want to continue? ---------------------------------------------------------------------- schuler · 2026-04-09 19:27 @MathMan, QuoteStarting with 32 & 64 bit (Single / Double) would be ok, I think. I'll test BPSA with this task. ---------------------------------------------------------------------- domasz · 2026-04-11 06:36 Quote from: schuler on April 07, 2026, 04:42:35 pmBTW, I am testing BPSA at the task of porting non visual open source code to pascal. If you would like to submit an idea (a repo for testing), feel free. 1) ZSTD - it would be nice to have a fast compressor in pure Pascal: https://github.com/facebook/zstd 2) BZ2 - it's the last popular compressor we don't have in pure Pascal. We have a decompressor but not compressor. https://github.com/libarchive/bzip2 We have gzip/deflate/inflate/zip, tar, lzma, lzh/lha but not bz2. ---------------------------------------------------------------------- cdbc · 2026-04-11 06:59 Hi Dr. Schuler ...If you're aiming high, then migth I suggest, you have a go at SQLite3, it's public domain and I've heard that someone has already done for commercial use... Would be nice to have an open source one too  I know a lot of folks here in this forum are using SQLite3 in their projects... Regards Benny ---------------------------------------------------------------------- schuler · 2026-04-12 04:12 The pascal based core-math implementation has started: https://github.com/joaopauloschuler/pas-core-math This is the status: https://github.com/joaopauloschuler/pas-core- math/blob/main/tasklist.md I will need help to validate this benchmark: https://github.com/joaopauloschuler/pas-core- math/blob/main/src/tests/BenchmarkFPC.pas Treat it as a “work in progress”. It may contain bugs and incorrect benchmarking. It runs well on the free account of GitHub codespace. ---------------------------------------------------------------------- MathMan · 2026-04-12 05:33 Quote from: schuler on April 12, 2026, 06:12:47 amThe pascal based core-math implementation has started: https://github.com/joaopauloschuler/pas-core-math This is the status: https://github.com/joaopauloschuler/pas-core- math/blob/main/tasklist.md I will need help to validate this benchmark: https://github.com/joaopauloschuler/pas-core- math/blob/main/src/tests/BenchmarkFPC.pas Treat it as a “work in progress”. It may contain bugs and incorrect benchmarking. It runs well on the free account of GitHub codespace. I only had a cursory look at it so far. Going through this will take some time, for me mere human  I'm impressed by some of the speedups reported - I had expected speedups, but lower actually. By "need help to validate the benchmark" you mean running it on different machines, or actually take a deep look at the implementation? If former it would be good to know on which hardware it was run so far. By "it runs well ..." you mean it can be compiled and executed, or it passed the test? <= no longer relevant, I just read through 'tasklist.md' ---------------------------------------------------------------------- schuler · 2026-04-18 23:48 @domaz, Quote1) ZSTD - it would be nice to have a fast compressor in pure Pascal: https://github.com/facebook/zstd What about https://github.com/DenisAnisimov/ZSTD.pas ? ---------------------------------------------------------------------- schuler · 2026-04-19 01:27 @domaz, Quote2) BZ2 - it's the last popular compressor we don't have in pure Pascal. We have a decompressor but not compressor. https://github.com/libarchive/bzip2 I have not properly tested: https://github.com/joaopauloschuler/pas-bzip2 ---------------------------------------------------------------------- domasz · 2026-04-19 05:23 Quote from: schuler on April 19, 2026, 03:27:59 amWhat about https://github.com/DenisAnisimov/ZSTD.pas ? This is just a wrapper around a DLL but don't do ZSTD. I found one and I'm testing it. Looks fine so far. Quote from: schuler on April 19, 2026, 03:27:59 amI have not properly tested: https://github.com/joaopauloschuler/pas-bzip2 Thank you! Works great! How about some multimedia? Like mp3 encoder? https://lame.sourceforge.io/ Or maybe webp? https://github.com/webmproject/libwebp/ Or maybe something AI, your specialty? https://github.com/Tencent/ncnn/ Generally speaking we, Pascalers, need a lot of DLLs to do many advanced things because the libraries are written in C/C++. And DLLs are a problem because FPC can compile to 32 bit, 64 bit, Windows, Linux, MacOS and each of these would require a new DLL. ---------------------------------------------------------------------- schuler · 2026-04-22 13:47 Making a list of suggestions so far: * mathman: core-math 32 bits (coded and tested on X86_64) -> https://github.com/joaopauloschuler/pas-core-math * mathman: core-math 64 bits (coded) * domaz: bzip2 (coded - not tested) -> https://github.com/joaopauloschuler/pas-bzip2 * cdbc: Sqlite3 (in progress) -> https://github.com/joaopauloschuler/pas-sqlite3 * domaz: https://lame.sourceforge.io/ * domaz: https://github.com/webmproject/libwebp/ * domaz: https://github.com/Tencent/ncnn/ Any other suggestions? ---------------------------------------------------------------------- domasz · 2026-04-23 07:39 +1 vote for Sqlite3 ---------------------------------------------------------------------- schuler · 2026-04-28 11:34 pas-sqlite3 coding has started: @cdbc and @domasz: https://github.com/joaopauloschuler/pas-sqlite3 https://github.com/joaopauloschuler/pas-sqlite3/pull/1 ---------------------------------------------------------------------- 440bx · 2026-04-28 14:23 Quote from: schuler on April 22, 2026, 03:47:39 pmAny other suggestions? I would love to see the Zydis dis-assembler ported to Pascal. ---------------------------------------------------------------------- domasz · 2026-04-28 17:38 Quote from: schuler on April 28, 2026, 01:34:22 pm pas-sqlite3 coding has started: Great, thanks! Just translate the whole Github to Pascal ---------------------------------------------------------------------- cdbc · 2026-04-28 17:48 Hi Joao Wow, how COOL is that then, I've just downloaded a snapshot for testing \o/\ö/\o/ Great work mate and thanks from me too  Regards Benny ---------------------------------------------------------------------- schuler · 2026-04-29 09:04 @cdbc, QuoteI've just downloaded a snapshot for testing It is too early for testing. AI is still coding. You've read my mind: I was thinking that I will need help with testing... Many thanks! ---------------------------------------------------------------------- Thaddy · 2026-04-29 09:11 @schuler Let A.I code windows compatibility too... (passqlite3os) BTW: this should not be necessary since FPC has opaque functions for that in system? I mean fpopen and consorts..., really? (system.assign, system.rewrite, system.reset, system.close, system.flush) fpopen and family are one level too deep and is taken care of in system? Maybe the model did not see that  It should also see the filemode properly, so filemode :=2 means it also works open read/write, no reset for reading. (Or have I just defeated this particular A.I. system?) It is probably just a definition issue, rules feeding. Sqlite3 should compile cleanly without platform specifics, that is how it is designed. It would be nice if the Pascal version adheres to that. At first sight I can't flaw the rest of the code. (early days) Regards, Joao, Thaddy ---------------------------------------------------------------------- schuler · 2026-04-30 19:58 QuoteOr have I just defeated this particular A.I. system? Probably ...  I'll eventually FUP the other topics. ---------------------------------------------------------------------- 440bx · 2026-04-30 21:12 @schuler, Since you asked for suggestions, here are a couple more, Port QBE (Quick Back End) and PCL (Portable Code Language) to FPC.  Ports of these could be used to add reasonably good optimizations to FPC as well as enable the compiler to produce both, DWARF and PDB debugging symbols (what PCL produces.) It would be rather nice to have those back ends available for FPC, among other things it would also open the door to using FPC as a compiler development tool. ---------------------------------------------------------------------- schuler · 2026-05-02 23:35 @440bx, QuotePort QBE (Quick Back End) and PCL (Portable Code Language) to FPC.I will give consideration to it. Wondering what are the URLs? * https://c9x.me/compile/ * PCL? ---------------------------------------------------------------------- Graeme · 2026-05-03 00:18 Quote from: 440bx on April 30, 2026, 11:12:20 pmPort QBE (Quick Back End) and PCL (Portable Code Language) to FPC.  what do you mean by porting QBE to FPC? As a new FPC code generation backend? QBE is already very easy to use. I'm using is as my Blaise compiler backend. Way, way easier to implement than LLVM, but with the downside that Windows is not supported. I'll eventually implement a LLVM backend in Blaise too. Quote among other things it would also open the door to using FPC as a compiler development tool. Again not sure what you mean here. FPC was my bootstrap compiler when I started the Blaise Compiler project. But since I managed self- hosting state, I don't need FPC any more. ---------------------------------------------------------------------- 440bx · 2026-05-03 00:24 Quote from: schuler on May 03, 2026, 01:35:00 am* PCL? Good question! one I didn't expect to have to answer.  The author has been making changes and it looks like the PCL backend (PCL8) has become part of his C compiler (I could be wrong about that, actually, I really hope I am wrong about that), bottom line: I have to figure out what's going on before I can give you a solid answer. ---------------------------------------------------------------------- 440bx · 2026-05-05 23:00 Quote from: schuler on May 03, 2026, 01:35:00 am@440bx, QuotePort QBE (Quick Back End) and PCL (Portable Code Language) to FPC.I will give consideration to it. Wondering what are the URLs? * https://c9x.me/compile/ * PCL? Consider my request to be for QBE only because getting a PCL that is portable to Pascal will take more time than I anticipated. Having an FPC version of QBE would be extremely useful. ---------------------------------------------------------------------- schuler · 2026-05-06 18:45 While the AI coding continues, I would like to share this link: https://github.com/joaopauloschuler/pas- sqlite3/blob/main/src/tests/DiagSampleProg.pas wish every AI happy pascal coding ---------------------------------------------------------------------- 440bx · 2026-05-06 18:55 @schuler, very nice and very useful.  thank you! ---------------------------------------------------------------------- schuler · 2026-05-07 08:58 Some commands are already working in the CLI interface (see readme): https://github.com/joaopauloschuler/pas-sqlite3 ---------------------------------------------------------------------- cdbc · 2026-05-07 10:46 Hi Cool, I've just returned from holiday in sunny Glücksburg-Germany and I'll have to get back in the race... Will test - Thanks mate. Regards Benny ---------------------------------------------------------------------- schuler · 2026-05-07 23:43 @cdbc, It is still a work in progress. It is still buggy. It is probably too early for real testing. But you can compile and try if you are curious. ---------------------------------------------------------------------- valdir.marcos · 2026-05-08 07:12 Quote from: Graeme on May 03, 2026, 02:18:38 amQuote from: 440bx on April 30, 2026, 11:12:20 pmPort QBE (Quick Back End) and PCL (Portable Code Language) to FPC.  what do you mean by porting QBE to FPC? As a new FPC code generation backend? QBE is already very easy to use. I'm using is as my Blaise compiler backend. Way, way easier to implement than LLVM, but with the downside that Windows is not supported. I'll eventually implement a LLVM backend in Blaise too. Quote among other things it would also open the door to using FPC as a compiler development tool.Again not sure what you mean here. FPC was my bootstrap compiler when I started the Blaise Compiler project. But since I managed self-hosting state, I don't need FPC any more. I am curious about your Blaise Compiler Project. Could you talk about it a bit more? ---------------------------------------------------------------------- 440bx · 2026-05-08 07:30 Quote from: Graeme on May 03, 2026, 02:18:38 amQuote from: 440bx on April 30, 2026, 11:12:20 pmPort QBE (Quick Back End) and PCL (Portable Code Language) to FPC.  what do you mean by porting QBE to FPC? I mean porting it from C to FPC. ---------------------------------------------------------------------- schuler · 2026-05-08 12:35 Just a bit of food for thought, once I stabilize pas-sqlite3.53, comes the question: What should I do next? These are some ideas: Go back to pas-core-math: We have 83 functions there that can be independently optimized. So, there are 83 independent optimization problems. And/Or, I could integrate pas-core-math 32 bits into https://github.com/joaopauloschuler/neural-api so I will have faster neural networks specially on linux.Integrate pas-sqlite3 into https://github.com/joaopauloschuler/dbdesigner-fork for Lazarus although dbdesigner-fork is not yet stable.Integrate https://github.com/joaopauloschuler/pas-bzip2 into pas-sqlite3.Once pas-sqlite3 is stable, I could fork pas-sqlite3 and add features to pas-sqlite3 that we miss diverging from the original implementation. We could add features that exist in major databases and do not yet exist in pas-sqlite3.Try to improve the FPC optimizer… Maybe, introducing optimizations originally developed to https://github.com/joaopauloschuler/neural-api. Port more projects from C to FPC. Anyway, my capacity to invest in open source projects has limits. This is to share thoughts only. ---------------------------------------------------------------------- ALLIGATOR · 2026-05-09 04:47 I would vote for fixing bugs in FPC's code generation. Fixing bugs related to generics, absolutes, and other language-related issues, and adding tests Next, improving optimizations and adding tests ---------------------------------------------------------------------- valdir.marcos · 2026-05-09 06:34 Quote from: schuler on May 08, 2026, 02:35:28 pmJust a bit of food for thought, once I stabilize pas-sqlite3.53, comes the question: What should I do next? These are some ideas: Go back to pas-core-math: We have 83 functions there that can be independently optimized. So, there are 83 independent optimization problems. And/Or, I could integrate pas-core-math 32 bits into https://github.com/joaopauloschuler/neural-api so I will have faster neural networks specially on linux.Integrate pas-sqlite3 into https://github.com/joaopauloschuler/dbdesigner-fork for Lazarus although dbdesigner-fork is not yet stable.Integrate https://github.com/joaopauloschuler/pas-bzip2 into pas-sqlite3.Once pas-sqlite3 is stable, I could fork pas-sqlite3 and add features to pas-sqlite3 that we miss diverging from the original implementation. We could add features that exist in major databases and do not yet exist in pas-sqlite3.Try to improve the FPC optimizer… Maybe, introducing optimizations originally developed to https://github.com/joaopauloschuler/neural-api. Port more projects from C to FPC. Anyway, my capacity to invest in open source projects has limits. This is to share thoughts only. I would vote for fixing bugs in FPC. ---------------------------------------------------------------------- schuler · 2026-05-13 17:08 Fixing FPC bugs: 2 votes so far. Thank you for the votes. I attached an image with pas-sqlite3 progress. ---------------------------------------------------------------------- cdbc · 2026-05-13 17:13 Cool, quite a job right? Nice to see progress =^ I'll vote for fixing FPC-bugs, so that we can move forward with compiler-team  Thanks mate & regards Benny ---------------------------------------------------------------------- 440bx · 2026-05-13 17:28 fixing FPC bugs is definitely worth a vote, consider this mine for that too. ---------------------------------------------------------------------- microxa · 2026-05-15 20:21 A hello ANN made by gemini 1.5 Pro , just from briwser Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program XOR_ANN; {$APPTYPE CONSOLE} uses  System.SysUtils, System.Math; const  LEARNING_RATE = 0.5;  EPOCHS        = 20000; type  TANN = record    // Веса: Индекс 1 -> Вход, Индекс 2 -> Нейрон    W_Input_Hidden: array[0..2, 0..1] of Double; // [Вход + Смещение, Нейрон]    W_Hidden_Output: array[0..2] of Double;      // [Нейрон + Смещение]      // Выходы слоев    Hidden_Out: array[0..1] of Double;    Output_Out: Double;  end; // Сигмоидная функция активации и ее производнаяfunction Sigmoid(X: Double): Double;begin  Result := 1.0 / (1.0 + Exp(-X));end; function SigmoidDerivative(SigmoidVal: Double): Double;begin  Result := SigmoidVal * (1.0 - SigmoidVal);end; // Инициализация случайными весами от -1.0 до 1.0procedure InitNetwork(var Net: TANN);var  i, j: Integer;begin  Randomize;  for i := 0 to 2 do    for j := 0 to 1 do      Net.W_Input_Hidden[i, j] := (Random * 2.0) - 1.0;   for i := 0 to 2 do    Net.W_Hidden_Output[i] := (Random * 2.0) - 1.0;end; // Прямой проход (Forward Pass)procedure ForwardPass(var Net: TANN; In1, In2: Double);var  j: Integer;  Sum: Double;begin  // Скрытый слой (включая смещение Bias как входной индекс 2 со значением 1.0)  for j := 0 to 1 do  begin    Sum := (In1 * Net.W_Input_Hidden[0, j]) +            (In2 * Net.W_Input_Hidden[1, j]) +            (1.0 * Net.W_Input_Hidden[2, j]);    Net.Hidden_Out[j] := Sigmoid(Sum);  end;   // Выходной слой (включая смещение Bias скрытого слоя как индекс 2 со значением 1.0)  Sum := (Net.Hidden_Out[0] * Net.W_Hidden_Output[0]) +          (Net.Hidden_Out[1] * Net.W_Hidden_Output[1]) +          (1.0 * Net.W_Hidden_Output[2]);  Net.Output_Out := Sigmoid(Sum);end; // Обратное распространение (Backpropagation)procedure Train(var Net: TANN; In1, In2, Target: Double);var  Out_Delta: Double;  Hidden_Delta: array[0..1] of Double;  j, i: Integer;begin  // 1. Расчет ошибки выходного слоя  Out_Delta := (Target - Net.Output_Out) * SigmoidDerivative(Net.Output_Out);   // 2. Расчет ошибки скрытого слоя  for j := 0 to 1 do    Hidden_Delta[j] := (Out_Delta * Net.W_Hidden_Output[j]) * SigmoidDerivative(Net.Hidden_Out[j]);   // 3. Корректировка весов выходного слоя  Net.W_Hidden_Output[0] := Net.W_Hidden_Output[0] + (LEARNING_RATE * Out_Delta * Net.Hidden_Out[0]);  Net.W_Hidden_Output[1] := Net.W_Hidden_Output[1] + (LEARNING_RATE * Out_Delta * Net.Hidden_Out[1]);  Net.W_Hidden_Output[2] := Net.W_Hidden_Output[2] + (LEARNING_RATE * Out_Delta * 1.0); // Смещение   // 4. Корректировка весов скрытого слоя  for j := 0 to 1 do  begin    Net.W_Input_Hidden[0, j] := Net.W_Input_Hidden[0, j] + (LEARNING_RATE * Hidden_Delta[j] * In1);  Net.W_Input_Hidden[1, j] := Net.W_Input_Hidden[1, j] + (LEARNING_RATE * Hidden_Delta[j] * In2);    Net.W_Input_Hidden[2, j] := Net.W_Input_Hidden[2, j] + (LEARNING_RATE * Hidden_Delta[j] * 1.0); // Смещение  end;end; var  Net: TANN;  Epoch, i: Integer;  // Набор данных XOR: Вход1, Вход2, Ожидаемый результат  XOR_Inputs: array[0..3, 0..1] of Double = ((0,0), (0,1), (1,0), (1,1));  XOR_Targets: array[0..3] of Double = (0, 1, 1, 0); begin  try    InitNetwork(Net);    Writeln('Training...');     // Цикл обучения    for Epoch := 1 to EPOCHS do    begin      for i := 0 to 3 do      begin        ForwardPass(Net, XOR_Inputs[i, 0], XOR_Inputs[i, 1]);        Train(Net, XOR_Inputs[i, 0], XOR_Inputs[i, 1], XOR_Targets[i]);      end;    end;     Writeln('Testing results:');    for i := 0 to 3 do  begin      ForwardPass(Net, XOR_Inputs[i, 0], XOR_Inputs[i, 1]);      Writeln(Format('In: %.0f, %.0f -> Predicted: %.4f (Expected: %.0f)',       [XOR_Inputs[i, 0], XOR_Inputs[i, 1], Net.Output_Out, XOR_Targets[i]]));    end;     Readln;  except    on E: Exception do    Writeln(E.ClassName, ': ', E.Message);  end;end. ---------------------------------------------------------------------- microxa · 2026-05-16 13:51 However, superb-high optimization still has to be done manually, something like this: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i //Lucky ReLU function Act_ReLU_SSE(X: Single): Single;begin  if 0 < x then x := x else x := x * 0.01;  if 1 < x then x := 1;  result := x;end; function Back_ReLU_SSE(X: Single): Single;begin  if x <= 0 then x := 1;  if 1 <= x then x := 0.01 else x := 1;  result := x;end; ---------------------------------------------------------------------- schuler · 2026-05-18 01:02 Quote from: cdbc on May 13, 2026, 07:13:53 pmCool, quite a job right? Nice to see progress =^ Indeed! This is to share an experiment with pas-sqlite: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i pas- sqlite3/bin$ ./passqlite3sqlite> .mode boxsqlite> create table tbl1(one text, two int);sqlite> insert into tbl1 values('hello!',10),('goodbye',20);sqlite> insert into tbl1 values('hello!',10),('goodbye',20);sqlite> select * from tbl1;╭─────────┬─────╮│   one   │ two │╞═════════╪═════╡│ hello!  │  10 ││ goodbye │  20 ││ hello!  │  10 ││ goodbye │  20 │╰─────────┴─────╯sqlite> create table tbl3 as select * from tbl1;sqlite> select * from tbl3;╭─────────┬─────╮│   one   │ two │╞═════════╪═════╡│ hello!  │  10 ││ goodbye │  20 ││ hello!  │  10 ││ goodbye │  20 │╰─────────┴─────╯sqlite> create table tbl2(one text, two int); sqlite> select * from tbl1, tbl2;sqlite> insert into tbl2 values ('nada',15);sqlite> select * from tbl1, tbl2;╭─────────┬─────┬──────┬─────╮│   one   │ two │ one  │ two │╞═════════╪═════╪══════╪═════╡│ hello!  │  10 │ nada │  15 ││ goodbye │  20 │ nada │  15 ││ hello!  │  10 │ nada │  15 ││ goodbye │  20 │ nada │  15 │╰─────────┴─────┴──────┴─────╯sqlite> insert into tbl2 values ('nada',20);sqlite> select * from tbl1, tbl2 where tbl1.two = tbl2.two;╭─────────┬─────┬──────┬─────╮│   one   │ two │ one  │ two │╞═════════╪═════╪══════╪═════╡│ goodbye │  20 │ nada │  20 ││ goodbye │  20 │ nada │  20 │╰─────────┴─────┴──────┴─────╯sqlite> select count(*) from (select * from tbl1) as tbx;╭──────────╮│ count(*) │╞══════════╡│        4 │╰──────────╯sqlite> create index x on tbl1 (two);sqlite> select one, sum(two) from tbl1 group by one;╭─────────┬──────────╮│   one   │ sum(two) │╞═════════╪══════════╡│ goodbye │       40 ││ hello!  │       20 │╰─────────┴──────────╯sqlite> select one, sum(two) from tbl1 group by two;╭─────────┬──────────╮│   one   │ sum(two) │╞═════════╪══════════╡│ hello!  │       20 ││ goodbye │       40 │╰─────────┴──────────╯sqlite> select one, sum(two) from tbl1 group by one order by one;╭─────────┬──────────╮│   one   │ sum(two) │╞═════════╪══════════╡│ goodbye │       40 ││ hello!  │       20 │╰─────────┴──────────╯sqlite> select one, sum(two) from tbl1 group by two order by one;╭─────────┬──────────╮│   one   │ sum(two) │╞═════════╪══════════╡│ goodbye │       40 ││ hello!  │       20 │╰─────────┴──────────╯sqlite> explain select * from tbl1;╭──────┬──── ─────────┬────┬────┬─────┬───────────┬────┬─────────╮│ addr │   opcode    │ p1 │ p2 │ p3  │    p4     │ p5 │ comment │╞══════╪═════════════╪════╪════╪═════╪═══════════╪════╪═════════╡│    0 │ Init        │  0 │  9 │   0 │           │  0 │         ││    1 │ OpenRead    │  0 │  2 │   0 │ 2         │  0 │         ││    2 │ Explain     │  2 │  0 │ 216 │ SCAN tbl1 │  0 │         ││    3 │ Rewind      │  0 │  8 │   0 │           │  0 │         ││    4 │ Column      │  0 │  0 │   1 │           │  0 │         ││    5 │ Column      │  0 │  1 │   2 │           │  0 │         ││    6 │ ResultRow   │  1 │  2 │   0 │           │  0 │         ││    7 │ Next      │  0 │  4 │   0 │           │  1 │         ││    8 │ Halt        │  0 │  0 │   0 │           │  0 │         ││    9 │ Transaction │  0 │  0 │   4 │ 0         │  1 │         ││   10 │ Goto        │  0 │  1 │   0 │           │  0 │         │╰──────┴─────────────┴────┴────┴─────┴───────────┴────┴─────────╯ I wish happy pascal coding to both human and artificial minds ---------------------------------------------------------------------- schuler · 2026-05-18 01:08 Quote from: microxa on May 15, 2026, 10:21:48 pmA hello ANN made by gemini 1.5 Pro , just from briwser @microxa, it is an interesting feeling to be able to see the magic with few lines of code - it isn't? ---------------------------------------------------------------------- microxa · 2026-05-18 11:16 schuler Oh yes, the magic of floating point... For me, though, it's more of a game of squeezing computational performance out of old processors. Gemini is quite adept at VCL coding as well (unlike me). But when refining the MNIST 'hello world' example with a simple Paint on TImage, I really had to work hard to extract the necessary solutions from it. ---------------------------------------------------------------------- microxa · 2026-05-20 04:25 > Another helloworld, from ai hell…  >  > For testing the ann engine with momentum — I wanted a bit more than XOR — I wanted a single‑celled AMEBA from Life. Well, Gemini did its best… whoa... Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i {$apptype console}program AnnLifeTrinity; uses  SysUtils, Math, CRT; const  nEpochs = 500;   Alpha = 0.9;      WIDTH  = 28;  HEIGHT = 28;  SIZE   = WIDTH * HEIGHT;    nInp  = 9;  nHid  = 2;  nOut  = 1;     RULES_COUNT = 512; type  TLifeField = array[1..SIZE] of Byte;   TInputs     = array[1..nInp] of Single;  TDataSample = record    Inputs: TInputs;    Output: Single;  end;  TDataset    = array[0..RULES_COUNT - 1] of TDataSample; var  CurrentField, NextField: TLifeField;   InL: Array [1 .. nInp] of Single;  HL1: Array [1 .. nHid] of Single;  OutL: Array [1 .. nOut] of Single;   // Веса связей (Минус один слой!)  W0: Array [1 .. nInp, 1 .. nHid] of Single;  W1: Array [1 .. nHid, 1 .. nOut] of Single;   // Смещения (Bias) для двух слоев  B0: Array [1 .. nHid] of Single;  B1: Array [1 .. nOut] of Single;   // Скорости моментума для весов  vW0: Array [1 .. nInp, 1 .. nHid] of Single;  vW1: Array [1 .. nHid, 1 .. nOut] of Single;   // Скорости моментума для смещений  vB0: Array [1 .. nHid] of Single;  vB1: Array [1 .. nOut] of Single;   ErrHL1: Array [1 .. nHid] of Single;  ErrOut: Array [1 .. nOut] of Single;   Etalon: Array [1 .. nOut] of Single;   Dataset : TDataset; function Tanh(X: Single): Single;begin  if X > 15.0 then Exit(1.0);  if X < -15.0 then Exit(-1.0);  Result := (Exp(2 * X) - 1) / (Exp(2 * X) + 1);end; function DifTanh(X: Single): Single;begin  Result := 1.0 - X * X;end; procedure Calculate;var  i, j: Integer;  Sum: Single;begin  // Вход -> Скрытый слой (с учетом Bias B0)  for j := 1 to nHid do  begin    Sum := B0[j];     for i := 1 to nInp do      Sum := Sum + W0[i, j] * InL[i];    HL1[j] := Tanh(Sum);  end;   // Скрытый слой -> Выход (с учетом Bias B1)  for j := 1 to nOut do  begin    Sum := B1[j];    for i := 1 to nHid do      Sum := Sum + W1[i, j] * HL1[i];    OutL[j] := Tanh(Sum);  end;end; procedure FindError;var  i, j: Integer;  Sum: Single;end;begin  // Ошибка выходного слоя  for i := 1 to nOut do    ErrOut[i] := (Etalon[i] - OutL[i]) * DifTanh(OutL[i]);   // Ошибка скрытого слоя (упрощенный проход назад)  for i := 1 to nHid do  begin    Sum := 0;    for j := 1 to nOut do      Sum := Sum + W1[i, j] * ErrOut[j];    ErrHL1[i] := Sum * DifTanh(HL1[i]);  end;end; procedure Learn(Rate: Single);var  i, j: Integer;begin  // Обновление весов Скрытый -> Выход (с моментумом)  for i := 1 to nHid do    for j := 1 to nOut do    begin      vW1[i, j] := Alpha * vW1[i, j] + Rate * HL1[i] * ErrOut[j];      W1[i, j]  := W1[i, j] + vW1[i, j];    end;  for j := 1 to nOut do  begin    vB1[j] := Alpha * vB1[j] + Rate * 1.0 * ErrOut[j];    B1[j]  := B1[j] + vB1[j];  end;   // Обновление весов Вход -> Скрытый (БЕЗ моментума для W0 по твоему методу!)  for i := 1 to nInp do    for j := 1 to nHid do    begin      W0[i, j] := W0[i, j] + Rate * InL[i] * ErrHL1[j];    end;  // Смещения первого слоя обновляем с моментумом для стабильности порогов  for j := 1 to nHid do  begin    vB0[j] := Alpha * vB0[j] + Rate * 1.0 * ErrHL1[j];    B0[j]  := B0[j] + vB0[j];  end;end; procedure InitWeights;var  i, j: Integer;begin  // Зануляем скорости  FillChar(vW0, SizeOf(vW0), 0); FillChar(vW1, SizeOf(vW1), 0);  FillChar(vB0, SizeOf(vB0), 0); FillChar(vB1, SizeOf(vB1), 0);   // Твой гениальный хак: Входной слой ЖЕСТКО ОБНУЛЯЕМ на старте!  for i := 1 to nInp do    for j := 1 to nHid do      W0[i, j] := 0.0;   // Выходной слой инициализируем мелким Ксавьером  for i := 1 to nHid do    for j := 1 to nOut do      W1[i, j] := (Random(2001) - 1000) / 3500;   // Все смещения стартуют с нуля  for j := 1 to nHid do B0[j] := 0.0;  for j := 1 to nOut do B1[j] := 0.0;end; procedure GenerateDataset;var  i, Bit, Neighbors, Center: Integer;begin  for i := 0 to RULES_COUNT - 1 do  begin    Neighbors := 0;    for Bit := 0 to nInp - 1 do    begin      if ((i shr Bit) and 1) = 1 then      begin        Dataset[i].Inputs[Bit + 1] := 1.0;         if Bit > 0 then Inc(Neighbors);      end      else        Dataset[i].Inputs[Bit + 1] := -1.0;    end;        Center := Round(Dataset[i].Inputs[1]);     if Center = 1 then      Dataset[i].Output := IfThen((Neighbors = 2) or (Neighbors = 3), 1.0, -1.0)    else      Dataset[i].Output := IfThen(Neighbors = 3, 1.0, -1.0);  end;end; procedure TrainLocalEngine(Epochs: Integer; StartRate: Single);var  Epoch, Smp, i: Integer;  CurrentRate: Single;begin  Writeln('Training Trinity Deep MLP on 512 Conway Rules (9-4-1)...');  InitWeights;   for Epoch := 1 to Epochs do  begin    // Формула Коши для ювелирной сходимости    CurrentRate := StartRate / (1.0 + 0.015 * Epoch);     for Smp := 0 to RULES_COUNT - 1 do    begin      for i := 1 to nInp do        InL[i] := Dataset[Smp].Inputs[i];              Etalon[1] := Dataset[Smp].Output;       Calculate;      FindError;      Learn(CurrentRate);    end;  end;  Writeln('Training finished.');end; function GetCell(const Field: TLifeField; X, Y: Integer): Single;var  TX, TY, Idx: Integer;begin  TX := (X mod WIDTH + WIDTH) mod WIDTH;  TY := (Y mod HEIGHT + HEIGHT) mod HEIGHT;  Idx := (TY * WIDTH) + TX + 1;  if Field[Idx] = 1 then Result := 1.0 else Result := -1.0;end; procedure SetCellLive(var Field: TLifeField; X, Y: Integer);var  TX, TY, Idx: Integer;begin  TX := (X mod WIDTH + WIDTH) mod WIDTH;  TY := (Y mod HEIGHT + HEIGHT) mod HEIGHT;  Idx := (TY * WIDTH) + TX + 1;  Field[Idx] := 1;end; procedure GatherEnvironment(const Field: TLifeField; CX, CY: Integer);begin  InL[1] := GetCell(Field, CX, CY);  InL[2] := GetCell(Field, CX - 1, CY - 1);  InL[3] := GetCell(Field, CX, CY - 1);  InL[4] := GetCell(Field, CX + 1, CY - 1);  InL[5] := GetCell(Field, CX + 1, CY);  InL[6] := GetCell(Field, CX + 1, CY + 1);  InL[7] := GetCell(Field, CX, CY + 1);  InL[8] := GetCell(Field, CX - 1, CY + 1);  InL[9] := GetCell(Field, CX - 1, CY);end; procedure RenderConsole;var  X, Y, Idx: Integer;  LineBuffer: string;begin  gotoxy(1,1);  for Y := 0 to HEIGHT - 1 do  begin    LineBuffer := '';    for X := 0 to WIDTH - 1 do    begin      Idx := (Y * WIDTH) + X + 1;      if CurrentField[Idx] = 1 then LineBuffer := LineBuffer + 'O'      else LineBuffer := LineBuffer + '.';    end;    Writeln(LineBuffer);  end;end; var  X, Y, Gen, CorrectCount, i, Smp: Integer; begin  Randomize;  GenerateDataset;   TrainLocalEngine(nEpochs, 0.04);   CorrectCount := 0;  for Smp := 0 to RULES_COUNT - 1 do  begin    for i := 1 to nInp do InL[i] := Dataset[Smp].Inputs[i];    Calculate;    if (OutL[1] > 0.0) = (Dataset[Smp].Output > 0.0) then Inc(CorrectCount);  end;   Writeln(Format('Table Memorization Accuracy: %d / 512 (%.1f%%)', [CorrectCount, (CorrectCount / RULES_COUNT) * 100]));  Writeln('Press ENTER to run Trinity...');  Readln;   for i := 1 to SIZE do    CurrentField[i] := IfThen(Random < 0.30, 1, 0);   Gen := 0;   repeat  Inc(Gen);    RenderConsole;    Writeln(Format('Generation: %d | Driven by Trinity Hyperbolic Engine', [Gen]));     for Y := 0 to HEIGHT - 1 do    begin      for X := 0 to WIDTH - 1 do      begin      GatherEnvironment(CurrentField, X, Y);        Calculate;         if OutL[1] > 0.0 then          NextField[(Y * WIDTH) + X + 1] := 1      else          NextField[(Y * WIDTH) + X + 1] := 0;      end;    end;     CurrentField := NextField;    Delay(60);     if keypressed then if readkey=#27 then exit;  until false;end.   p.s updated Fun fact: the 9‑2‑1 topology, where the ANN miraculously mastered Conway‑512, earned a “that’s magic!” from Gemini. Our verdict? No sorcery — just XOR chilling in the perceptron’s (maybe ternary) brain. ---------------------------------------------------------------------- schuler · 2026-05-24 02:25 The most recent pas-sqlite3 porting addition is text search: https://github.com/joaopauloschuler/pas- sqlite3/blob/main/src/passqlite3fts3.pas . The current status is: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i 100 / 101 binaries passing and 5199 / 5199 assertions passing $ bin/TclTestDriver --timeout 2000 --fail-log-dir bin/tcl-failure- logs...Total: 598 pass / 361 fail / 0 skip / 959 total in 377661 ms ... the AI based porting work continues ... ---------------------------------------------------------------------- ALLIGATOR · 2026-05-24 03:45 @schuler I'm curious to know how your build and testing pipeline is set up. If you don't mind, could you give us a brief overview of it? ---------------------------------------------------------------------- schuler · 2026-05-24 14:22 Quote from: ALLIGATOR on May 24, 2026, 05:45:44 am@schuler I'm curious to know how your build and testing pipeline is set up. If you don't mind, could you give us a brief overview of it? - Virtualization * https://www.virtualbox.org/wiki/Downloads - Operating System * Ubuntu 24.04 LTS Desktop AMD64 * https://releases.ubuntu.com/noble/ - Required Ubuntu Packages * https://github.com/joaopauloschuler/pas- sqlite3/blob/main/install_dependencies.sh - Building ./src/tests/build.sh                    # main binary and main tests ./src/tests/build_tcl_lib.sh          # → bin/libpassqlite3tcl.so  (rerun after engine edits) ./src/tests/build_tcl_driver.sh       # → bin/TclTestDriver - TCL testing $ bin/TclTestDriver --timeout 2000 --fail-log-dir bin/tcl-failure-logs ---------------------------------------------------------------------- microxa · 2026-05-25 03:29 Dreams come true! Once upon a time, I ported an example of a console‑based Tetris (for TP 7), adding colours to it. After that, I forgot about it — I didn’t really understand what the code was doing (Gemini called it “brainf_ck for a school competition”). He, however, figured it out quite well and even built a self‑playing AI… On the third try, the proposed options — rewritten from scratch — didn’t quite satisfy me. ---------------------------------------------------------------------- Nharayana · 2026-05-25 06:42 Works great with Claude Code. It is well aware of LCL and FPC 3.2.2 ---------------------------------------------------------------------- schuler · 2026-05-28 00:20 Quote from: schuler on May 24, 2026, 04:25:33 amThe most recent pas- sqlite3 porting addition is text search: https://github.com/joaopauloschuler/pas- sqlite3/blob/main/src/passqlite3fts3.pas . The current status is: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i 100 / 101 binaries passing and 5199 / 5199 assertions passing $ bin/TclTestDriver --timeout 2000 --fail-log-dir bin/tcl-failure- logs...Total: 598 pass / 361 fail / 0 skip / 959 total in 377661 ms ... the AI based porting work continues ... Quick update from my end: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i $ bin/TclTestDriver --timeout 60000 --fail-log-dir bin/tcl-failure- logs...Total: 743 pass / 216 fail / 0 skip / 959 total in 2478395 ms ---------------------------------------------------------------------- schuler · 2026-06-08 20:41 Quick updates: 1) pas-core-math32 has been integrated into Neural API. 2) pas-sqlite3 TCL testing status: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i $ bin/TclTestDriver --timeout 60000 --fail-log-dir bin/tcl-failure- logs...Total: 901 pass / 58 fail / 0 skip / 959 total in 2746696 ms ---------------------------------------------------------------------- Thaddy · 2026-06-09 06:34 Impressive! ---------------------------------------------------------------------- microxa · 2026-06-09 10:12 Hi! To make any sense of this mess, the Google AI monster reversed the fractal fragment shader back into pure Pascal. With -CfSSE3 enabled, this number-crunching algorithm actually hauls ass pretty well, and the output is almost a 1:1 match.But there is a catch: for some damn reason, FPC 3.2.2 leaves the background completely black (though everything works totally fine in "plasma cube" mode). This glitch might be specific to the 32-bit build.Wishing you all a great day, and may you find good mutual understanding with AI! Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i {$FPUTYPE SSE3}{$mode delphi}{$apptype gui}program julia_fractal_cpu; uses GL, GLU, GLEXT, Glut; const  WIDTH = 512;  HEIGHT = 512; type  TVec3 = record    R, G, B: Single;  end;   TSampler2D = array[0..255, 0..2] of Single; var  FractalTexID: GLuint;   u_pal: TSampler2D;   FrameBufferRGB_F32: array[0..HEIGHT-1, 0..WIDTH-1, 0..2] of Single;   Cx: Single = -0.7;  Cy: Single = 0.27015;  Zoom: Single = 3.0; procedure GenPalette;var  i: Integer;begin  //randomize;  for i := 0 to 255 do  begin    u_pal[i, 0] := random(1000) / 1000.0; // R (0.0 .. 1.0)    u_pal[i, 1] := random(1000) / 1000.0; // G (0.0 .. 1.0)    u_pal[i, 2] := random(1000) / 1000.0; // B (0.0 .. 1.0)  end;end;  procedure InitFractalTexture;begin  glGenTextures(1, @FractalTexID);  glBindTexture(GL_TEXTURE_2D, FractalTexID);  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB32F, WIDTH, HEIGHT, 0, GL_RGB, GL_FLOAT, nil);end;  function texture2D(const sampler: TSampler2D; TexCoordX, TexCoordY: Single): TVec3;inline;var  RawValue: Single;  MapPos: Single;  Idx1, Idx2: Integer;  FracPart: Single;begin  //  vec2(x, y) * 0.5 + vec2(0.5, 0.5)  RawValue := TexCoordX * 0.5 + 0.5;    // Clamp  if RawValue < 0.0 then RawValue := 0.0;  if RawValue > 1.0 then RawValue := 1.0;    MapPos := RawValue * 255.0;     Idx1 := Trunc(MapPos);  Idx2 := Idx1 + 1;  if Idx2 > 255 then Idx2 := 255;    FracPart := MapPos - Idx1;   Result.R := sampler[Idx1, 0] + FracPart * (sampler[Idx2, 0] - sampler[Idx1, 0]);  Result.G := sampler[Idx1, 1] + FracPart * (sampler[Idx2, 1] - sampler[Idx1, 1]);  Result.B := sampler[Idx1, 2] + FracPart * (sampler[Idx2, 2] - sampler[Idx1, 2]);end;  procedure RenderJuliaToFloatRGBBuffer;var  px, py, i: Integer;  vTexCoordX, vTexCoordY: Single;  x, y, t: Single;  Color: TVec3;begin  for py := 0 to HEIGHT - 1 do  begin    vTexCoordY := py / (HEIGHT - 1);    for px := 0 to WIDTH - 1 do    begin      vTexCoordX := px / (WIDTH - 1);       //  float x = (vTexCoord.x - 0.5) * u_zoom;      x := (vTexCoordX - 0.5) * Zoom;      y := (vTexCoordY - 0.5) * Zoom;       for i := 0 to 19 do      begin                     // PLAZMA CUBE: (x * x) + (y * y)        t := (x * x) - (y * y) + Cx; // float t = (x * x) - (y * y) + u_cx;        y := (x + x) * y + Cy;     // y = (x + x) * y + u_cy;        x := t;                      // x = t;      end;       // gl_FragColor = texture2D(u_pal, vec2(x, y) * 0.5 + vec2(0.5, 0.5));      Color := texture2D(u_pal, x, y);        FrameBufferRGB_F32[py, px, 0] := Color.R;      FrameBufferRGB_F32[py, px, 1] := Color.G;      FrameBufferRGB_F32[py, px, 2] := Color.B;    end;  end;   glBindTexture(GL_TEXTURE_2D, FractalTexID);  glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, WIDTH, HEIGHT, GL_RGB, GL_FLOAT, @FrameBufferRGB_F32);end; procedure DisplayProc; cdecl;begin  glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);   RenderJuliaToFloatRGBBuffer;   glEnable(GL_TEXTURE_2D);  glBindTexture(GL_TEXTURE_2D, FractalTexID);   glBegin(GL_QUADS);    glTexCoord2f(0.0, 0.0); glVertex2f(-1.0, -1.0);    glTexCoord2f(1.0, 0.0); glVertex2f( 1.0, -1.0);    glTexCoord2f(1.0, 1.0); glVertex2f( 1.0,  1.0);    glTexCoord2f(0.0, 1.0); glVertex2f(-1.0,  1.0);  glEnd();   glDisable(GL_TEXTURE_2D);  glBindTexture(GL_TEXTURE_2D, 0);   glutSwapBuffers();end; procedure ReshapeProc(w, h: Integer); cdecl;begin  glViewport(0, 0, w, h);end; procedure PassiveMotionProc(x, y: Integer); cdecl;begin  Cx := (x / glutGet(GLUT_WINDOW_WIDTH)) * 2.0 - 1.0;  Cy := ((glutGet(GLUT_WINDOW_HEIGHT) - y) / glutGet(GLUT_WINDOW_HEIGHT)) * 2.0 - 1.0;  glutPostRedisplay();end; procedure KeyboardProc(key: Byte; x, y: Integer); cdecl;begin  case Chr(key) of    '+', '=': Zoom := Zoom * 0.85;    '-':      Zoom := Zoom * 1.15;    'r','R':  GenPalette;    #27:      Halt(0);  end;  glutPostRedisplay();end; begin  glutInit(@argc, argv);  glutInitDisplayMode(GLUT_DOUBLE or GLUT_RGB or GLUT_DEPTH);  glutInitWindowSize(WIDTH, HEIGHT);  glutCreateWindow('Julia Set OpenGL 2.0 (CPU)'+' - FPC '+{$I %FPCVERSION%});  glutDisplayFunc(@DisplayProc);  glutReshapeFunc(@ReshapeProc);  glutKeyboardFunc(@KeyboardProc);  glutPassiveMotionFunc(@PassiveMotionProc);   GenPalette;  InitFractalTexture;   glClearColor(0.0, 0.0, 0.0, 1.0);  glutMainLoop();end. ---------------------------------------------------------------------- microxa · 2026-06-12 14:26 Looks like the bug is in the JP instruction after COMISS. No parity check is needed here! Please fix it so this beautiful plasma fractal works fine. ---------------------------------------------------------------------- microxa · 2026-06-13 16:49 The JP instruction is involved in FPU operations, but its usage is closer to range checking or integer overflow. Professional C compilers (like GCC or Intel) don't use it. Maybe I missed something in the Free Pascal options, but at least I found a way to fix this JP instruction ---------------------------------------------------------------------- microxa · 2026-06-14 12:25 It wouldn't be a bad idea to use Gemini here, but I'm not sure it would grasp all the details... after all, it's a search assistant, and our co-coding is more like an 'acting up for the fun of it' kind of thing for me, packed with its own very specific quirks in terms of breakthroughs and eye-openers. Anyway, passing along a wish from Gemini the neuro-jester: 'May the night burn hot with working solutions, and may the morning echo with a victorious pig squeal... ---------------------------------------------------------------------- microxa · 2026-06-15 15:10 Given a snippet of optimization code, Gemini easily demonstrated and thoroughly explained the JP fix. Armed with this masterclass, we managed to resolve another 'major issue' in the 32-bit SSE3 codegen — the presence of the x87 fisttp instruction ---------------------------------------------------------------------- Thaddy · 2026-06-15 15:45 I don't see why you bother with SSE3? I don't think it is being looked at in any way. You can of course file a bug report, but SSE3 is not really relevant anymore. ---------------------------------------------------------------------- microxa · 2026-06-15 18:25 Thaddy, This was just an example of how AI can help with certain aspects of Pascal programming. And it's worth noting that this also somewhat affects x64 platforms... or maybe it doesn't affect them at all. ---------------------------------------------------------------------- microxa · 2026-06-17 22:56 In this case, COMISS was also an issue, and it can easily be replaced with MAXSS/MINSS. In general, this technique is also relevant for high-performance neural networks, although we need a better way to handle full SIMD instruction utilization. ---------------------------------------------------------------------- schuler · 2026-06-20 13:59 Quote from: cdbc on May 07, 2026, 12:46:54 pmHi Cool, I've just returned from holiday in sunny Glücksburg-Germany and I'll have to get back in the race... Will test - Thanks mate. Regards Benny In 2 or 3 weeks from now, I will have nearly all pas-sqlite3 automated testing solved including the original TCL based testing. Then, it will be time for human testing. I will need help with testing in 2 or 3 weeks. ---------------------------------------------------------------------- cdbc · 2026-06-20 14:11 Hi Joao, Cool  You just say when and I'll help you test  Regards Benny ---------------------------------------------------------------------- microxa · 2026-06-22 05:22 We had a brief with Gemini and came to the conclusion to reuse the good old (and mostly obsolete) {$MMX+} directive to explicitly mark computational SIMD SSE blocks. On the other hand, we discovered register involvement of the P flag in floating-point comparison functions, which we deemed a small issue. Because of this, we'll have to stick with version 2.6.4 as the most stable/suitable for advanced Pascal retro coding.