Skip to content

Instantly share code, notes, and snippets.

@davghouse
Created February 25, 2018 20:17
Show Gist options
  • Save davghouse/1751dec3c73ebfdc730ae4b5ab6dae6f to your computer and use it in GitHub Desktop.
Save davghouse/1751dec3c73ebfdc730ae4b5ab6dae6f to your computer and use it in GitHub Desktop.
Russian Wordament Solver example
[TestMethod]
public void RussianSolutionExample()
{
// This dictionary is incomplete.
var russianDictionary = new[]
{
"АВТОМОБИЛЬ",
"СОБАКА",
"САМОЛЕТ",
"КОСМОНАВТ",
"МИКРОВОЛНОВЫЙ",
"ГОЛОД",
"СТРАХ",
"ВЗРЫВ",
"ГЕНИЙ"
};
// Use the Russian dictionary instead of the default English dictionary.
Solution.SetDictionary(russianDictionary);
// The tile values are all 1 in this example, but you'd want to use whatever Wordament does.
// Also, I don't know if these tiles are complete/correct. I used the 'Basic Cyrillic alphabet'
// list on Wikipedia: https://en.wikipedia.org/wiki/Cyrillic_script_in_Unicode#Basic_Cyrillic_alphabet
var russianBasicTileValues = new Dictionary<char, int>(new CaseInsensitiveCharEqualityComparer())
{
{ 'А', 1 }, { 'Б', 1 }, { 'В', 1 }, { 'Г', 1 }, { 'Д', 1 }, { 'Е', 1 }, { 'Ж', 1 }, { 'З', 1 },
{ 'И', 1 }, { 'Й', 1 }, { 'К', 1 }, { 'Л', 1 }, { 'М', 1 }, { 'Н', 1 }, { 'О', 1 }, { 'П', 1 },
{ 'Р', 1 }, { 'С', 1 }, { 'Т', 1 }, { 'У', 1 }, { 'Ф', 1 }, { 'Х', 1 }, { 'Ц', 1 }, { 'Ч', 1 },
{ 'Ш', 1 }, { 'Щ', 1 }, { 'Ъ', 1 }, { 'Ы', 1 }, { 'Ь', 1 }, { 'Э', 1 }, { 'Ю', 1 }, { 'Я', 1 }
};
var sampleBoardTileStrings = new[]
{
"А", "В", "Т", "О",
"Г", "Л", "Д", "М",
"О", "О", "Й", "О",
"Ь", "Л", "И", "Б"
};
var board = new Board(
boardHeight: 4,
boardWidth: 4,
tileStringSelector: p => sampleBoardTileStrings[p],
tilePointsSelector: p => null,
// Use the Russian basic tile values instead of the default English basic tile values.
basicTileValues: russianBasicTileValues);
board.GuessTilePoints();
var solution = new Solution(board);
Assert.IsTrue(solution.ContainsWord("АВТОМОБИЛЬ"));
Assert.IsTrue(solution.ContainsWord("ГОЛОД"));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment