**[Source Code](Program.cs)**
Simon is a pattern memory game. The game will generate a random series of directional inputs, and you try to repeat the pattern. Every time you successfully repeat the pattern, the pattern will grow making it harder to remember. Get the pattern wrong at any time you lose.
The **arrow keys (↑, ↓, ←, →)** are used to repeat the randomized pattern. The **escape** key may be used to close the game at any time. If you **resize** the console widow the game will be closed.
using System.Collections.Generic;
enum Direction { Up = 1, Right = 2, Down = 3, Left = 4, }
static readonly Random random = new Random();
static readonly TimeSpan buttonPress = TimeSpan.FromMilliseconds(500);
static readonly TimeSpan animationDelay = TimeSpan.FromMilliseconds(200);
static readonly List<Direction> pattern = new List<Direction>();
static readonly Dictionary<Direction, string> simonRenders = new Dictionary<Direction, string>()
@" _.-""""""-._" + '\n' +
@" _.-""""""-._" + '\n' +
@" .'█████████`." + '\n' +
@" / '███████' \" + '\n' +
@" _.-""""""-._" + '\n' +
@" | '. .'█████|" + '\n' +
@" | .' '.█████|" + '\n' +
@" _.-""""""-._" + '\n' +
@" \ .███████. /" + '\n' +
@" `.█████████.'" + '\n' +
@" _.-""""""-._" + '\n' +
@" |█████'. .' |" + '\n' +
@" |█████.' '. |" + '\n' +
Console.CursorVisible = false;
Render(simonRenders[default]);
Thread.Sleep(buttonPress);
pattern.Add((Direction)random.Next(1, 5));
for (int i = 0; i < pattern.Count; i++)
switch (Console.ReadKey(true).Key)
if (pattern[i] != Direction.Up) goto GameOver;
case ConsoleKey.RightArrow:
if (pattern[i] != Direction.Right) goto GameOver;
case ConsoleKey.DownArrow:
if (pattern[i] != Direction.Down) goto GameOver;
case ConsoleKey.LeftArrow:
if (pattern[i] != Direction.Left) goto GameOver;
Console.Write("Simon was closed.");
Render(simonRenders[pattern[i]]);
Thread.Sleep(buttonPress);
Render(simonRenders[default]);
Console.Write("Game Over. Score: " + score + ".");
Console.WriteLine("Simon");
static void AnimateCurrentPattern()
for (int i = 0; i < pattern.Count; i++)
Render(simonRenders[pattern[i]]);
Thread.Sleep(buttonPress);
Render(simonRenders[default]);
Thread.Sleep(animationDelay);
Render(simonRenders[default]);
static void Render(string @string, bool renderSpace = true)
int x = Console.CursorLeft;
int y = Console.CursorTop;
foreach (char c in @string)
if (c is '\n') Console.SetCursorPosition(x, ++y);
else if (!(c is ' ') || renderSpace) Console.Write(c);
else Console.SetCursorPosition(Console.CursorLeft + 1, Console.CursorTop);