dev:questions_ulam
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
dev:questions_ulam [2015/05/30 19:26] – [Q: Some tips about MFM simulator?] xychen | dev:questions_ulam [2015/06/01 18:11] (current) – [Q: Do smaller grid geometries make the simulator run faster?] xychen | ||
---|---|---|---|
Line 3: | Line 3: | ||
What is the range for an '' | What is the range for an '' | ||
- | A: To understand the range of an Unary number, we first have to know how it is represented. An Unary(n) number takes n bits. It represents an integer of the number of 1's in it. For example | + | **A:** To understand the range of an Unary number, we first have to know how it is represented. An Unary(n) number takes n bits. It represents an integer of the number of 1's in it. For example |
'' | '' | ||
Line 27: | Line 27: | ||
==== Q: More about the bits in Unary ==== | ==== Q: More about the bits in Unary ==== | ||
If the value of an myUnary5 is '' | If the value of an myUnary5 is '' | ||
+ | |||
+ | **A: 30-May-2015 02: | ||
===== Week Two ===== | ===== Week Two ===== | ||
Line 140: | Line 142: | ||
because that particular '' | because that particular '' | ||
- | **Thank you professor**! Now I understand that '' | + | ==== Q: Does ws.getPick(typeIndex) only return one site? How to access each site within an event window? ==== |
+ | **Thank you**! Now I understand that '' | ||
+ | |||
+ | **A: 31-May-2015 12: | ||
+ | |||
+ | But even when you do need to loop, we have '' | ||
+ | |||
+ | <code - SSDemo1.ulam> | ||
+ | |||
+ | /** | ||
+ | | ||
+ | */ | ||
+ | |||
+ | element SSDemo1 { | ||
+ | // Typedefs | ||
+ | typedef Unsigned(8) Score; | ||
+ | |||
+ | // Utilities | ||
+ | EventWindow ew; | ||
+ | Random random; | ||
+ | DebugUtils du; | ||
+ | |||
+ | // Data members | ||
+ | Score val; | ||
+ | |||
+ | Void behave() { | ||
+ | if (val == 0) // randomize initial vals | ||
+ | val = random.bits(val.sizeof); | ||
+ | |||
+ | WindowServices ws; // Scanning support | ||
+ | SelectorServices ss; // Selection support | ||
+ | |||
+ | ws.reset(1, | ||
+ | ss.reset(); | ||
+ | |||
+ | for (Int idx = ws.next(); idx >= 0; idx = ws.next()) { | ||
+ | Atom a = ew[idx]; | ||
+ | if (a as SSDemo1) | ||
+ | ss.maximize(idx, | ||
+ | } | ||
+ | // This code is fairly general, but cumbersome. | ||
+ | if (ss.selectionMade()) { | ||
+ | Int sidx = ss.getSelectedKey(); | ||
+ | SSDemo1 f = (SSDemo1) ew[sidx]; // which we know is a SSDemo1 | ||
+ | if (f.val > 0) // ..if they' | ||
+ | val = f.val; | ||
+ | du.printContext(); | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | |||
+ | </ | ||
+ | |||
+ | <code - SSDemo2.ulam> | ||
+ | |||
+ | /** | ||
+ | | ||
+ | */ | ||
+ | |||
+ | element SSDemo2 { | ||
+ | // Typedefs | ||
+ | typedef Unsigned(8) Score; | ||
+ | |||
+ | // Utilities | ||
+ | EventWindow ew; | ||
+ | Random random; | ||
+ | DebugUtils du; | ||
+ | |||
+ | // Data members | ||
+ | Score val; | ||
+ | |||
+ | Void behave() { | ||
+ | if (val == 0) // randomize initial vals | ||
+ | val = random.bits(val.sizeof); | ||
+ | |||
+ | WindowServices ws; // Scanning support | ||
+ | SelectorServices ss; // Selection support | ||
+ | |||
+ | ws.reset(0, | ||
+ | ss.reset(); | ||
+ | |||
+ | for (Int idx = ws.next(); idx >= 0; idx = ws.next()) { | ||
+ | Atom a = ew[idx]; | ||
+ | if (a as SSDemo2) | ||
+ | ss.maximize((Int) a.val); | ||
+ | } | ||
+ | // We scanned ourselves, so we know ss.selectionMade() will be | ||
+ | // true. So we just take the chosen value (even if it was ours). | ||
+ | val = (Score) ss.getSelectedValue(); | ||
+ | du.printContext(); | ||
+ | } | ||
+ | } | ||
+ | |||
+ | </ | ||
==== Q: How to change the size of the MFM simulator? ==== | ==== Q: How to change the size of the MFM simulator? ==== | ||
Sometimes the canvas is too big for my experiment. If I don't want those atoms diffuse too far away, I will draw a box of '' | Sometimes the canvas is too big for my experiment. If I don't want those atoms diffuse too far away, I will draw a box of '' | ||
- | A: The regular | + | A: In version 3, the '' |
(and even the tile size!) on the command line. | (and even the tile size!) on the command line. | ||
Line 151: | Line 247: | ||
is specified is has to be the first argument on the command line. | is specified is has to be the first argument on the command line. | ||
- | Try something like: ..path../ | + | Try something like: |
+ | |||
+ | you@linux$ | ||
+ | |||
+ | or even | ||
+ | |||
+ | you@linux$ ..path../ | ||
+ | |||
+ | ==== Q: Do smaller grid geometries make the simulator run faster? ==== | ||
+ | |||
+ | **Thank you!** That's better than drawing '' | ||
+ | |||
- | or even ..path../ | ||
- | **Thank you professor!** That's better than drawing | + | **A: 31-May-2015 01: |
- | {{: | + | On a separate point, note that the "edge of the grid" is somewhat different that a ring of '' |
+ | {{: |
dev/questions_ulam.1433013988.txt.gz · Last modified: 2015/05/30 19:26 by xychen