dev:questions_ulam
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
dev:questions_ulam [2015/05/31 07:04] – [Q: How to change the size of the MFM simulator?] ackley | dev:questions_ulam [2015/05/31 09:57] – [Q: Does ws.getPick(typeIndex) only return one site? How to access each site within an event window?] ackley | ||
---|---|---|---|
Line 145: | Line 145: | ||
**Thank you**! Now I understand that '' | **Thank you**! Now I understand that '' | ||
- | **A: 31-May-2015 12: | + | **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 164: | Line 255: | ||
you@linux$ ..path../ | you@linux$ ..path../ | ||
- | ------ | + | ==== Q: Do smaller grid geometries make the simulator run faster? ==== |
- | **Thank you!** That's better than drawing '' | + | **Thank you!** 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