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/31 02:40] – [Q: How to access event window site number when using ''WindowServices scan()''?] xychen | dev:questions_ulam [2015/06/01 18:11] (current) – [Q: Do smaller grid geometries make the simulator run faster?] xychen | ||
---|---|---|---|
Line 143: | Line 143: | ||
==== Q: Does ws.getPick(typeIndex) only return one site? How to access each site within an event window? ==== | ==== Q: Does ws.getPick(typeIndex) only return one site? How to access each site within an event window? ==== | ||
- | **Thank you professor**! Now I understand that '' | + | **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 154: | 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.txt · Last modified: 2015/06/01 18:11 by xychen