Recent

Recent Posts

Pages: 1 2 [3] 4 5 ... 10
21
Version 7.5E
This has the database, learning & auto-play features enabled (and hopefully debugged).

This is where things start to get interesting. If you enable these three options and give the program a position, it will explore the available moves looking for an advantage or win, and store that information in the database.

I have included a classic 3-king vs 2-king position where black can win but achieving the win is difficult, and a database where the program has explored the position. If you play the position as black with the database enabled, and then with the database disabled, you should be able to see a significant improvement in the standard of play by the program playing white.

The proram has not yet explored the position long enough to discover how to win as black, but I'm planning to do that is next.
22
Debugger / Re: Lazarus caught AV, seems to be related to FpDebug
« Last post by n7800 on Today at 11:05:17 am »
It would be helpful if you provided the commit hash of your trunk.
23
Lazarus / Re: Lazarus Bugfix Release 4.4
« Last post by BlueIcaro on Today at 10:52:47 am »
I was thinking when I meet Lazarus, was in release 0.9.x. I can't imagine the effort that made the Lazarus team, since this days.
Thank you very much!
/BlueIcaro
24
It looks like you're trying to use Delphi code(uses UTF-16 strings) in Lazarus(uses UTF-8 strings).

You could try this modified version:
Code: Pascal  [Select][+][-]
  1. function IsWordChar(ch: WideChar): Boolean;
  2. begin
  3.   // Letters and digits are word characters. Include '_' if you want underscore to count as part of words.
  4.   Result := TCharacter.IsLetterOrDigit(ch) or (ch = '_');
  5. end;
  6.  
  7. function PosWholeWordInsensitive(const Sub, S: unicodestring; StartPos: Integer = 1): Integer;
  8. var
  9.   i, LSub, LStr: Integer;
  10.   Hay, Needle: unicodestring;
  11.   beforeOK, afterOK: Boolean;
  12. begin
  13.   Result := 0;
  14.   if (Sub = '') or (S = '') then Exit;
  15.   if StartPos < 1 then StartPos := 1;
  16.  
  17.   LSub := Length(Sub);
  18.   LStr := Length(S);
  19.   if StartPos > LStr - LSub + 1 then Exit;
  20.  
  21.   // Use Unicode-aware case folding; UpperCase is OK for many RTLs. Replace with proper casefold if available.
  22.   Hay := ToUpper(S);
  23.   Needle := ToUpper(Sub);
  24.  
  25.   i := StartPos;
  26.   while i <= LStr - LSub + 1 do
  27.   begin
  28.     if Copy(Hay, i, LSub) = Needle then
  29.     begin
  30.       // check char before match (if any)
  31.       if i = 1 then
  32.         beforeOK := True
  33.       else
  34.         beforeOK := not IsWordChar(S[i - 1]);
  35.  
  36.       // check char after match (if any)
  37.       if i + LSub - 1 = LStr then
  38.         afterOK := True
  39.       else
  40.         afterOK := not IsWordChar(S[i + LSub]);
  41.  
  42.       if beforeOK and afterOK then
  43.       begin
  44.         Result := i;
  45.         Exit;
  46.       end;
  47.     end;
  48.     Inc(i);
  49.   end;
  50. end;
  51.  
  52. function strSearchReplaceWholeAll(const strText, strToReplace, strReplaceWith : unicodestring) : string;
  53. var
  54.    ps : Integer;
  55.    a : Integer;
  56.    rtn : unicodestring;
  57.    txtBefore, txtAfter : unicodestring;
  58. begin
  59.      rtn := strText;
  60.      if (trim(rtn)<>'') and (trim(strToReplace)<>'') then
  61.      begin
  62.           try
  63.              ps := posWholeWordInsensitive(strToReplace, rtn, ps);
  64.              while ps>0 do
  65.              begin
  66.                  txtBefore := Copy(rtn, 1, ps-1);
  67.                  txtAfter := Copy(rtn, (ps + length(strToReplace)), length(rtn));
  68.  
  69.                  if (rtn[ps-1]=#10) then
  70.                     rtn := #10 + txtBefore + strReplaceWith + txtAfter
  71.                  else if (rtn[ps-1]=#13) then
  72.                       rtn := #13 + txtBefore + strReplaceWith + txtAfter
  73.                  else if (rtn[ps-1]=#13) then
  74.                       rtn := #13 + txtBefore + strReplaceWith + txtAfter
  75.                  else if (rtn[ps-1]=#9) then
  76.                       rtn := #9 + txtBefore + strReplaceWith + txtAfter;
  77.  
  78.  
  79.                  if (rtn[ps+length(strToReplace)]=#10) then
  80.                     rtn := txtBefore + strReplaceWith + #10 + txtAfter
  81.                  else if (rtn[ps+length(strToReplace)]=#13) then
  82.                     rtn := txtBefore + strReplaceWith + #13 + txtAfter
  83.                  else if (rtn[ps+length(strToReplace)]=#9) then
  84.                       rtn := txtBefore + strReplaceWith + #9 + txtAfter
  85.                  else
  86.                      rtn := txtBefore + strReplaceWith + txtAfter;
  87.  
  88.  
  89.                  ps := ps + length(strReplaceWith);
  90.                  ps := posWholeWordInsensitive(strToReplace, rtn, ps);
  91.                  if (ps>=length(rtn)) or (ps<=0) then break;
  92.              end;
  93.           except
  94.                 //
  95.           end;
  96.      end;
  97.      result := string(rtn);
  98. end;
  99.  

But from a performance point of view, this code is a real disaster.
25
Thanks peeps,

I will look into those, I think the biggest thing is that it needs to replace whole words so 'ThisIsAString' replacing with replace would replace say 'This' which is part of the string where as I would only want to replace 'This Is a string', the 'This' in that is what I'd want to replace not the one that is part of the first.

See what I mean, I feel I'm not explaining that well but I can't think of another way of putting it.
26
Very cool! 👍🏻

Option 1 Sounds like the way to go - only remembering the setting in the IDE Options is good enough for me.

Changing it in the Designer view is (probably) often just a temporary change - like when one wants to take a quick look at the non-visual controls.
I typically hide the non visuals right away and only make them visible when needed, but I can imagine others working the other way around (as it is the way it works right now).

2 and 3 are maybe nice to have, but most certainly not needed on my end.
Just my opinion - I'd be super happy with option 1 (as you already implemented) 😊


Excited to go test this! Thank you! And congrats on the 200th merge request! 😊
27
Debugger / Re: Lazarus caught AV, seems to be related to FpDebug
« Last post by ALLIGATOR on Today at 09:58:17 am »
I also have the CPU-View package from Alexander Bagel installed.

I don't know if this could have any effect, because as far as I understand, it is closely integrated.
28
Debugger / Lazarus caught AV, seems to be related to FpDebug
« Last post by ALLIGATOR on Today at 09:55:43 am »
Sorry, I can't repeat it. I tried, but it doesn't work...
But I took a screenshot and saved it, maybe it will give you some ideas.

29
Designer / Re: Feature request: Default hide/show nonvisual components
« Last post by n7800 on Today at 09:42:42 am »
There's a small nuance. The option is now available in the Designer context menu and in the IDE Options dialog. What are the interaction variants?

1. Only the setting in the options dialog is remembered. This is the default state for each new Designer. You can change its state separately via the context menu, and it won't be remembered. This is quite flexible.

2. Changes in the context menu are also remembered. This is much more obvious and familiar to the user, and theoretically, the checkbox in the options might not even be necessary. On the other hand, there can be multiple Designers - switching the state in one won't change the others. This means there can be multiple states, but only the most recent switch is remembered.

3. As in the second case, but switching in any Designer will change all the others. This consistent but it's lacks flexibility.

Personally I don't have a preference. So far, only the first option is technically implemented.
30
Designer / Re: Feature request: Default hide/show nonvisual components
« Last post by n7800 on Today at 09:41:28 am »
I've finished the patch and created a merge request. Let's see what the developers have to say...
Pages: 1 2 [3] 4 5 ... 10

TinyPortal © 2005-2018