首页
网站开发
桌面应用
管理软件
微信开发
App开发
嵌入式软件
工具软件
数据采集与分析
其他
首页
>
> 详细
program编程设计讲解、辅导Python留学生程序 辅导留学生Prolog|解析C/C++编程
项目预算:
开发周期:
发布时间:
要求地区:
Intro to Dear AI - Spring 2021
Homework 1
Burnt pancake problem
Due: Wednesday, March 24th
, 11:59 pm
In Short
Write a program that receives an order of 4 bottom-burnt pancakes and prints the
solution that BFS and A* search will find for going from the Start state to the Goal
(ordered pancakes and all burnt-side down).
Description
In this programming homework, you will work on a modified version of the classic
pancake problem that was discussed in the class. In this version, one side of each
pancake is burnt, and the pancakes must be sorted with all the burnt-side down. You
need to write a program that receives an arbitrary order of such 4 pancakes from the
user, plus the type of the search algorithm, and prints the steps that the specified
algorithm will take to reach the Goal state.
Format
Similar to the format described in class, each of the pancakes has an ID number that is
consistent with their size followed by a letter “w” or “b”. This way, the largest pancake
has an ID of 4, the next largest 3, the next 2, and the smallest has an ID of 1. The letter
“w” refers to the unburnt (white) side is up, and “b” shows that the burnt side is up. The
goal is to reach “1w2w3w4w”. Figure 1 shows an example of the IDs associated with
each pancake in a certain configuration.
Input
The input should consist of pairs of four digits and one character, a hyphen, and one
last character (#C#C#C#C-X), where the first digit indicates the ID of the top pancake
and the first character indicates whether if the burnt side is down (“w”) or not (“b”), the
second number indicates the second-highest pancake followed by a character, etc. The
last character (X) would be “b” or “a” characters, which refer to the Breadth-First (BFS)
or A* search algorithms respectively. The program should receive this variable as an
input from the user upon running the code.
Implementation
The cost associated with each flip is equal to the number of pancakes that are being
flipped. For instance, the cost of one flip between pancake 3b and 2b from the state
“4w1b2w3b” to “2b1w4b3b” is equal to 3 (spatula between 2 and 3). For each state, use
the same heuristic function (h(x)) that was discussed in the class: “the ID of the largest
pancake that is still out of place”. For BFS, you don’t need to consider a cost and a
heuristic function. Use the graph version of the algorithms, meaning that use some type
of list (closed set) to avoid visiting the nodes multiple times.
Add as many comments as you can to your code, so that it’s easy to understand your
implementation, including the role of functions, variables, etc. Specifically, make it clear
how your fringe is implemented and employed. Use an informative name for your fringe
and add comments where you define that.
Tie-Breaking
When needed for any of the search algorithms, use the following tie-breaking
mechanism:
"when there is a tie between two nodes, replace “w” with 1 and “b” with 0 to obtain an
eight-digit number. After that pick the node with a larger numerical ID chosen."
For instance, if there is a tie between 4b3w2b1b and 3w4w2b1b, then 4b3w2b1b will be
chosen as 40312010>31412010.
Output
Your program must print the steps that the specified algorithm (e.g., BFS) finds to solve
the problem, line by line. In other words, simply prints the solution that the algorithm
finds. For each state (except the final state), use the character “|” to show where the flip
to go to the next step happens. For A*, also print the value for the actual cost (function
g), and the value of the heuristic function (function h) in each step. The following is an
example of an input and output of the program.
Input:
1b2b3w4b-a # “a” indicates A*
Output: 1b2b|3w4b g:0, h:0
2w|1w3w4b g:2, h:2
2b1w3w4b| g:3, h:2
4w|3b1b2w g:7, h:4
4b3b1b2w| g:8, h:4
2b1w|3w4w g:12, h:2
1b|2w3w4w g:14, h:0
1w2w3w4w g:15, h:0
Note that the values for g and h correspond to the “current” state, and the character “|”
denotes the location of the flip for going to the “next” state.
Programming Language
At this point, our Moodle implementation only accepts Python.
Submitting Instructions
Follow this procedure for enrolling on the Moodle server:
● Go to https://quiz.cis.udel.edu/
● Select “CISC 681/481-21S-Beheshti” from the course list
● Enroll yourself as a student using the enrollment key: “dearai”
● Select the related assignment (Burnt Pancake)
● Click on the Edit tab and enter your program in the editor (tabbed
"hw1.py"). You can run and evaluate your code there. To evaluate your
code, you should first save the code and then click on evaluate.
● Your highest score before the deadline will be recorded as the proposed
grade. There’s no limitation on the number of submissions you can make.
The format of the input is as described above and you should enter input with the
same format while running the code. The program should only print the
requested output with the format described earlier.
Similarity Check
Please note that Moodle automatically checks for similarities between any submission
at any time that is related to this homework. The Collaboration and Cheating policy is
presented in our syllabus.
Grading
The total points will be 100. For each of the two requested search algorithms, you will
receive 50 points. The system will drop points per each failed test-case. For instance, if
there are 10 test-cases, you will lose 10 points per any wrong output.
Note that what you see on Moodle will be the “proposed grade.” Your submission can be
manually evaluated to ensure your code is actually solving the problems as requested.
To make understanding your code easier, you may want to use a different function for
each of the search algorithms, even if it needs copying the same piece of code and use
easily distinguishable names for your functions.
Questions?
Post them on Pizza. You can mention our TA @Mina Samizadeh for questions about
formatting and Moodle.
Final Note
Don’t start late! It might take you longer than you expect to finish the homework.
Some Other Examples
Example 1
Input: 1w2b3w4b-a
Output: 1w2b|3w4b g:0, h:0
2w|1b3w4b g:2, h:2
2b1b3w4b| g:3, h:2
4w|3b1w2w g:7, h:4
4b3b1w2w| g:8, h:4
2b1b|3w4w g:12, h:2
1w2w3w4w g:14, h:0
Example 2
Input: 1w2b3w4b-b
Output: 1w2b|3w4b
2w|1b3w4b
2b1b|3w4b
1w2w3w4b|
4w|3b2b1b
4b3b2b1b|
1w2w3w4w
Example 3
Input: 1b2b3w4b-a
Output: 1b2b|3w4b g:0, h:0
2w|1w3w4b g:2, h:2
2b1w3w4b| g:3, h:2
4w|3b1b2w g:7, h:4
4b3b1b2w| g:8, h:4
2b1w|3w4w g:12, h:2
1b|2w3w4w g:14, h:0
1w2w3w4w g:15, h:0
Example 4
Input: 1w2b3b4w-b
Output: 1w2b|3b4w
2w|1b3b4w
2b1b|3b4w
1w2w3b|4w
3w|2b1b4w
3b2b1b|4w
1w2w3w4w
Example 5
Input: 1b2w3b4b-a
Output: 1b2w3b4b| g:0, h:0
4w|3w2b1w g:4, h:4
4b3w|2b1w g:5, h:4
3b|4w2b1w g:7, h:4
3w4w|2b1w g:8, h:4
4b3b2b1w| g:10, h:4
1b|2w3w4w g:14, h:0
1w2w3w4w g:15, h:0
软件开发、广告设计客服
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-23:00
微信:codinghelp
热点项目
更多
代做ceng0013 design of a pro...
2024-11-13
代做mech4880 refrigeration a...
2024-11-13
代做mcd1350: media studies a...
2024-11-13
代写fint b338f (autumn 2024)...
2024-11-13
代做engd3000 design of tunab...
2024-11-13
代做n1611 financial economet...
2024-11-13
代做econ 2331: economic and ...
2024-11-13
代做cs770/870 assignment 8代...
2024-11-13
代写amath 481/581 autumn qua...
2024-11-13
代做ccc8013 the process of s...
2024-11-13
代写csit040 – modern comput...
2024-11-13
代写econ 2070: introduc2on t...
2024-11-13
代写cct260, project 2 person...
2024-11-13
热点标签
mktg2509
csci 2600
38170
lng302
csse3010
phas3226
77938
arch1162
engn4536/engn6536
acx5903
comp151101
phl245
cse12
comp9312
stat3016/6016
phas0038
comp2140
6qqmb312
xjco3011
rest0005
ematm0051
5qqmn219
lubs5062m
eee8155
cege0100
eap033
artd1109
mat246
etc3430
ecmm462
mis102
inft6800
ddes9903
comp6521
comp9517
comp3331/9331
comp4337
comp6008
comp9414
bu.231.790.81
man00150m
csb352h
math1041
eengm4100
isys1002
08
6057cem
mktg3504
mthm036
mtrx1701
mth3241
eeee3086
cmp-7038b
cmp-7000a
ints4010
econ2151
infs5710
fins5516
fin3309
fins5510
gsoe9340
math2007
math2036
soee5010
mark3088
infs3605
elec9714
comp2271
ma214
comp2211
infs3604
600426
sit254
acct3091
bbt405
msin0116
com107/com113
mark5826
sit120
comp9021
eco2101
eeen40700
cs253
ece3114
ecmm447
chns3000
math377
itd102
comp9444
comp(2041|9044)
econ0060
econ7230
mgt001371
ecs-323
cs6250
mgdi60012
mdia2012
comm221001
comm5000
ma1008
engl642
econ241
com333
math367
mis201
nbs-7041x
meek16104
econ2003
comm1190
mbas902
comp-1027
dpst1091
comp7315
eppd1033
m06
ee3025
msci231
bb113/bbs1063
fc709
comp3425
comp9417
econ42915
cb9101
math1102e
chme0017
fc307
mkt60104
5522usst
litr1-uc6201.200
ee1102
cosc2803
math39512
omp9727
int2067/int5051
bsb151
mgt253
fc021
babs2202
mis2002s
phya21
18-213
cege0012
mdia1002
math38032
mech5125
07
cisc102
mgx3110
cs240
11175
fin3020s
eco3420
ictten622
comp9727
cpt111
de114102d
mgm320h5s
bafi1019
math21112
efim20036
mn-3503
fins5568
110.807
bcpm000028
info6030
bma0092
bcpm0054
math20212
ce335
cs365
cenv6141
ftec5580
math2010
ec3450
comm1170
ecmt1010
csci-ua.0480-003
econ12-200
ib3960
ectb60h3f
cs247—assignment
tk3163
ics3u
ib3j80
comp20008
comp9334
eppd1063
acct2343
cct109
isys1055/3412
math350-real
math2014
eec180
stat141b
econ2101
msinm014/msing014/msing014b
fit2004
comp643
bu1002
cm2030
联系我们
- QQ: 9951568
© 2021
www.rj363.com
软件定制开发网!