Skip to content

Commit

Permalink
Make Console.WriteLine not work in Think()
Browse files Browse the repository at this point in the history
  • Loading branch information
StanislavNikolov committed Aug 9, 2023
1 parent 4027078 commit 7d3846b
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions bot-scaffold/Main.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
MyBot bot = new MyBot();
// Disable console output. Some competitors use stdout for debugging info, which confuses the
// backend.
var nullWriter = new StreamWriter(Stream.Null);
var savedStdoutWriter = Console.Out;
Console.SetOut(nullWriter);

MyBot bot = new MyBot();

while (true)
{
Expand All @@ -17,5 +23,8 @@

// Think and write move to stdout.
ChessChallenge.API.Move move = bot.Think(apiBoard, apiTimer);

Console.SetOut(savedStdoutWriter);
Console.WriteLine($"{move}");
}
Console.SetOut(nullWriter);
}

0 comments on commit 7d3846b

Please sign in to comment.