Hiya, how are you all doing? I ask you to observe your explanations as I'm a hobby programmer and knowledge-wise surely cannot be compared with pro developers.
Situation:
I make a console program in .net Core (6 and 7), implementing a small part of the chess UCI protocol. Then compile and via a chess GUI (either Cutechess or Fritz 18 GUI) attach the executable. Sometimes magically it works. Mostly not. However, when I recreate the same project in ramework .net 4.7.2 then it works.
It must be something related to .net.. But I don't have the knowledge to analyze how the GUI interacts with the executable to figure out where it goes wrong. Notice that there's nothing to debug, as it would imply the GUI communicates with the console. It doesn't do that as it never gets that far.
I don't mind help on this at all. It would be horrible if I had to continue my chess programming journey with an older Framework instead of a .net core project. I run Windows 10 and use VS 2022 (Version 17.6.3).
The code below is only to prove that it's not the code causing the problem.
Steps to reproduce:
Install Cutechess gui.
Compile this code in .net core 6 or 7.
In Cutechess, go to tools->settings->engines
Add engine
Try to run a game with "game -> new and select the engine to play with either color"
Error occurs or nothing happens. Or you don't have the choice to select your "engine at all.
Now try the same with .net framework 4.7.2. Works fine. Every time.
using System;
namespace Uci2
{
public class Program
{
private static void Main(string[] args)
{
while (true)
{
string input = ReadInput();
if (input == null)
break;
string[] tokens = input.Trim().Split();
if (tokens.Length == 0)
continue;
switch (tokens[0])
{
case "uci":
Console.WriteLine($"id name ValChess");
Console.WriteLine($"id author Uci2");
Console.WriteLine("uciok");
break;
case "isready":
Console.WriteLine("readyok");
break;
case "position":
break;
case "go":
Console.WriteLine("bestmove e2e4");
break;
case "ucinewgame":
break;
case "stop":
break;
case "quit":
break;
case "setoption":
break;
default:
break;
}
}
}
private static string ReadInput()
{
return Console.ReadLine();
}
}
}