Search under this category:
NXT Repository/Programming/Math related/
Cosine Approximation Function
Last update: Wednesday, August 2nd, 2006Jeff Owrey explains how to caluclate cosine(x) using NXT-G.
Factorial Function in NXT-G
Last update: Wednesday, August 2nd, 2006Jeff Owrey explains how to calculate factorials in NXT-G.
NXT Life
Last update: Sunday, October 29th, 2006Based on a comment in the nxtasy forums about a version of the Life simulator written in NBC that was unusably slow, I decided to try my hand at writing a speedier version.
The original code is written by forum user bk227865. He kindly shared a copy of his code with me and I started ripping it apart and building it up again. Originally, the program kept an array of bytes with 6400 entries which was used to mark whether a pixel on the screen was a live cell or a dead cell. A faster way to implement Life is to just keep an array of live cell indices. This will generally be a relatively small array which can be used to paint the screen very quickly.
After a generation has been drawn on the screen then a new array is built containing all the live cell indices from the previous generation plus all their neighbors which may become live in the next generation. This next generation array is then processed to count how many live neighbors each cell indice has. I can think of a way to optimize this further to make it even faster at calculating the next generation of live cells, but I’ll leave that as an exercise for the reader for now.
In my version of NXT Life with a glider and a blinker on the screen, like in bk227865’s original code, each generation takes a little less than 0.8 seconds to draw. When the glider intersects the blinker and additional live cells appear in subsequent generations the time it takes to calculate the next generation increases.
The program uses a macro called MakeCellLive to draw the first generation state. If you want to try other Life shapes you can modify this section of the program.
You can get a copy of Life on the NBC Samples page. It’s the first item on the page. I also posted it to the nxtasy forums.
Trigonometric MyBlocks
Last update: Friday, August 11th, 2006Here are several trigonometric MyBlocks by Brian Davis - Cos(), Sin(), Arctan(), Arccos(), Arcsin(). Also included are Sqrt() and Modulo() as needed by these functions.
Any additions/suggestions/comments? Send an email to repository@nxtasy.org.
Search
Categories
Monthly Archives
- July 2008
- June 2008
- May 2008
- April 2008
- March 2008
- February 2008
- January 2008
- December 2007
- November 2007
- October 2007
- September 2007
- August 2007
- July 2007
- June 2007
- May 2007
- April 2007
- March 2007
- February 2007
- January 2007
- December 2006
- November 2006
- October 2006
- September 2006
- August 2006
- July 2006
- June 2006