Normally, I'd leave a post like this for a Friday Fun article. But given the situation these days, I thought some of you might like to start your week off with a little fun. And maybe even learn a little PowerShell along the way.
ManageEngine ADManager Plus - Download Free Trial
Exclusive offer on ADManager Plus for US and UK regions. Claim now!
If your family is anything like mine, you are hopefully spending a little more time with family game night. One of the games we like is LCR, which stands for Left-Center-Right. This is a fun game that requires no strategy or thinking because everything relies on a random roll of 3 dice. You can use regular dice or get a set of specific LCR dice. I bought a game from Amazon.
Each player gets 3 chips. You roll as many dice as you have chips up to 3. Each dice as a single L, C, and R pip which indicate which way to pass one of your chips: Left,Center or Right. The remaining pips are neutral meaning you keep your chips. Play continues until only 1 player has chips remaining. They win and get the pot in the center. See https://www.wikihow.com/Play-LCR for more information.
Anyway, I decided to write a PowerShell version of the game. The game is contained in a single script file that you can find as a gist on Github.
The game needs a minimum of 3 players. Technically, there is no max, but my version limits it to 6.
C:\scripts\lcr.ps1 -playername John,Paul,George,Ringo
The script file uses a PowerShell class to define a player object. Each turn shows the current status and what the player rolled.
Play continues to loop through each player until only one player remains with chips.
I also added a parameter called Autoplay that will automatically loop through the game in 1-second intervals.
I had fun putting this together and spent way more time on it than I should of. Even so, it is far from perfect. In fact, I've left a number of enhancement suggestions if you want to try your hand at extending the code. I hope you have some fun.
2 thoughts on “PowerShell Left-Center-Right”
Comments are closed.