|
このページはEtoJ逐語翻訳フィルタによって翻訳生成されました。 |
Bookmark this on Delicious
Recommend to StumbleUpon
This is the second of two web pages. 表面上は, they show you how to make a good start on a 模擬実験/偽ること modeling the 生態学 of a small woodland, 住むd by grass, rabbits and foxes. A Predator/ Prey 全住民 Dynamics 模擬実験/偽ること.
The 模擬実験/偽ること won't 勝利,勝つ any prizes... yet... for 存在 true- to- nature. But, having said that, the way the work already done has been done should mean that 延長するing the 模擬実験/偽ること to make it more life-like is 完全に feasible. It would be an 利益/興味ing challenge.
The 最初の/主要な value of the 構成要素 here will be, I think, as an example of how you could build a 模擬実験/偽ること of things like predator/ prey interaction. Things that proceed in "世代s". 細胞の automata, such as Conway's "Life". Traffic flows. River flooding. One thing you could 取り組む this way which 特に tempts me is a 模擬実験/偽ること of how age pyramids proceed... i.e. graphs showing the numbers of males and 女性(の)s in age-範囲 禁止(する)d, over a 一連の years. Many, many 可能性s!
Download the sim07- Predator/ Prey 全住民 Dynamics 模擬実験/偽ること source-code. If you just want the source-code, to adapt to your own 目的s (or to follow along, as you read this essay), it is 利用できる for download, in an 古記録 called, not very imaginatively, "sim07.zip". The .exe that arises from 編集 is 含むd in that .zip, and can be run without any その上の ado. It doesn't read from or 令状 to your hard 運動. You can run it 直接/まっすぐに from the .zip, without doing an 抽出する- and- save first. 収集するd for Windows, on a Win7 machine. Download 実験(する)d under Firefox.)
A few 半端物s and ends of 一般に useful programming tricks and techniques also arise, as, I hope, ever.
Not "as ever" will be the level of 手渡す-持つ/拘留するing I 一般に 申し込む/申し出, 特に in tutorials of a more elementary nature. I 招待する you to try some of the lower "level" tutorials at my 場所/位置 until you are more Lazarus (or Delphi) "fluent", if you find this one goes too quickly.
Many general techniques are illustrated along the way. A 収集するd .exe is 利用できる so that you can play with the 使用/適用 without having to 収集する it. The Lazarus sourcecode is in the same zip とじ込み/提出する you can download. Both are there for you to play with... but I reserve all 権利s to any 使用/適用s derived from the sourcecode. It is there to show you programming techniques, not to be the basis of a 商業の 製品. 井戸/弁護士席... anyone else's 商業の 製品, anyway.
This is a 延長/続編 from sim06, a 模擬実験/偽ること of 全住民 dynamics in a woodland.
While sim06 had some very good stuff in it, and in its design and 開発, there was one major 欠陥... a pretty dumb one, at that!
You really should read that tutorial before this one, as there are many things I am not going to (打撃,刑罰などを)与える twice on people who HAVE read the first "一時期/支部".
The "計画(する)" was to model the biomass of the grass, rabbits and foxes in a small woodland, by 簡単に going '一連の会議、交渉/完成する and '一連の会議、交渉/完成する the に引き続いて 宙返り飛行....
REPEAT.... Make a 公式文書,認める of how things stood, end of previous period. Based on the grass you have, 追加する more. (It grew) Based on number of rabbits, 減少(する) grass by a 確かな 量. Based on number of rabbits, 増加する number of rabbits. (They bred) Based in number of foxes, 減少(する) number of rabbits. (They got eaten) Based on number of rabbits, 増加する or 減少(する) number of foxes. (Their 増加する from 産む/飼育するing either did, or did not, 越える the deaths 予定 to 餓死.) UNTIL YOU ARE BORED (or a 全住民 衝突,墜落s!)
===
Remember, please... the point of this is NOT to produce the 最新の, greatest 全住民 dynamics simulator. Rather, it is to 論証する some programming 原則s. Not least of which is "Build a 枠組み that is 強健な. One which can 徐々に be developed, 高めるd, made to 会社にする/組み込む more 詳細(に述べる)s."
===
In the pseudo-code 輪郭(を描く), you may have noticed "Make a 公式文書,認める of how things stood, end of previous period."
This is a ありふれた necessity in programs of this sort. It arises thus....
早期に on, we are going to 改訂する the biomass of grass 現在の. And after that, we are going to do a 計算/見積り on the feeding success of the rabbits 含むing as a factor, the grass 利用できる to them. But we don't want to be using the NEW grass biomass. We want 接近 to what the grass biomass was at the end of last year.
Hence, we created the に引き続いて....
lwBM_grassPrev, lwBM_rabbitPrev, lwBM_foxPrev:longword;
We will fill them, at the beginning of the 宙返り飛行, from lwBM_grass, lwBM_rabbit and lwBM_fox.
So far, so good. When, for instance, 査定する/(税金などを)課すing how much rabbit biomass might have been lost in the past year 予定 to the foxes eating rabbits, it isn't fair to use the number of foxes at the end of the year. (Of course, it isn't perfect to use the number of foxes at the beginning of the year, either. But we are going, at least for now, to "let that go", and use the number of foxes at the beginning of the year in our 計算/見積りs.)
These 計算/見積りs take place in the RabbitsReduce subroutine.
The problem with the first 見解/翻訳/版, sim006, arose in several places. Here's one, to illustrate it.
The two lines of pseudo-code 関心ing the 量 of rabbit biomass were as follows...
Based on number of rabbits, 増加する number of rabbits. (They bred) Based in number of foxes, 減少(する) number of rabbits. (They got eaten)
They turned into....
lwBM_rabbit:=(lwBM_rabbitPrev*wRabbitAD) div 1000; lwBM_rabbit:=lwBM_rabbitPrev-((lwBM_fox*wRabbitRD) div 100);
A moment's thought will tell you that the first line is going to be a 完全にする waste of time, have no 影響 on the rabbit biomass at the end of the 現在の "year". The "new" (after the "追加する") rabbit biomass is over-written with the result of the "減ずる rabbit biomass" 計算/見積り (the second line.)
At this point, while the 模擬実験/偽ること is simple, there is a very simple 直す/買収する,八百長をする to this problem....
lwBM_rabbit:=(lwBM_rabbitPrev*wRabbitAD) div 1000;
lwBM_rabbit:=lwBM_rabbit{Prev}-((lwBM_fox*wRabbitRD) div 100);
(The one 始める,決める of curly brackets {} in the second line, "take out" the "Prev" between them, making the line, 効果的に,....
lwBM_rabbit:=lwBM_rabbit-((lwBM_fox*wRabbitRD) div 100);
... which "Would Work".
However! "It would work" "解答s" are いつかs 誤った 約束s of an 平易な 直す/買収する,八百長をする.
Any time you find you can 直す/買収する,八百長をする something serious with an 平易な 直す/買収する,八百長をする, 診察する it with care and 疑惑.
If this 模擬実験/偽ること is going to be a good 創立/基礎 upon which a sophisticated 模擬実験/偽ること can, in time, with work, be built, it needs to be a solid 創立/基礎, without little "tricky" bits to trip us up when we are concentrating on something else later.
At the moment, the RabbitsAdd and RabbitsReduce subroutines, from which the two lines above come, each consist of just the one line you see. If the 模擬実験/偽ること is to be made more 現実主義の, those subroutines will grow. Remembering that in one we can work from lwBM_rabbitPrev to calculate then new lwBM_rabbit, but in the other we must work from the new, the 中間の, the "sub-total" "lwBM_rabbit"... even while in parts we will need to know the lwBM_rabbitPrev 人物/姿/数字 is just asking for trouble.
以前, if we 手配中の,お尋ね者 to 追加する 10% to the rabbit biomass, we (in 影響) did....
lw_BM_rabbit:=lw_BM_rabbit*1.10
Although it will mean more variables, and more 計算/見積りs, I am 説得するd that for the 欠如(する) of subtle things to trip us up, it may be wiser to 可決する・採択する the に引き続いて approach. It will mean that the way the changes are calculated in both the "追加する" and "減ずる" subroutines will follow a ありふれた pattern....
Approximation of new way to 追加する 10% to lw_BM_rabbit....
lwToAdd:=lw_BM_rabbit*0.1; lw_BM_rabbit:=lw_BM_rabbit+lwToAdd;
.. and in the "減ずる" subroutine, we would have something like....
lwToSubtract:=lw_BM_rabbit*0.05; lw_BM_rabbit:=lw_BM_rabbit-lwToSubtract;
Yes, I know I've "cheated" and pretended we can multiply an integer by 0.1... you'll see the way we get around that in the actual code. However, 公式文書,認める that I have NOT cheated in the 事柄 of trying to 蓄える/店 a 消極的な number in an unsigned integer type variable.
Of course, because I chose to use unsigned integers, I will need....
lwToSubtract:=lw_BM_rabbit*0.05; if (lw_BM_rabbit>lwToSubtract) then lw_BM_rabbit:=lw_BM_rabbit-lwToSubtract else lw_BM_rabbit:=0;
Also all of the "率s" will have to be 変えるd. (1020 to become 20, etc.)
Sigh. I noticed the 欠陥 in sim06 about an hour ago. And now I have the "joy" of 器具/実施するing the things discussed above. I'd much rather be 延長するing the program, not 直す/買収する,八百長をするing 欠陥s! Just shows what happens to programmers who type before they have 完全に planned (and reviewed 計画(する)s.) Oh 井戸/弁護士席.
===========
(After about an hour.... Onward! (Hurrah!))
I 手配中の,お尋ね者 to leave having a graph of the biomasses for another time... it introduces a bunch of new 頭痛s... but I couldn't resist.
The 規模ing is somewhat 独断的な, with the swings of the rabbit and fox biomass 誇張するd, 親族 to the grass biomass. If they were all to the same 規模, the variation in the rabbit and fox biomass would be hard to see.
支配(する)/統制するs 関係のある to the graphing... Image1, with a bitmap associated. (See sheepdogguides.com/lut/PixelProblem.htm, and the section 示すd "始める,決める up a 非,不,無-resize-able "surface" for doing graph on." in the FormCreate handler of the code. 公式文書,認める also the constants associated with this, wImageW, wImageH, and the extra variable, "Bitmap", of type TBitmap.
New data will be 追加するd at the 権利 手渡す 辛勝する/優位 of the chart, and each "year" it will scroll one pixel to the left. Hence the new subroutines "ClearDrawingSurface", "PlotPoints" "DrawLine" and "ScrollGraph". (And "DrawDiag", if it is still 現在の!
These, and Image1, and Bitmap, are all just for doing the graph showing the biomasses over time. Do not waste time on them if they perplex you.
Also just for the graphing: clGrass, clRabbit, clFox (決定する color lines drawn in.)
その上の for graphing: The 相殺する and 規模ing constants, for grass, rabbit and fox: wScGrass, wOffGrass, etc.
====
At this point....
That about exhausts the time I have for this at the moment.
As I hope I have said often enough, it is NOT 現在のd as a "finished", "完全にする" predator/ prey model. I hope you agree that it IS a good basic 枠組み which could be taken much その上の? I hope you see elements in it which would be useful 成分s for many wants? I hope you can see that not only is the basic 枠組み suitable for predator/ prey models, but also for other programming, for instance "人工的な life" 模擬実験/偽ることs, in the style of Conway's "Life". Or, as I happen to be listening to some "relaxing" music", a dynamic graphics 陳列する,発揮する ふりをするing an 広げるing "biome", to be used, say, for a screensaver. The 枠組み could be used to model movements of 惑星s around a sun. Etc, etc.
====
To Do's....
Sigh. I REALLY have to turn to other things. But I couldn't just 令状 about 追加するing a "make it go by itself" button, so 出版(物) (and breakfast, and the day 職業, etc, etc) got 延期するd to do that.
The 複雑さ of the biology can be 熟考する/考慮するd in ever greater 詳細(に述べる) until you have your Ph.D in 生態学, and beyond. I 本気で believe that the 枠組み in this modest start at modeling an ecosystem could "take the 緊張する" of very 重要な 拡張. Even if just as a hobbyist (programmer, or biologist, or both!), I hope you will 追加する more factors in- for the fun of it. A 抱擁する 前進する would be to 追加する grasshoppers and mice and a kestrel... and make all feeding proportionate to a predator's "likes" and prey 豊富. Harder to 追加する, maybe, but 平等に important... a 機械装置 which introduced a lag between biomass 増加する and the consequent 率 (in 絶対の 条件) of "増加する 増加する". This, done 適切に, would soon make the sim portray things like the famous link between lynxes and hares in Canada. 1845-1925. (The two 全住民s went through symmetrical, but out of 段階, "にわか景気/ 破産した/(警察が)手入れする" cycles.) (More foxes (or better 条件s, and hence survivorship) in June 2016 doesn't mean "more more" foxes in July of the same year. The cubs have to grow up before they 再生する!)
Many of the things you would tweak by 手渡す, then recompile, should be accessible interactively. An ini とじ込み/提出する should 持つ/拘留する the values you had chosen. It should be possible to save and 負担 シナリオs. If you 再開する the sim (with the button 始める,決める up for doing that without shutting/ 再開するing the app), the "clock" should stop, i.e. "自動車-前進する" should be turned off.
The game element (you get to "play God", selectively 追加する biomass, to "put thumb on 規模", as sim 進歩s) needs to be 追加するd in.
Enjoy! I hope you will publish derivatives, and let me know where, so I can go and look at what you've built! (I will assume you want a link to it from here, unless I hear さもなければ)
That's it for this two part tutorial. I hope you liked it, will recommend 経由で social マスコミ (see 最高の,を越す of page), etc. Feedback welcome other than "needs more graphics". (I know that!)
Search across all my 場所/位置s with the Google search...
|
|
Page 実験(する)d for 同意/服従 with INDUSTRY (not MS-only) 基準s, using the 解放する/自由な, 公然と accessible validator at validator.w3.org. Mostly passes. There were two "unknown せいにするs" in Google+ button code. Sigh.
....... P a g e . . . E n d s .....