代写Assignment 1 (Autumn Term 2024)代写留学生Python语言

Assignment 1 (Autumn Term 2024)

Questions

1. Vacuum cleaner

Consider the Simple Reflex Agent in the Two-square Vacuum-cleaner World studied in  w01_vacuum_world_revised.ipynb in your seminar

(linked here, see code blocks 30 and 31 for the environment and agent definitions). We modify the environment so that after dirt has been cleaned in a square, new dirt will be generated in the same square after Y time steps, where Y ∼ Geom(p) for p = 1/15 (i.e. if the square is clean at     any time point, the probability of having dirt in the square at the next time point isp). Let RT denote the average reward in T time steps for this     Simple Reflex Agent.

i.  Write down the PEAS description of the task environment (using the reward function as in the IPython notebook). Is the environment fully observable? Is the environment deterministic?

ii.  Compute limT T −1ERT . You may derive it mathematically or write a piece of code to provide an approximate solution (to two decimal places) for this part. You do not need to submit any code used.

iii.  Is the simple reflex agent described in (ii) rational? Why or why not?

iv.  Explain why model-based agents can be more suitable for this particular environment.

2. Maze exploration

Consider the following maze in a 7-by-7 grid world. An agent is exploring the maze from

At each square, the agent will always try  forward ,  turn left and  turn right in this order. For example, after reaching square  X , the agent will try first to move East, and then try to move North (which it cannot move due to a wall), before trying to move South.

i.  If the agent explores using a depth-first graph search algorithm, write down the order in which it visits squares  A ,  B ,  C ,  D ,  E and  F before reaching the  Finish (not all squares may be visited).

ii.  If the agent explores using a breadth-first graph search algorithm, write down the order in which it visits squares  A ,  B ,  C ,  D ,  E and  F before reaching the  Finish (not all squares may be visited).

iii.  In the previous two parts, will your answers change if the agent used depth-first tree search and breadth-first tree search respectively? Why?

iv.  The agent now uses an A* search algorithm with the heuristic function

h(x) = (x1(−)f1(−−))2(−)(x2(−−)f2(−−),

where x = (x1, x2) is the coordinate value of the current square (with (0,0) for the top-left square) and f = (f1, f2) = (6, 3) is the coordinate value of the  Finish square. Is this heuristic function admissible? Why?

3. Sokoban

In this task, you are required to submit Python code that solves a variant of the Sokoban (Storekeeper) game using the A* search algorithm. You will modify the provided  sokoban.py file to solve the puzzle based on the game rules and provided input.

Game Rules

Game setup: The game is initialised with a 7x7 grid world where each square can either be an obstacle  * , a free square (blank space), a storekeeper  S , a box  B or a target location  # . You may assume that there is only one  S , one  B and one  # , and that the entire

perimeter of the grid world are lined with  * .

Movement: You control the storekeeper. In each step, your action is one of ‘N’ (move north), ‘S’ (move south), ‘E’ (move east), ‘W’ (move west). The storekeeper cannot walk into an obstacle ( * ). The storekeeper can push the box  B (by walking towards it) only if the square   behind the box (in the direction of the push) is free (not an obstacle).

Cost: The floor of the store is sloped so it is difficult to push the box North. Each push in the North has a cost of 0.2, and a push in South, East or West has a cost of 0.1. In addition, each non-pushing movement of the storekeeper incurs a cost of 0.01.

Example

The 7x7 character array in  input0.txt encodes the initial game configuration as shown in the leftmost panel below:

A sequence of moves  NNWNNESSSNNNEESSSSWW would have solved the puzzle (though not necessarily optimally) with a total cost of 0.2 × 1 + 0.1 × 4 + 0.01 × 15 = 0.75. Some intermediate game states are shown above.

Your Task

You are provided with three files on Moodle:

.   sokoban.py : main code file for solving the Sokoban puzzle using A* search.

search4e.py : a slight modification of code in  search4e.ipynb in your AIMA library that implements various search algorithms. input0.txt : an example input instance.

Please place all three files in the same working directory. Your task is to fill in the blanks in sokoban.py so that the code reads in an input in the same format as  input0.txt and outputs a character string encoding the sequence of actions for solving the Sokoban puzzle. You only need to submit  sokoban.py , renamed using your candidate number according to the submission instruction below. Please do not modify code outside designated blanks in  sokoban.py and do not change  search4e.py , otherwise your submitted code may not run properly.




热门主题

课程名

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
联系我们
EMail: 99515681@qq.com
QQ: 99515681
留学生作业帮-留学生的知心伴侣!
工作时间:08:00-21:00
python代写
微信客服:codinghelp
站长地图