Design for change, refactoring, SOLID

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

Henk
Posts: 7216
Joined: Mon May 27, 2013 10:31 am

Design for change, refactoring, SOLID

Post by Henk »

Because I don't know what input of a network might be I wrote down:

Code: Select all

public interface INetwork
{
            void SetInput(IInputGenerator input);
}
Maybe this is a bit too much ?
Or maybe IInputReader would be better. For why would it has to generate input if it might already be created.
Or maybe IIterator would be better. For reader would suggest it would read from a persistent resource.


I also defined a GameService. But it's a class which is far too fat. I even doubt if service concept is any good. For it is not specific enough.
Last edited by Henk on Sat Jun 16, 2018 7:53 pm, edited 3 times in total.
Ras
Posts: 2487
Joined: Tue Aug 30, 2016 8:19 pm
Full name: Rasmus Althoff

Re: Design for change, refactoring, SOLID

Post by Ras »

Rasmus Althoff
https://www.ct800.net
Henk
Posts: 7216
Joined: Mon May 27, 2013 10:31 am

Re: Design for change, refactoring, SOLID

Post by Henk »

Maybe it is better to use an existing network. For creating one is too costly. Although selecting the right one can be expensive too.
Henk
Posts: 7216
Joined: Mon May 27, 2013 10:31 am

Re: Design for change, refactoring, SOLID

Post by Henk »

Currently I use this interface but I think it should be a template for now it assumes output is an array of double. But that need not be.

Might also be that at the time I have finished rewriting all my chess software I got so bored or sick of it that I don't want to have to do anything with chess programming again.

Risk of creating something generic is that you may never reuse it.

Code: Select all

 
    public interface INetwork
    {
        string Name
        {
            get;
        }

        IOutput Output
        {
            get;
        }
        
        bool Load();
        void Save();
        void InitWeights(Random r);
        void SetInput(IIterator input);
        void Eval();
        double Train(IOutput output, int maxCycles);
    }

    public interface IOutput
    {
        double this[int i]
        {
            get;
        }

        int Count
        {
            get;
        }
    }