Skip to content
Menu
The Lonely Administrator
  • PowerShell Tips & Tricks
  • Books & Training
  • Essential PowerShell Learning Resources
  • Privacy Policy
  • About Me
The Lonely Administrator

PowerShell Left-Center-Right

Posted on April 20, 2020April 9, 2021
LCR

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.

Manage and Report Active Directory, Exchange and Microsoft 365 with
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.

lcr-1

Play continues to loop through each player until only one player remains with chips.

lcr-2

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.


Behind the PowerShell Pipeline

Share this:

  • Click to share on X (Opens in new window) X
  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on Mastodon (Opens in new window) Mastodon
  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on Pocket (Opens in new window) Pocket
  • Click to share on Reddit (Opens in new window) Reddit
  • Click to print (Opens in new window) Print
  • Click to email a link to a friend (Opens in new window) Email

Like this:

Like Loading...

Related

2 thoughts on “PowerShell Left-Center-Right”

  1. Pingback: ICYMI: PowerShell Week of 24-April-2020 | PowerShell.org
  2. Pingback: ICYMI: PowerShell Week of 24-April-2020 – 247 TECH

Comments are closed.

reports

Powered by Buttondown.

Join me on Mastodon

The PowerShell Practice Primer
Learn PowerShell in a Month of Lunches Fourth edition


Get More PowerShell Books

Other Online Content

github



PluralSightAuthor

Active Directory ADSI Automation Backup Books CIM CLI conferences console Friday Fun FridayFun Function functions Get-WMIObject GitHub hashtable HTML Hyper-V Iron Scripter ISE Measure-Object module modules MrRoboto new-object objects Out-Gridview Pipeline PowerShell PowerShell ISE Profile prompt Registry Regular Expressions remoting SAPIEN ScriptBlock Scripting Techmentor Training VBScript WMI WPF Write-Host xml

©2025 The Lonely Administrator | Powered by SuperbThemes!
%d