Complicating code in C#

Discussion of chess software programming and technical issues.

Moderators: hgm, Dann Corbit, Harvey Williamson

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
Henk
Posts: 6819
Joined: Mon May 27, 2013 8:31 am

Re: Complicating code in C#

Post by Henk » Sat Feb 20, 2021 3:17 pm

O no I defined another dirty enum

Code: Select all

 
     enum SlidingType { Straight, Diagonal };

Henk
Posts: 6819
Joined: Mon May 27, 2013 8:31 am

Re: Complicating code in C#

Post by Henk » Wed Feb 24, 2021 12:18 pm

To make ICoordset : IEnumerable<ICoord> I had to implement GetEnumerator for CoordSet64. But looks like it is a main computational bottleneck.

Don't know what to do about it. Make representation a List<ICoord> perhaps instead of a bitboard (uint64) . Doubt if that would make it faster.
For you have intersection and union operation. So maybe a sortedlist<ICoord> I don't know yet.

Code: Select all

      public IEnumerator<ICoord> GetEnumerator()
        {
            var bbIter = new BitboardIterator(bb);
            foreach (var bit in bbIter)
            {
                yield return new BitBoardCoord(bit);  // far too slow
            }
        }
  

Henk
Posts: 6819
Joined: Mon May 27, 2013 8:31 am

Re: Complicating code in C#

Post by Henk » Wed Feb 24, 2021 12:27 pm

O wait maybe it is the Log operation.

Code: Select all

        public BitBoardCoord(ulong bit)
        {
            Index = (int)Math.Log(bit, 2);
        }
   

Henk
Posts: 6819
Joined: Mon May 27, 2013 8:31 am

Re: Complicating code in C#

Post by Henk » Wed Feb 24, 2021 2:39 pm

Another terrible slow operation.

Code: Select all

      public static ulong ConvertToBitBoard(ICoordSet coordSet)
        {
            ulong result = 0;
            foreach (var coord in coordSet)
            {
                var bb = ConvertToBitBoard(coord);
                result |= bb;
            }
            return result;
        }
 
To fix this I have to repair at least 120 compile errors.
Coding horror movie never stops.

By the way argument should have been CoordSet64 and not ICoordSet.
So that will be another gazillion type casting errors.

Henk
Posts: 6819
Joined: Mon May 27, 2013 8:31 am

Re: Complicating code in C#

Post by Henk » Wed Feb 24, 2021 4:45 pm

If ICoordSet: IEnumerable<ICoord> I can use Intersect and Union operation from LinQ.
Problem is that it returns an IEnumerable<ICoord> and not an ICoordSet or a CoordSet64.

So I can expect even more compile errors.

When will it compile? Maybe next week. After that remove run time errors and then find out that movegeneration is another two times lower.

Henk
Posts: 6819
Joined: Mon May 27, 2013 8:31 am

Re: Complicating code in C#

Post by Henk » Thu Feb 25, 2021 12:08 pm

Too optimistic. Appears to be 4 times slower. But quick fixed tedious compile errors.
Maybe not a good idea to use system.Linq for enumerable operations on what was previously bitsets.

O wait I already found it. Can't use linq operations when computing hashkey for an occupancy during movegeneration. So you really have to use | & there instead of union and intersect. So can't use CoordSets there only bitboards (ulong). Or you have to make a fast implementation of union, intersect.

Henk
Posts: 6819
Joined: Mon May 27, 2013 8:31 am

Re: Complicating code in C#

Post by Henk » Sat Feb 27, 2021 9:50 am

Skipper able to play a game now. Last game was 9/2020. Performance not so great.


Henk
Posts: 6819
Joined: Mon May 27, 2013 8:31 am

Re: Complicating code in C#

Post by Henk » Sat Feb 27, 2021 12:02 pm

A file including System.Linq is a warning that implementation might be too slow.

Henk
Posts: 6819
Joined: Mon May 27, 2013 8:31 am

Re: Complicating code in C#

Post by Henk » Sat Feb 27, 2021 4:35 pm

No time to waste

Henk
Posts: 6819
Joined: Mon May 27, 2013 8:31 am

Re: Complicating code in C#

Post by Henk » Thu Mar 04, 2021 9:40 am

I get hardly 30kn/s in search when lucky but I don't count futile moves.
I remember speed used to be 3 times better half year ago.

So maybe time to make some ugly optimizations.

Garbage collection already takes 30% of the time.

Post Reply