public void VerifyCompression_astrachan_() { var stream = new MemoryStream(); string input = "astrachan_"; var compressor = new StaticHuffman<char>(CharacterFrequencies(input)); // Node ids: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 // Weights: 1 1 1 1 1 1 1 3 2 2 2 3 4 6 10 var state = new TreeState(8, '_', 'c', 'h', 'n', 'r', 's', 't', 'a', 0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 7, 11, 12, 13); compressor.WriteTable(state.WriteSymbol, state.WriteUInt32); state.Final(); var writer = new BitStreamWriter(stream, true); foreach (char ch in input) { compressor.WriteCode(ch, writer.Write); } writer.Flush(); state.Reset(); var decompressor = new StaticHuffman<char>(state.ReadSymbol, state.ReadUInt32); state.Final(); state.Reset(); decompressor.WriteTable(state.WriteSymbol, state.WriteUInt32); state.Final(); stream.Position = 0; var reader = new BitStreamReader(stream, true); foreach (char ch in input) { Assert.AreEqual(ch, decompressor.GetSymbol(reader.ReadBoolean)); } }
/// <summary> /// /// </summary> /// <param name="tree"></param> /// <param name="furtherProcessing"></param> /// <param name="lastState"></param> /// <returns>list of functions and properties</returns> private static List <Tree <string> > PrepocessTree(Tree <string> tree, List <Tree <string> > furtherProcessing = null, TreeState lastState = TreeState.TopLevel) { if (furtherProcessing == null) { furtherProcessing = new List <Tree <string> >(); } TreeState state = TreeState.TopLevel; string line0 = tree[0]?.data ?? tree.First(x => x != null); if (line0 != null) { switch (lastState) { case TreeState.TopLevel: if (ProperContains(line0, "namespace")) { state = TreeState.Namespace; break; } else { goto case TreeState.Namespace; } case TreeState.Namespace: if (ProperContains(line0, "class") || ProperContains(line0, "struct")) { state = TreeState.Type; } break; case TreeState.Type: if (ProperContains(line0, "(")) { state = TreeState.Function; } else { state = TreeState.Property; } break; case TreeState.Function: case TreeState.Property: state = TreeState.Logic; break; case TreeState.Logic: default: break; } } //preprocess switch (state) { case TreeState.Function: case TreeState.Property: //earmark for later de-stacking furtherProcessing.Add(tree); goto case TreeState.Logic; case TreeState.Logic: //tree.Collapse(); return(furtherProcessing); case TreeState.TopLevel: case TreeState.Namespace: case TreeState.Type: default: foreach (Tree <string> child in tree.children) { if (child[0]?.First() != null) //don't process single lines { PrepocessTree(child, furtherProcessing, state); } } break; } return(furtherProcessing); }
void FixedUpdate() { count++; if (beatCount == 2) { if (count == 34) { count = 0; beatCount = 0; } } else { if (count == 33) { count = 0; beatCount++; } } if (state == TreeState.Increasing && count == 0) { int numCorrect = anim.GetInteger("NumCorrect"); anim.SetInteger("NumCorrect", numCorrect + 1); state = TreeState.Dancing; if (numCorrect + 1 == 3) { //GameObject rock = GameObject.Find("Final_Rock"); //rock.GetComponent<FinalRock>().Activate(); GameObject.Find("piano_rock_01").GetComponent <Tablet>().ActivateSlider(); GameObject.Find("guitar_rock_01").GetComponent <Tablet>().ActivateSlider(); GameObject.Find("drum_rock_01").GetComponent <Tablet>().ActivateSlider(); } } if (state == TreeState.Decreasing && count == 0) { int numCorrect = anim.GetInteger("NumCorrect"); if (numCorrect > 0) { anim.SetInteger("NumCorrect", numCorrect - 1); } state = TreeState.Dancing; if (numCorrect - 1 != 3) { //GameObject rock = GameObject.Find("Final_Rock"); //rock.GetComponent<FinalRock>().Activate(); GameObject.Find("piano_rock_01").GetComponent <Tablet>().DeactivateSlider(); GameObject.Find("guitar_rock_01").GetComponent <Tablet>().DeactivateSlider(); GameObject.Find("drum_rock_01").GetComponent <Tablet>().DeactivateSlider(); } } if (glowing) { if (glowVal >= 1.5f) { glowing = false; return; } glowVal += .01f; tree.GetComponent <Renderer>().material.SetColor("_EmissionColor", new Color(1.0f, 1.0f, 1.0f, 1.0f) * glowVal); altar.GetComponent <Renderer>().material.SetColor("_EmissionColor", new Color(1.0f, 1.0f, 1.0f, 1.0f) * glowVal); } }
virtual protected void Update() { switch (state) { case TreeState.InSeed: break; case TreeState.Growing: _timer += Time.deltaTime; graphicalModel.localScale = Vector3.Lerp(startScale, originScale, _timer); if (graphicalModel.localScale == originScale) { state = TreeState.Grown; } break; case TreeState.Grown: break; case TreeState.WaitDomino: if (dominoDelayTime < 0) { _timer = 0; state = TreeState.Falling; } else { dominoDelayTime -= Time.deltaTime; } break; case TreeState.Falling: if (Quaternion.Angle(graphicalModel.rotation, fallingQuat) < 1f) { gameObject.SetActive(false); graphicalModel.rotation = Quaternion.identity; p3Scene.Instance.treesInScene.Remove(this); cell.RemoveTree(); cell.HighLightOn(false); cell.SelectedOn(false); cell.AuraOn(false); ActivateOnFall(choper); if (dealDmg) { var c = cell.Get(fx, fz); if (c != null) { if (c.player != null) { c.player.OnBeingChoped(choper, 0); } } } break; } _timer += Time.deltaTime; graphicalModel.rotation = Quaternion.Lerp(Quaternion.identity, fallingQuat, _timer); break; } }
/// <param name="states"> the two states to compare. </param> /// <returns> oldest (w/ regards to <seealso cref="TreeState.stableGeneration()"/>) <seealso cref="TreeState.isValid() invalid"/> /// <seealso cref="TreeState"/> of the two. If both are invalid then the <seealso cref="Pair.getLeft() first one"/> is returned. </returns> internal static TreeState SelectOldestOrInvalid(Pair <TreeState, TreeState> states) { TreeState newestValidState = SelectNewestValidStateOptionally(states).orElse(states.Right); return(newestValidState == states.Left ? states.Right : states.Left); }
public override void TreeState(Pair <TreeState, TreeState> statePair) { this._treeState = TreeStatePair.SelectNewestValidState(statePair); }
public void ChangeState(string newState) { currentState.Leave(); currentState = states[newState]; currentStateName = newState; currentState.Enter(null); }
/// <summary> /// Called 50 times/second /// starts and stops dances on 90 bpm beats /// At 50 frames per second, one beat == 33.3333 frames /// </summary> void FixedUpdate() { //increment count count++; //if this is the third beat, reset at count == 34 if (beatCount == BEATMAX) { //set count to 0, beatCount to 0 if (count == COUNTMAX + 1) { count = 0; beatCount = 0; } } //otherwise, reset at count == 33 else { //set count to 0, increment beatCount if (count == COUNTMAX) { count = 0; beatCount++; } } //if on an exact beat (count == 0) if (count == 0) { //if waiting to progress dancing if (state == TreeState.Increasing) { //get the current dance number from Animator object and increment (as long as numCorrect < 3) int numCorrect = anim.GetInteger("NumCorrect"); if (numCorrect < MAXCORRECT) { anim.SetInteger("NumCorrect", numCorrect + 1); } //Set state to nothing state = TreeState.Nothing; } //if waiting to regress dancing if (state == TreeState.Decreasing) { //get the current dance number from Animator object and decrement (as long as numCorrect > 0) int numCorrect = anim.GetInteger("NumCorrect"); if (numCorrect > 0) { anim.SetInteger("NumCorrect", numCorrect - 1); } //Set state to nothing state = TreeState.Nothing; } } //If currently increasing the glow of the tree if (glowing) { //stop if glowVal is already at max (1.5f) if (glowVal >= GLOWMAX) { glowing = false; return; } //increase glowVal glowVal += .01f; tree.material.SetColor("_EmissionColor", new Color(1.0f, 1.0f, 1.0f, 1.0f) * glowVal); altar.material.SetColor("_EmissionColor", new Color(1.0f, 1.0f, 1.0f, 1.0f) * glowVal); } }
public Tree(Rectangle position, TreeState state, double scale, Level level) : base(position, true, scale, level) { this.state = state; textures = LoadTextures <TreeState>(0); }
// Use this for initialization void Start() { treeState = TreeState.Null; }
internal abstract void write(Org.Neo4j.Io.pagecache.PageCursor cursor, TreeNode <org.apache.commons.lang3.mutable.MutableLong, org.apache.commons.lang3.mutable.MutableLong> treeNode, Layout <org.apache.commons.lang3.mutable.MutableLong, org.apache.commons.lang3.mutable.MutableLong> layout, TreeState treeState);
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void write(org.neo4j.io.pagecache.PagedFile pagedFile, org.neo4j.io.pagecache.PageCursor cursor, TreeNode<org.apache.commons.lang3.mutable.MutableLong,org.apache.commons.lang3.mutable.MutableLong> node, Layout<org.apache.commons.lang3.mutable.MutableLong,org.apache.commons.lang3.mutable.MutableLong> layout, TreeState checkpointedTreeState, TreeState unstableTreeState) throws java.io.IOException internal virtual void Write(PagedFile pagedFile, PageCursor cursor, TreeNode <MutableLong, MutableLong> node, Layout <MutableLong, MutableLong> layout, TreeState checkpointedTreeState, TreeState unstableTreeState) { Type.write(cursor, node, layout, checkpointedTreeState); foreach (GBPTreeCorruption.PageCorruption <MutableLong, MutableLong> pc in PageCorruptions) { pc.Corrupt(cursor, layout, node, unstableTreeState); } }
public PropertyState(TreeState parent, string ns, string name) : base(parent) { this.ns = ns; this.name = name; }
void Start() { state = TreeState.UP; }
public void ChangeState(string newState, object data) { currentState.Leave(); currentState = states[newState]; currentState.Enter(data); }
// Update is called once per frame void Update() { /* //test if (this.gameObject.transform.position.x < 0) { chopLeft(); chopRight(); } //!test */ if ( state == TreeState.UP && isChoped()) { GameObject.FindGameObjectWithTag("Player").GetComponent<BrothersManager>().treeIsChop(); state = TreeState.CHOPED; calculFallPosition(); remaningSeconde = SecondeAnimation; } if (state == TreeState.CHOPED && remaningSeconde > 0) { rightChop.SetActive(false); leftChop.SetActive(false); remaningSeconde -= Time.deltaTime; fall (); } if (remaningSeconde < 0) { trunk.GetComponent<BoxCollider2D>().enabled = false; if(isShake){ GameObject.FindGameObjectWithTag ("CameraManager").GetComponent<CameraManager> ().setShaking(true,true,0.2f); isShake = false; state=TreeState.ONFLOOR; trunk.GetComponent<SpriteRenderer>().enabled=false; GameObject.FindGameObjectWithTag ("ParallaxManager").GetComponent<parralaxManager> ().isPaused(false); }else{ state = TreeState.FALLEN; } } }
protected virtual void CreateStates() { states = new Dictionary<string, TreeState>(); TreeState inactive = new TreeStateInactive(); TreeState inactiveDead = new TreeStateInactiveDead(); TreeState active = new TreeStateActive(); TreeState eatingMinigameWrangle = new TreeStateEatingMinigameWrangle(); TreeState eatingMinigameMash = new TreeStateEatingMinigameMash(); TreeState eatingMinigameMashInstant = new TreeStateEatingMinigameMashInstant(); TreeState eating = new TreeStateEating(); // Axe man minigame states TreeState axeManMinigameDead = new TreeStateAxeManMinigameDead(); TreeState axeManMinigameWaitForChop = new TreeStateAxeManMinigameWaitForChop(); TreeState axeManMinigameGroan = new TreeStateAxeManMinigameGroan(); TreeState axeManMinigamePanToAxe = new TreeStateAxeManMinigamePanToAxe(); TreeState axeManMinigameWrangleAxe = new TreeStateAxeManMinigameWrangleAxe(); TreeState axeManMinigameGrabAxe = new TreeStateAxeManMinigameGrabAxe(); TreeState axeManMinigameRemoveAxe = new TreeStateAxeManMinigameRemoveAxe(); TreeState axeManMinigameRaiseAxe = new TreeStateAxeManMinigameRaiseAxe(); TreeState axeManMinigameDropAxe = new TreeStateAxeManMinigameDropAxe(); TreeState axeManMinigameLowerToAxeMan = new TreeStateAxeManMinigameLowerToAxeMan(); TreeState axeManMinigameRaiseAxeMan = new TreeStateAxeManMinigameRaiseAxeMan(); TreeState axeManMinigameWrangleAxeMan = new TreeStateAxeManMinigameWrangleAxeMan(); TreeState axeManMinigameMash = new TreeStateAxeManMinigameMash(); TreeState axeManMinigameEatingFirstHalf = new TreeStateAxeManMinigameEatingFirstHalf(); TreeState axeManMinigameEatingLastWords = new TreeStateAxeManMinigameEatingLastWords(); TreeState axeManMinigameEatingLastHalf = new TreeStateAxeManMinigameEatingLastHalf(); states.Add("Inactive", inactive); states.Add("InactiveDead", inactiveDead); states.Add("Active", active); states.Add("EatingMinigameWrangle", eatingMinigameWrangle); states.Add("EatingMinigameMash", eatingMinigameMash); states.Add("EatingMinigameMashInstant", eatingMinigameMashInstant); states.Add("Eating", eating); // Axe man minigame state states.Add("AxeManMinigameDead", axeManMinigameDead); states.Add("AxeManMinigameWaitForChop", axeManMinigameWaitForChop); states.Add("AxeManMinigameGroan", axeManMinigameGroan); states.Add("AxeManMinigamePanToAxe", axeManMinigamePanToAxe); states.Add("AxeManMinigameWrangleAxe", axeManMinigameWrangleAxe); states.Add("AxeManMinigameGrabAxe", axeManMinigameGrabAxe); states.Add("AxeManMinigameRemoveAxe", axeManMinigameRemoveAxe); states.Add("AxeManMinigameRaiseAxe", axeManMinigameRaiseAxe); states.Add("AxeManMinigameDropAxe", axeManMinigameDropAxe); states.Add("AxeManMinigameLowerToAxeMan", axeManMinigameLowerToAxeMan); states.Add("AxeManMinigameRaiseAxeMan", axeManMinigameRaiseAxeMan); states.Add("AxeManMinigameWrangleAxeMan", axeManMinigameWrangleAxeMan); states.Add("AxeManMinigameMash", axeManMinigameMash); states.Add("AxeManMinigameEatingFirstHalf", axeManMinigameEatingFirstHalf); states.Add("AxeManMinigameEatingLastWords", axeManMinigameEatingLastWords); states.Add("AxeManMinigameEatingLastHalf", axeManMinigameEatingLastHalf); foreach (TreeState state in states.Values) state.Tree = this; currentState = (Active) ? states["Active"] : states["Inactive"]; if (Active) MessageCenter.Instance.Broadcast(new CameraChangeFollowedMessage(transform, Vector3.zero)); currentState.Enter(null); }
public void VerifyTable() { string input = "astrachan_"; var compressor = new StaticHuffman<char>(CharacterFrequencies(input)); // Node ids: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 // Weights: 1 1 1 1 1 1 1 3 2 2 2 3 4 6 10 var state = new TreeState(8, '_', 'c', 'h', 'n', 'r', 's', 't', 'a', 0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 7, 11, 12, 13); compressor.WriteTable(state.WriteSymbol, state.WriteUInt32); state.Final(); }
private void Write(PageCursor cursor, TreeState origin) { TreeState.Write(cursor, origin.StableGeneration(), origin.UnstableGeneration(), origin.RootId(), origin.RootGeneration(), origin.LastId(), origin.FreeListWritePageId(), origin.FreeListReadPageId(), origin.FreeListWritePos(), origin.FreeListReadPos(), origin.Clean); }