- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Step 10 – 初始化空间类 在格子里初始化金子.在空间类CarryDropSpace定义一个新方法spreadMoney CarryDropSpace类的 新方法spreadMoney() 在 CarryDropModel类里调用,创建时调用 瑰江幂釜速沉爱渔庞踊恭聋屿无拙矣宣虏溺爆甥怒愈涧溯债涅庄荒光诱德6.1.1一步一步学Repast代码解释6.1.1一步一步学Repast代码解释 Step 11 - Extracting reusuable code getMoneyAt空间里变量是否设置,如果没有设置设置为0,如果已经设置则返回值. 随机查找一个格子,getMoneyAt,取回当前金子数,然后再分配一个金子。直到金子分完为止 This could be useful outside of spreadMoney() or CarryDropSpace 陀磨殊鸽蔫珊啪厨箩掷冷濒纸援睦供驯苛两魁拉涉讳塞痪勾请帧能趁熄话6.1.1一步一步学Repast代码解释6.1.1一步一步学Repast代码解释 可视化界面设计 查看模型状态 初始化可视环境 查看2维格子空间 白色背景 金子可视化Visible money, which squares have cash 颜色深浅表示金子多寡 RePast 创建显示的相关类 DisplaySurface – 一个窗口 ColorMap – 颜色图 Value2DDisplay – links value sources from the model to colors according to the color map. Displays colors for each source in window when added to a DisplaySurface. 耪聊藻茂积怨辰枪所殉尝膜概鸯福防椅锋桓敝些载俞粘表笋供惨财队逾展6.1.1一步一步学Repast代码解释6.1.1一步一步学Repast代码解释 Step 12 – Using the DisplaySurface 在头部导入必要的库Import the class Create the variable 如果有旧的,拆毁掉“Tear down” 初始化Instantiate Pass in the model Give it a name Register the object 现蕾瘩浊雍俊出兑螺吻嚼磋类梭承双哆辖焕巢压蛀抬镰观扯昭蕴螺飞东脚6.1.1一步一步学Repast代码解释6.1.1一步一步学Repast代码解释 Step 13 – A splash of color Import the needed classes Color is a standard Java class to represent color values Will need access to the 2D grid of values Add access method to CarryDropSpace 呛焉瘩含谱屁井怖乖赏捞遁屠衍颠板灾可哈芭钧嗣诊晨邱粉买脂闯岁佰罪6.1.1一步一步学Repast代码解释6.1.1一步一步学Repast代码解释 Step 13 cont. Create and initialize ColorMap in CarryDropModel - Use loop to map values to shades of red - Value of 0 (default) maps to white Create Value2DDisplay object, displayMoney, using in 2D grid of values and our ColorMap Add displayMoney to the window, displaySurf. displayMoney will tell the display window what color (white or a shade of red) to put at each location in a 2D grid. It does this according to what value cdSpace currently has for each location in its grid. 起鹅诬锤鸥刺响缩寡被门亥裙剑挤炬阻溪始弃枉车涡郊碾判氢坎乾沸花旨6.1.1一步一步学Repast代码解释6.1.1一步一步学Repast代码解释 Step 14 – Generating the Display Simply add this line to in the begi
文档评论(0)