Open SteveL-MSFT opened 1 month ago
Hi Steve. Thanks for your feedback! I will certainly have a look at your suggestions. The colors are a must-have though, so it's probably going to take some creative thinking to keep those in there. Will let you know if/when I get it working. Thanks again.
my idea to optimize the rendering would be to make use of an index array for the game board, instead of re-drawing all. like I've done it in: https://github.com/HCRitter/PSFunctions/blob/main/Start-MultiJob.ps1
for example:
$host.UI.RawUI.CursorPosition = @{ X = 0; Y = $Changingline }
$ChangingLine= $Changeingline.replace('X','Y')
Write-Host $changingline
Interesting, never even considered that. Back to the drawing board!
Saw your community demo on this. Thought it was great. However, I did notice that the drawing aspect was not fast. Looking at your code, I think one optimization you should make is instead of writing each cell with
Write-Host
, write it to a string and then render it to the console all at once. Would suggest using aStringBuilder
to construct the output and then a singleWrite-Host
at the end. The only "challenge" I see is color output which you rely on withWrite-Host
. Instead, you'd have to use VT escape sequences. The easiest way is to use$PSStyle
, but if you need it to work on Windows PowerShell 5.1, you could use$PSStyle
on PowerShell 7 just to get the VT escape sequence to use with Windows PowerShell 5.1.