代写CSCI 1100、代做Bears, Berries and Tourists
CSCI 1100 — Computer Science 1 Homework 8
Bears, Berries and Tourists Redux: Classes
Overview
This homework is worth 100 points toward your overall homework grade, and is due Thursday,
April 18, 2024 at 11:59:59 pm. It has three parts. The first two are not worth many points,
and may end up being worth 0. They are mainly there to give you information to help you debug
your solution. Please download hw8_files.zip. and unzip it into the directory for your HW8.
You will find data files and sample outputs for each of the parts.
The goal of this assignment is to work with classes. You will be asked to write a simulation engine
and use classes to encapsulate data and functionality. You will have a lot of design choices to make.
While we have done simulations before, this one will be more complex. It is especially important
that you start slowly, build a program that works for simple cases, test it and then add more
complexity. We will provide test cases of increasing difficulty. Make sure you develop slowly and
test throughly.
Submission Instructions
In this homework, for the first time, you will be submitting multiple files to Submitty that together
comprise a single program.
Please follow these instructions carefully.
Each of Part 1, Part 2 and Part 3 will require you to to write a main program: hw8_part1.py,
hw8_part2.py and hw8_part3.py, respectively. You must also submit three modules per part in
addition to this main file, each of which encapsulates a class. The first is a file called BerryField.py
that contains your berry class, a file called Bear.py that contains your Bear class and a file called
Tourist.py that contains your Tourist class.
As always, make sure you follow the program structure guidelines. You will be graded on good
program structure as well as program correctness.
Remember as well that we will be continuing to test homeworks for similarity. So,
follow our guidelines for the acceptable levels of collaboration. You can download the
guidelines from the resources section in the Course Materials if you need a refresher.
We take this very seriously and will not hesitate to impose penalties when warranted.
Getting Started
You will need to write at least three classes for this assignment corresponding to a BerryField, a
bear and a Tourist. We are going to give you a lot of freedom in how you organize these three
classes, but each class must have at least an initializer and a string method. Additional methods
are up to you. Each of the classes is described below.
BerryField
The berry field must maintain and manage the location of berries as a square Row X Column grid
with (0,0) being the upper left corner and (N-1, N-1) being the lower right corner. Each space
holds 0-10 berry units.
• The initializer class must, minimally, be able to take in a grid of values (think of our Sodoku
lab) and use it to create a berry field with the values contained in the grid.
• The string function must, minimally, be able to generate a string of the current state of the
berry patch. Each block in the grid must be formatted with the "{:>4}" format specifier. If
there is a bear at the location the grid should have a "B", if there is a tourist the grid should
have a "T", and if there is both a bear and a tourist the grid should have an "X". If there is
neither a bear nor a tourist, it should have the number of berries at the location.
• Berries grow. The berry class must provide a way to grow the berry field. When the berries
grow, any location with a value 1 <= number of berries < 10 will gain an extra berry.
• Berries also spread. Any location with no berries that is adjacent to a location with 10 berries
will get 1 berry during the grow operation.
Bear
Each bear has a location and a direction in which they are walking. Bears are also very hungry. In
your program, You must manage 2 lists of bears. The first list are those bears that are currently
walking in the field. The second is a queue of bears waiting to enter the field.
• The initializer class must, minimally, be able to take in a row and column location and a
direction of travel.
• The string function must, minimally, be able to print out the location and direction of travel
for the bear and if the bear is asleep.
• Bears can walk North (N), South (S), East (E), West (W), NorthEast (NE), NorthWest (NW),
SouthEast (SE), or SouthWest (SW). Once a bear starts walking in a direction it never turns.
• Bears are always hungry. Every turn, unless there is tourist on the same spot, the bear eats
all the berries available on the space and then moves in its current direction to the next space.
This continues during the current turn until the bear eats 30 berries or runs into a tourist.
• For the special case of a bear and a tourist being in the same place during a turn, the bear
does not eat any berries, but the tourist mysteriously disappears and the bear falls asleep for
three turns.
• Once a bear reaches the boundary of the field (its row or column becomes -1 or N), it is no
longer walking in the field and need not be considered any longer.
Tourist
Each tourist has a location. Just like with bears, you must someplace maintain a list of tourists
currently in the field and a queue of tourists waiting to enter the field.
• The initializer class must, minimally, be able to take in a row and column location.
• Tourists see a bear if the bear is within 4 of their current position.
• The string function must, minimally, be able to print out the location of the tourist and how
many turns have passed since they have seen a bear.
• Tourists stand and watch. They do not move, but they will leave the field if:
1. Three turns pass without them seeing a bear; they get bored and go home.
2. They can see three bears at the same time; they get scared and go home
3. A bear runs into them; they mysteriously disappear and can no longer be found in the
field.
Execution
Remember to get hw8_files_F19.zip from the Course Materials section of Submitty. It has two
sample input files and the expected output for your program.
For this homework all of the data required to initialize your classes and program can be found in
json files. Each of your 3 parts should start by asking for the name of the json file, reading the
file, and then creating the objects you need based on the data read. The code below will help you
with this.
f = open("bears_and_berries_1.json")
data = json.loads(f.read())
print(data["berry_field"])
print(data["active_bears"])
print(data["reserve_bears"])
print(data["active_tourists"])
print(data["reserve_tourists"])
You will see that field in a list of lists where each [row][column] value is the number of berries
at that location; the "active_bears" and "reserve_bears" entries are lists of three-tuples (row,
column, direction) defining the bears; and the "active_tourists" and "reserve_tourists"
entries are lists of two-tuples (row, column) defining the tourists.
Part 1
In part one, read the json file, create your objects and then simply report on the initial state of the
simulation by printing out the berry field, active bears, and active tourists. Name your program
hw8_part1.py and submit it along with the three classes you developed.
Part 2
In part two, start off the same by reading the json file and create your objects and again print out
the initial state of the simulation. Then run five turns of the simulation by:
• Growing the berries
• Moving the bears
• Checking on the tourists
• Print out the state of the simulation
Do not worry about the reserve bears or reserve tourists entering the field, but report on any
tourists or bears that leave. Name your program hw8_part2.py and submit it along with the three
classes you developed.
Part 3
In part three, do everthing you did in part 2, but make the following changes.
• After checking on the tourists, if there are still bears in the reserve queue and at least 500
berries, add the next reserve bear to the active bears.
• Then, if there is are still tourists in the reserve queue and at least 1 active bear, add the next
reserve tourist to the field.
• Instead of stopping after 5 turns, run until there are no more bears on the field and no more
bears in the reserve list; or if there are no more bears on the field and no more berries.
• Finally, instead of reporting status every turn, report it every 5 turns and then again when
the simulation ends.
As you go, report on any tourists or bears that leave or enter the field. Name your program
hw8_part3.py and submit it along with the three classes you developed.
请加QQ:99515681 邮箱:99515681@qq.com WX:codinghelp
- Instagram营销软件,ins如何快速群发/ig精准引流神器推荐/联系大轩测试
- WhatsApp群发云控软件,ws协议云控功能/ws协议号批发
- 登上国际顶刊的鼻喷,一位英国医学科学院院士的科研成果转化之旅
- TG、WS、Zalo、line海外营销代筛料子功能工具的系統软件,乐乐解答
- 未知商机的科技征途:WhatsApp筛选器推广打开国际大门
- 跨境电商 Line 群发云控征途的科技幽默:探险跨境电商 Line 群发云控征途的科技幽默,笑中有智慧
- “数字卫生”:在“世界备份日”安心无忧地备份数据
- 陈丹感恩:恒兴33年,感恩一路有你
- 从此告别业务低谷 WhatsApp拉群营销工具 我的营业额狂飙不止
- LitePoint、Morse Micro与AzureWave合作,推动Wi-Fi HaLow在工业物联网中的应用
- 智慧医疗时代,两位院士、百余位学科带头人在如何做健康管理?
- 石阡生态农业平台:绿色生态,共享健康新生活
- ins营销软件,ins群发拉群助手,爆粉软件欢迎测试联系
- 代做 Rule Minimizer、代写 SQL 语言程序
- WhatsApp营销软件,ws拉群助手/ws协议号/ws注册/ws业务咨询大轩
- AIC2100代写、Python设计程序代做
- EIG 旗下 MidOcean Energy 将收购 SK Earthon 在秘鲁液化天然气(PLNG)公司 20% 的股份
- 百万博主推荐instagram引流营销工具,ins强力群发私信软件
- 绿色生态农业:回归自然,滋养未来
- 深圳科华荣获2024“北极星杯”两项行业大奖!
- 代做IERG 4080、代写Python程序语言
- Instagram营销软件,ins群发工具/ig采集神器/测试联系大轩
- 商业先锋推荐WhatsApp工具助力海外营销高手揭示市场趋势的独到智慧
- 外贸新星 WhatsApp拉群营销工具的奇异之处 引发我的浓厚好奇
- Instagram营销软件,Ins群发拉群助手,助你实现营销新突破!
- 近视手术的术前检查有多重要?爱尔英智眼科医院王文娟主任来解答
- Ins群发群控工具,Instagram多开云控群发,助你实现营销目标!
- Instagram营销软件 - ins定位采集/ig私信博主/ins批量养号
- 数字风暴 博主授业 WhatsApp拉群营销工具是我国际业务的风起云涌
- Ins自动私信/强私教程,Instagram营销引流神器全方位解析!
推荐
- 创意驱动增长,Adobe护城河够深吗? Adobe通过其Creative Cloud订阅捆绑包具有 科技
- B站更新决策机构名单:共有 29 名掌权管理者,包括陈睿、徐逸、李旎、樊欣等人 1 月 15 日消息,据界面新闻,B站上周发布内部 科技
- 智慧驱动 共创未来| 东芝硬盘创新数据存储技术 为期三天的第五届中国(昆明)南亚社会公共安 科技
- 疫情期间 这个品牌实现了疯狂扩张 记得第一次喝瑞幸,还是2017年底去北京出差的 科技
- 苹果罕见大降价,华为的压力给到了? 1、苹果官网罕见大降价冲上热搜。原因是苹 科技
- 全力打造中国“创业之都”名片,第十届中国创业者大会将在郑州召开 北京创业科创科技中心主办的第十届中国创业 科技
- 老杨第一次再度抓握住一瓶水,他由此产生了新的憧憬 瘫痪十四年后,老杨第一次再度抓握住一瓶水,他 科技
- 丰田章男称未来依然需要内燃机 已经启动电动机新项目 尽管电动车在全球范围内持续崛起,但丰田章男 科技
- 升级的脉脉,正在以招聘业务铺开商业化版图 长久以来,求职信息流不对称、单向的信息传递 科技
- 如何经营一家好企业,需要具备什么要素特点 我们大多数人刚开始创办一家企业都遇到经营 科技