/// <summary> /// Function to remember the previously assigned texture sampler for a given shader and slot index. /// </summary> /// <param name="shaderType">Type of the shader that the texture sampler belongs to.</param> /// <param name="slot">The slot for the texture sampler.</param> protected void RememberTextureSampler(ShaderType shaderType, int slot) { var key = new StateKey(shaderType, slot); switch (shaderType) { case ShaderType.Vertex: _prevSamplers[key] = Graphics.Shaders.VertexShader.TextureSamplers[slot]; break; case ShaderType.Pixel: _prevSamplers[key] = Graphics.Shaders.PixelShader.TextureSamplers[slot]; break; case ShaderType.Geometry: _prevSamplers[key] = Graphics.Shaders.GeometryShader.TextureSamplers[slot]; break; case ShaderType.Compute: _prevSamplers[key] = Graphics.Shaders.ComputeShader.TextureSamplers[slot]; break; case ShaderType.Domain: _prevSamplers[key] = Graphics.Shaders.DomainShader.TextureSamplers[slot]; break; case ShaderType.Hull: _prevSamplers[key] = Graphics.Shaders.HullShader.TextureSamplers[slot]; break; } }
private void NotifyGlobalRemoveStateChanged(StateKey newState) { foreach (TableSettingsItem <TraitItem> item in Data.Where(i => !i.IsHidden)) { item.Data.CanRemove = newState == StateKey.Enable; } }
public SimpleConcreteInputPlayable(StateKey state, Keys key, KeyStateChange callback, EntityType type) { this.state = state; this.key = key; this.callback = callback; this.type = type; }
private Dictionary <StateKey <SymbolId>, int> ComputeGotoLookup(SymbolMetaDictionary symbolMeta, LrItemSetCollection itemSets) { var gotos = new Dictionary <StateKey <SymbolId>, int>(); var itemSetByKernels = itemSets.ToDictionary(s => s.Kernels.ToArray(), s => s, SetEqualityComparer <LrItem> .Default); foreach (var itemSet in itemSets) { foreach (var sym in symbolMeta.Keys) { // Compute dynamic GOTO var gotoClosure = this.Lr1Closure(symbolMeta, new LrItemSet(itemSet .Where(item => (item.Marker < item.Length) && item.Rule.RuleSymbolIds[item.Marker].Equals(sym)) .Select(item => new LrItem(item.Rule, item.Marker + 1, true)))); if (!gotoClosure.Any()) { continue; } var key = new StateKey <SymbolId>(itemSet.Index, sym); if (gotos.ContainsKey(key)) { continue; } // Match the dynamic GOTO to an actual state if (itemSetByKernels.TryGetValue(gotoClosure.Kernels, out var existingGoto)) { gotos.Add(key, existingGoto.Index); } } } return(gotos); }
public LalrTable ComputeTable() { var symbolMeta = new SymbolMetaDictionary(this.symbols); symbolMeta.ComputeFirstFollowsAndNullable(this.Start, this.Eof, this.ProductionRules); var states = this.ComputeItemSets(symbolMeta, out var acceptIndex); var gotoLookup = this.ComputeGotoLookup(symbolMeta, states); var actionTable = new Dictionary <StateKey <SymbolId>, LalrAction>(); foreach (var state in states) { foreach (var sym in this.symbols) { var key = new StateKey <SymbolId>(state.Index, sym.Key); if (sym.Value == SymbolKind.Terminal) { foreach (var item in state) { if ((item.Marker < item.Length) && (item.Rule.RuleSymbolIds[item.Marker] == sym.Key)) { if (gotoLookup.TryGetValue(key, out var gotoState)) { actionTable[key] = new ShiftAction(gotoState); } } else if (item.Length == item.Marker) { if (item.Rule.Index == acceptIndex) { if (sym.Key == this.Eof) { actionTable[key] = new AcceptAction(); } } else if (item.LookaheadIds.Contains(sym.Key) && (item.Rule.ProductionSymbolId != this.Init)) { if (actionTable.TryGetValue(key, out var action)) { // Reduce-reduce conflict - plain LALR parser will fail, GLR parsers will try both rules in parallel actionTable[key] = ((ReduceAction)action).AddProductionRule(item.Rule); } else { actionTable[key] = new ReduceSingleAction(item.Rule); } } } } } else { if (gotoLookup.TryGetValue(key, out var gotoState)) { actionTable[key] = new GotoAction(gotoState); } } } } return(new LalrTable(states.StartState.Index, actionTable, this.ProductionRules)); }
private ConcurrentDictionary <TKey, TValue> GetCache <TKey, TValue>() { return((ConcurrentDictionary <TKey, TValue>)_state.GetOrAdd(StateKey.Create <TKey, TValue>(), k => { return new ConcurrentDictionary <TKey, TValue>(); })); }
/// <summary> /// This method is invoked once a heavy-weight SMPC is finished. /// </summary> /// <param name="stateKey"></param> protected void OnMpcFinish(StateKey stateKey) { // forward either the result or r_g up if I am in the anchor otherwise do nothing var mpcKey = (MpcKey)stateKey; if (mpcKey.GateId == mpcKey.AnchorId) { var myGate = Circuit.FindGate(mpcKey.GateId); var myQuorum = quorumsMap[myGate.QuorumIndex]; Debug.Assert(MpcSessions.ContainsKey(stateKey)); var mpc = MpcSessions[stateKey].Mpc; if (myGate.OutNodes.Count == 0) { // we are at the top gate! forward the result down to all players! throw new NotImplementedException(); } // forward the result up if I am the min player otherwise forward my share of r_g up if (Party.Id == myQuorum.Min()) { RunChildMpc(myGate.OutNodes[0], myGate, mpc.Result); } else { // note that my previous SMPC input is my share of r_g RunChildMpc(myGate.OutNodes[0], myGate, mpc.Input); } } }
public PPtr <MonoBehaviour>[] GetStateBeahviours(int stateMachineIndex, int stateIndex) { if (IsReadStateMachineBehaviourVectorDescription(File.Version)) { int layerIndex = Controller.GetLayerIndexByStateMachineIndex(stateMachineIndex); StateMachineConstant stateMachine = Controller.StateMachineArray[stateMachineIndex].Instance; StateConstant state = stateMachine.StateConstantArray[stateIndex].Instance; uint stateID = state.GetID(File.Version); foreach (KeyValuePair <StateKey, StateRange> pair in StateMachineBehaviourVectorDescription.StateMachineBehaviourRanges) { StateKey key = pair.Key; if (key.LayerIndex == layerIndex && key.StateID == stateID) { StateRange range = pair.Value; PPtr <MonoBehaviour>[] stateMachineBehaviours = new PPtr <MonoBehaviour> [range.Count]; for (int i = 0; i < range.Count; i++) { int index = (int)StateMachineBehaviourVectorDescription.StateMachineBehaviourIndices[range.StartIndex + i]; stateMachineBehaviours[i] = StateMachineBehaviours[index]; } return(stateMachineBehaviours); } } } return(new PPtr <MonoBehaviour> [0]); }
private void NotifyGlobalStateChanged(StateKey newState) { foreach (TableSettingsItem <EventItem> ev in Data.Where(i => !i.IsHidden)) { ev.Data.Enabled = newState == StateKey.Enable; } }
protected override void DrawHeaders(Rect region) { if (SettingsHelper.DrawTableHeader( _addStateHeaderRect, _addStateHeaderInnerRect, _addStateKey == StateKey.Enable ? Widgets.CheckboxOnTex : Widgets.CheckboxOffTex )) { _addStateKey = _addStateKey == StateKey.Enable ? StateKey.Disable : StateKey.Enable; NotifyGlobalAddStateChanged(_addStateKey); } if (SettingsHelper.DrawTableHeader( _removeStateHeaderRect, _removeStateHeaderInnerRect, _removeStateKey == StateKey.Enable ? Widgets.CheckboxOnTex : Widgets.CheckboxOffTex )) { _removeStateKey = _removeStateKey == StateKey.Enable ? StateKey.Disable : StateKey.Enable; NotifyGlobalRemoveStateChanged(_removeStateKey); } if (SettingsHelper.DrawTableHeader(_expandedHeaderRect, _expandedHeaderInnerRect, Textures.Gear)) { _settingsKey = _settingsKey == SettingsKey.Expand ? SettingsKey.Collapse : SettingsKey.Expand; NotifyGlobalSettingsChanged(_settingsKey); } DrawSortableHeaders(); DrawSortableHeaderIcon(); }
public override bool Equals(object o) { if (this == o) { return(true); } if (o == null || GetType() != o.GetType()) { return(false); } StateKey stateKey = (StateKey)o; if (Math.Abs(stateKey.verticalExaggeration - verticalExaggeration) > 0.0000001) { return(false); } if (elevationModel != null ? !elevationModel.Equals(stateKey.elevationModel) : stateKey.elevationModel != null) { return(false); } if (globe != null ? !globe.Equals(stateKey.globe) : stateKey.globe != null) { return(false); } if (_tessellator != null ? !_tessellator.Equals(stateKey._tessellator) : stateKey._tessellator != null) { return(false); } return(true); }
private void NotifyGlobalStateChanged(StateKey newState) { foreach (TableSettingsItem <PawnKindItem> item in Data.Where(i => !i.IsHidden)) { item.Data.Enabled = newState == StateKey.Enable; } }
public SimpleConcreteInputPlayable(StateKey state , Keys key ,KeyStateChange callback , EntityType type ) { this.state = state; this.key = key; this.callback = callback; this.type = type; }
public SimpleConcreteMouseBottomInputPlayable(StateKey sk, EntityType et, MouseButtons mb, MouseStateChangeComplete mst = null, InputMask mask = Input.InputMask.GSYSTEM) { this.sk = sk; this.mb = mb; this.KeyStateChange += mst; this.et = et; this.mask = mask; }
public DkmsProtocol(Circuit circuit, AsyncParty p, IList <int> playerIds, Zp playerInput, int numSlots, StateKey stateKey) : base(p, playerIds, stateKey) { Circuit = circuit; Input = playerInput; Prime = playerInput.Prime; NumSlots = numSlots; }
public DkmsProtocol(Circuit circuit, AsyncParty p, IList<int> playerIds, Zp playerInput, int numSlots, StateKey stateKey) : base(p, playerIds, stateKey) { Circuit = circuit; Input = playerInput; Prime = playerInput.Prime; NumSlots = numSlots; }
public virtual void ChangeState(EventType eventType) { var key = new StateKey(_state, eventType); if (_stateMachine.ContainsKey(key)) { _state = _stateMachine[key]; OnStateChanged?.Invoke(_state); } }
public void Remove(long persistanceDataId, object data) { var key = new StateKey { PersistanceDataId = persistanceDataId, Data = data }; this._storage.TryRemove(key, out var _); }
public IPersistanceData Load(long persistanceDataId, object data) { var key = new StateKey { PersistanceDataId = persistanceDataId, Data = data }; return(_storage.TryGetValue(key, out var item) ? item : null); }
public ByzantineBgwProtocol(AsyncParty e, Circuit circuit, ReadOnlyCollection<int> playerIds, Zp playerInput, StateKey stateKey) : base(e, circuit, playerIds, playerInput, stateKey) { throw new NotImplementedException(); // PolynomialDeg = NumParties % 4 == 0 ? (NumParties / 4 - 1) : (NumParties / 4); // Mahdi: Changed to the following since n/3 - 1 of players can be dishonest. // degree = n - t, where t is the number of dishonest players PolynomialDeg = (int)Math.Floor(2 * NumParties / 3.0); }
public ByzantineBgwProtocol(AsyncParty e, Circuit circuit, ReadOnlyCollection <int> playerIds, Zp playerInput, StateKey stateKey) : base(e, circuit, playerIds, playerInput, stateKey) { throw new NotImplementedException(); // PolynomialDeg = NumParties % 4 == 0 ? (NumParties / 4 - 1) : (NumParties / 4); // Mahdi: Changed to the following since n/3 - 1 of players can be dishonest. // degree = n - t, where t is the number of dishonest players PolynomialDeg = (int)Math.Floor(2 * NumParties / 3.0); }
public AlmostEverywhereProtocol(AsyncParty e, ReadOnlyCollection<int> processorIds, SafeRandom randGen, StateKey stateKey) : base(e, processorIds, stateKey) { if (randGen == null) randUtils = new RandomUtils(); else randUtils = new RandomUtils(randGen); var cStr = ConfigurationManager.AppSettings["SampleListSizeFactor"]; C = cStr == null ? 1 : float.Parse(cStr); }
/// <summary> /// Initializes a new instance of the <see cref="SimpleConcreteKeyboardInputPlayable"/> class. /// For Combo /// </summary> /// <param name="state">The state.</param> /// <param name="key">The key.</param> /// <param name="callback">The callback.</param> /// <param name="mask">The mask.</param> /// <param name="type">The type.</param> public SimpleConcreteKeyboardInputPlayable(StateKey state, Keys[] key, KeyStateChange callback = null, InputMask mask = InputMask.GSYSTEM, EntityType type = Input.EntityType.TOOLS) { this.state = state; this.key = key; if (callback != null) { this.KeyStateChange += callback; } this.type = type; this.mask = mask; }
public void CheckInitNumericKey()//初期値チェック { var state = new StateKey(); var stateLeft = state.GetStateLeft(); var stateRight = state.GetStateRight(); var stateTop = state.GetStateTop(); var stateBottom = state.GetStateBottom(); Assert.AreEqual(stateLeft, 0); Assert.AreEqual(stateRight, 0); Assert.AreEqual(stateTop, 0); Assert.AreEqual(stateBottom, 0); }
public PPtr <MonoBehaviour>[] GetStateBehaviours(int layerIndex) { if (HasStateMachineBehaviourVectorDescription(File.Version)) { uint layerID = Controller.LayerArray[layerIndex].Instance.Binding; StateKey key = new StateKey(layerIndex, layerID); if (StateMachineBehaviourVectorDescription.StateMachineBehaviourRanges.TryGetValue(key, out StateRange range)) { return(GetStateBehaviours(range)); } } return(Array.Empty <PPtr <MonoBehaviour> >()); }
public void Store(IPersistanceData data) { var key = new StateKey { PersistanceDataId = data.PersistanceDataId, Data = data.SomeData }; this._storage.AddOrUpdate(key, data, (k, oldData) => { return(data); }); }
public PPtr <MonoBehaviour>[] GetStateBehaviours(int stateMachineIndex, int stateIndex) { if (HasStateMachineBehaviourVectorDescription(File.Version)) { int layerIndex = Controller.GetLayerIndexByStateMachineIndex(stateMachineIndex); StateMachineConstant stateMachine = Controller.StateMachineArray[stateMachineIndex].Instance; StateConstant state = stateMachine.StateConstantArray[stateIndex].Instance; uint stateID = state.GetID(File.Version); StateKey key = new StateKey(layerIndex, stateID); if (StateMachineBehaviourVectorDescription.StateMachineBehaviourRanges.TryGetValue(key, out StateRange range)) { return(GetStateBehaviours(range)); } } return(Array.Empty <PPtr <MonoBehaviour> >()); }
public BgwProtocol(Circuit circuit, ReadOnlyCollection <int> pIds, AsyncParty e, Zp pInput, SendHandler send, StateKey stateKey) : base(e, pIds, pInput, send, stateKey) { Debug.Assert(circuit.InputCount == pIds.Count); Circuit = circuit; Prime = pInput.Prime; // to get the maximum polynomial degree, we should ask if there is a MUL in the circuit // Mahdi: This is probably valid only when we assume a reliable broadcast channel. //PolynomialDeg = circuit.MultipleContained ? (NumEntities - 1) / 2 : NumEntities - 1; // Mahdi: Changed to the following since n/3 - 1 of players can be dishonest. // degree = n - t, where t is the number of dishonest players PolynomialDeg = (int)Math.Floor(2 * NumParties / 3.0); }
public void GetTest() { var expectedKey = new StateKey("Test"); var stateMock = new Mock <IListState <string> >(); var stateManagerMock = new Mock <IActorStateManager>(); var factoryMock = new Mock <Func <IActorStateManager, IStateKey, IState> >(); factoryMock.Setup(x => x(stateManagerMock.Object, expectedKey)) .Returns <IActorStateManager, IStateKey>((sm, sk) => stateMock.Object) .Verifiable(); var unit = new ActorStateUnit(stateManagerMock.Object, factoryMock.Object); var resultState = unit.Get <IListState <string> >(new StateKey("Test")); Assert.Same(stateMock.Object, resultState); factoryMock.Verify(); }
public IPersistanceData LoadOrCreate(long persistanceDataId, object data) { var key = new StateKey { PersistanceDataId = persistanceDataId, Data = data }; var newData = new PersistanceData { PersistanceDataId = persistanceDataId, SomeData = data }; var item = this._storage.AddOrUpdate(key, newData, (k, oldData) => { return(oldData); }); return(item); }
/// <summary> /// Function to restore a previously remembered texture sampler for a given shader type and slot index. /// </summary> /// <param name="shaderType">The type of shader.</param> /// <param name="slot">The index of the slot used to store the texture sampler.</param> protected void RestoreTextureSampler(ShaderType shaderType, int slot) { GorgonTextureSamplerStates result; var key = new StateKey(shaderType, slot); if (!_prevSamplers.TryGetValue(key, out result)) { return; } switch (shaderType) { case ShaderType.Vertex: Graphics.Shaders.VertexShader.TextureSamplers[slot] = result; break; case ShaderType.Pixel: Graphics.Shaders.PixelShader.TextureSamplers[slot] = result; break; case ShaderType.Geometry: Graphics.Shaders.GeometryShader.TextureSamplers[slot] = result; break; case ShaderType.Compute: Graphics.Shaders.ComputeShader.TextureSamplers[slot] = result; break; case ShaderType.Domain: Graphics.Shaders.DomainShader.TextureSamplers[slot] = result; break; case ShaderType.Hull: Graphics.Shaders.HullShader.TextureSamplers[slot] = result; break; } }
/// <summary> /// This method is invoked once a heavy-weight SMPC is finished. /// </summary> /// <param name="stateKey"></param> protected void OnMpcFinish(StateKey stateKey) { // forward either the result or r_g up if I am in the anchor otherwise do nothing var mpcKey = (MpcKey)stateKey; if (mpcKey.GateId == mpcKey.AnchorId) { var myGate = Circuit.FindGate(mpcKey.GateId); var myQuorum = quorumsMap[myGate.QuorumIndex]; Debug.Assert(MpcSessions.ContainsKey(stateKey)); var mpc = MpcSessions[stateKey].Mpc; if (myGate.OutNodes.Count == 0) // we are at the top gate! forward the result down to all players! throw new NotImplementedException(); // forward the result up if I am the min player otherwise forward my share of r_g up if (Party.Id == myQuorum.Min()) RunChildMpc(myGate.OutNodes[0], myGate, mpc.Result); else // note that my previous SMPC input is my share of r_g RunChildMpc(myGate.OutNodes[0], myGate, mpc.Input); } }
public BgwProtocol(AsyncParty p, Circuit circuit, ReadOnlyCollection <int> playerIds, Zp playerInput, StateKey stateKey) : this(circuit, playerIds, p, playerInput, p.Send, stateKey) { }
public CuckooRule(AsyncParty e, ReadOnlyCollection<int> processorIds, StateKey stateKey) : base(e, processorIds, stateKey) { }
public AlmostEverywhereProtocol(AsyncParty e, ReadOnlyCollection<int> processorIds, StateKey stateKey) : this(e, processorIds, null, stateKey) { }
public CuckooRule(AsyncParty e, ReadOnlyCollection <int> processorIds, StateKey stateKey) : base(e, processorIds, stateKey) { }
public override void Update() { StateKey = Keyboard.GetState(); OldKeyboardState = Keyboard.GetState(); if (StateKey.IsKeyDown(Keys.Up)) { Up = true; Console.WriteLine("Naar bove"); } if (StateKey.IsKeyUp(Keys.Up)) { Up = false; } if (StateKey.IsKeyDown(Keys.Down)) { Console.WriteLine("Naar benede"); Down = true; } if (StateKey.IsKeyUp(Keys.Down)) { Down = false; } if (OldKeyboardState.IsKeyDown(Keys.Up)) { Up = true; Console.WriteLine("Naar bove"); } if (OldKeyboardState.IsKeyUp(Keys.Up)) { Up = false; } if (OldKeyboardState.IsKeyDown(Keys.Down)) { Console.WriteLine("Naar benede"); Down = true; } if (OldKeyboardState.IsKeyUp(Keys.Down)) { Down = false; } if (StateKey.IsKeyDown(Keys.Left)) { Left = true; } if (StateKey.IsKeyUp(Keys.Left)) { Left = false; } if (StateKey.IsKeyDown(Keys.Right)) { Right = true; } if (StateKey.IsKeyUp(Keys.Right)) { Right = false; } if (StateKey.IsKeyDown(Keys.Enter)) { Enter = true; } if (StateKey.IsKeyUp(Keys.Enter)) { Enter = false; } if (StateKey.IsKeyDown(Keys.Space)) { Space = true; } if (StateKey.IsKeyUp(Keys.Space)) { Space = false; } }
/// <summary> /// Initializes a new instance of the <see cref="SimpleConcreteKeyboardInputPlayable"/> class. /// For Combo /// </summary> /// <param name="state">The state.</param> /// <param name="key">The key.</param> /// <param name="callback">The callback.</param> /// <param name="mask">The mask.</param> /// <param name="type">The type.</param> public SimpleConcreteKeyboardInputPlayable(StateKey state, Keys[] key, KeyStateChange callback = null, InputMask mask = InputMask.GSYSTEM, EntityType type = Input.EntityType.TOOLS) { this.state = state; this.key = key; if(callback != null) this.KeyStateChange += callback; this.type = type; this.mask = mask; }