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: 6711
Joined: Mon May 27, 2013 8:31 am

Re: Complicating code in C#

Post by Henk » Mon Jan 11, 2021 1:48 pm

Missing part. Otherwise you won't understand GenOccupancies method posted above.

Code: Select all

 public class BitSet64
 {
        // least significant bit
        public static UInt64 First(UInt64 bits) 
            => bits & (~bits + 1);

        public static UInt64 Rest(UInt64 bits) 
        {
            var res = bits & (bits - 1);
            Debug.Assert(res == bits - First(bits));
            return res;
         }
}

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

Re: Complicating code in C#

Post by Henk » Mon Jan 11, 2021 3:20 pm

Don't know. If you want to implement 3d Chess then you probably need some kind of a 3d scene viewer.
Can you use winboard for that? Otherwise you need to implement a viewer yourself.

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

Re: Complicating code in C#

Post by Henk » Mon Jan 11, 2021 8:44 pm

All needless complcated. I had better write.

Code: Select all

       public int ComputeHashKey(ulong occupancy, ulong magic, int nBits)
        {
            var ind = occupancy * magic;
            var hashKey = (int)(ind >> (64 - nBits));
            return hashKey;
        }

        public void FillDiagonalMovesHashTable()
        {
            var diagonalOccupancies = GenOccupancies(DiagonalOcc, 0);
            foreach (var occupancy in diagonalOccupancies)
            {
                int index = ComputeHashKey(occupancy, DiagonalMagicNr, NDiagonalBits);
                DiagonalMovesArr[index] = GenerateDiagonalMoves(occupancy);
            }
        }
 
Maybe even possible now to use an other hashfunction. Have not tried yet.

To be continued.

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

Re: Complicating code in C#

Post by Henk » Tue Jan 12, 2021 12:36 pm

O wait hashfunction for move generation must be perfect. That is collision free. So can't use standard hashalgorithms from C# I guess.
Random(seed) also does not generate unique numbers.
seed = diagonal or vertical occupancy(square, position)


Problem is I do have these magic numbers but lost the code that generated them.
So if these magic numbers get accidentally corrupted I can't generate different ones.

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

Re: Complicating code in C#

Post by Henk » Wed Jan 13, 2021 11:06 am

Some people using Microsoft PowerApps or similar.
So trent is low code, configure and using some strange scription language to knit the pieces together?

If so then better copy (modules of) an existing chess engine.

Programming from scratch forbidden for it costs too much (development) time ??

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

Re: Complicating code in C#

Post by Henk » Thu Jan 14, 2021 10:31 am

In C# you can now also put static methods in an interface. Don't know yet what is the advantage.
Makes it more clear. No hidden static methods?

Post Reply