1 / 10

電腦物理與教學 第八組

指導 教授:利見興 老師 學生: M10061306 張代雄 M10061325 張家寶. 電腦物理與教學 第八組. 範例 介紹 ( 模擬直線上的行人 ). 原始碼. steps++; //steps 每次執行完自動 +1 for( int i =1; i <n; i ++){ // 宣告一個整數型態的變數 i 並給定初始值為 1 double d=-1+2* Math.random (); // 宣告一個 double 型態的變數 d, 初始值為 2 倍亂數值 -1 . walkers[ i ]+=d; // 產生 walkers 陣列的各個值

beth
Télécharger la présentation

電腦物理與教學 第八組

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 指導教授:利見興 老師 學生: M10061306 張代雄 M10061325 張家寶 電腦物理與教學第八組

  2. 範例介紹(模擬直線上的行人)

  3. 原始碼 • steps++; • //steps每次執行完自動+1 • for(inti=1; i<n; i++){ • //宣告一個整數型態的變數i並給定初始值為1 • double d=-1+2*Math.random(); • //宣告一個double型態的變數d, 初始值為2倍亂數值-1. • walkers[i]+=d; • //產生walkers陣列的各個值 • }

  4. 限制與規則 • double d=-1+2*Math.random() 程式碼讓行人前進或後退的機率均等。 • walkers[i]+=d,此行程式碼讓walkers陣列的值能儲存起來。事實上它也可以這樣寫。walkers[i]=walkers[i]+d;

  5. 範例介紹

  6. 原始碼 • if(r<=pRight) {//判別r是否小於等於0.25 • xpos[i] = xpos[i]+1;//將xpos[i]+1後寫入xpos陣列 • } else if(r<pRight+pLeft){//判別r是否在0.25<r<0.5間 • xpos[i] = xpos[i]-1;//將xpos[i]-1後寫入xpos陣列 • } else if(r<pRight+pLeft+pDown){//判別r是否<0.75 • ypos[i] = ypos[i]-1;//將ypos[i]-1後寫入ypos陣列 • } else{ • ypos[i] = ypos[i]+1;//將ypos[i]+1後寫入ypos陣列 • }

  7. 限制與規則 • 按照程序的寫法,迴圈每執行一次,質點只會往前、後、下、上其中一個方向移動一格。

  8. 主題介紹(以亂數模擬大樂透開獎分析)

  9. 進度規劃 • 0407 導論與分組 • 資料搜尋與主題討論。 • 0428 提案報告 • 完成範例分析與主題架構,並開始寫作程式碼與模型。 • 0512 進度報告(一) • 預計完成第一階段程式碼與統計圖表。 • 0526 進度報告(二) • 預計完成第二階段程式碼(重置、一次產生N組數據(直顯示於圖表上)) • 0預616 成果演示 • 成果展示。

  10. 參考文獻 • Open Source Physics • http://www.compadre.org/osp/index.cfm • Random Walk 1D Continuous Model Documents • http://www.compadre.org/OSP/document/ServeFile.cfm?ID=8844&DocID=1170 • Random Walk 2D Model • http://www.compadre.org/OSP/document/ServeFile.cfm?ID=8845&DocID=1172 • 台灣師大物理系-物理教學示範實驗教室 • http://www.phy.ntnu.edu.tw/demolab/phpBB/

More Related