private bool TryGetEnumSymbol(string name, out EnumSymbol symbol) { Contracts.AssertValue(name); symbol = EnumSymbols.Where(symbol => symbol.Name == name).FirstOrDefault(); return(symbol != null); }
public LearnPlayer(EnumSymbol _symbol, double _epsilon = 0.1, double _alpha = 0.3, double _gamma = 0.9) : base(_symbol) { qTable = new Dictionary <StateActionTuple <string, int>, double>(); Epsilon = _epsilon; alpha = _alpha; gamma = _gamma; lastState = null; lastAction = -1; random = new Random((int)DateTime.Now.Ticks); }
public bool IsPlayerWinner(EnumSymbol _symbol) { bool isWin = false; foreach (var winState in winStates) { bool winner = true; foreach (var index in winState) { if (BoardState[index] != (char)_symbol) { winner = false; } } if (winner) { isWin = true; break; } } return(isWin); }
protected AbstractPlayer(EnumSymbol _symbol) { Symbol = _symbol; }
public void PlayStroke(int _stroke, EnumSymbol _symbol) { BoardState[_stroke] = (char)_symbol; }
static void CollectEnumData(ref List <ReCTEnum> enums, ref List <ReCTGlobal> globals, EnumSymbol enm) { var _enum = new ReCTEnum(); _enum.Name = enm.Name; List <ReCTGlobal> properties = new List <ReCTGlobal>(); foreach (KeyValuePair <string, int> val in enm.Values) { properties.Add(new ReCTGlobal() { Name = val.Key, Datatype = "int" }); } _enum.Properties = properties.ToArray(); enums.Add(_enum); }
public EnumerationConstantAstNode(EnumSymbol value, int line, int column) : base(line, column) { Value = value; }
public RandomPlayer(EnumSymbol _symbol) : base(_symbol) { random = new Random((int)DateTime.Now.Ticks); }
/// <summary> /// Adds suggestions for an enum, with an optional prefix. /// </summary> /// <param name="intellisenseData"></param> /// <param name="enumInfo"></param> /// <param name="prefix"></param> internal static void AddSuggestionsForEnum(IntellisenseData.IntellisenseData intellisenseData, EnumSymbol enumInfo, string prefix = "") { Contracts.AssertValue(intellisenseData); Contracts.AssertValue(enumInfo); Contracts.AssertValue(prefix); bool anyCollisionExists = false; var locNameTypePairs = new List <Tuple <String, DType> >(); // We do not need to get the localized names since GetNames will only return invariant. // Instead, we use the invariant names later with the enumInfo to retrieve the localized name. foreach (var typedName in enumInfo.EnumType.GetNames(DPath.Root)) { string locName; enumInfo.TryGetLocValueName(typedName.Name.Value, out locName).Verify(); string escapedLocName = TexlLexer.EscapeName(locName); var collisionExists = intellisenseData.DoesNameCollide(locName); if (collisionExists) { string candidate = prefix + escapedLocName; bool canAddSuggestion = _addSuggestionDryRunHelper.AddSuggestion(intellisenseData, candidate, SuggestionKind.Global, SuggestionIconKind.Other, typedName.Type, false); anyCollisionExists = anyCollisionExists || canAddSuggestion; } locNameTypePairs.Add(new Tuple <String, DType>(escapedLocName, typedName.Type)); } foreach (var locNameTypePair in locNameTypePairs) { string suggestion = anyCollisionExists || !intellisenseData.SuggestUnqualifiedEnums ? prefix + locNameTypePair.Item1 : locNameTypePair.Item1; AddSuggestion(intellisenseData, suggestion, SuggestionKind.Global, SuggestionIconKind.Other, locNameTypePair.Item2, false); } }
public HumanPlayer(EnumSymbol _symbol, int _column, int _row) : base(_symbol) { column = _column - 1; row = _row - 1; }
/// <summary> /// Retrieves an <see cref="EnumSymbol"/> from <see cref="binding"/> (if necessary) /// </summary> /// <param name="name"> /// Name of the enum symbol for which to look /// </param> /// <param name="binding"> /// Binding in which may be looked for the enum symbol /// </param> /// <param name="enumSymbol"> /// Should be set to the symbol for <see cref="name"/> if it is found, and left null otherwise. /// </param> /// <returns> /// True if the enum symbol was found, false otherwise. /// </returns> internal virtual bool TryGetEnumSymbol(string name, TexlBinding binding, out EnumSymbol enumSymbol) => TryGetEnumSymbol(name, out enumSymbol);
public bool TryDeclareEnum(EnumSymbol _enum) => TryDeclareSymbol(_enum);
private static bool TryGetEnumInfo(IntellisenseData.IntellisenseData data, TexlNode node, TexlBinding binding, out EnumSymbol enumSymbol) { Contracts.AssertValue(node); Contracts.AssertValue(binding); FirstNameNode curNode = node.AsFirstName(); if (curNode == null) { enumSymbol = null; return(false); } FirstNameInfo firstNameInfo = binding.GetInfo(curNode).VerifyValue(); if (firstNameInfo.Kind != BindKind.Enum) { enumSymbol = null; return(false); } return(data.TryGetEnumSymbol(firstNameInfo.Name, binding, out enumSymbol)); }