The code must be in phyton
The objective of the exercise is to try to solve the problems of Sokoben under partial knowledge.
The principle of the game is that the player must push all the objects (called boxes) to different destinations in the usage maze. The player must fill all the targets in the boxes in the maze.
Use minimal movement. Unlike the first exercise, in which the agent had full knowledge of the state of the world, The knowledge that the agent has of the state of the world is partial parts of the world.
The agent is the player carton.
The agent input is the initial state of the world, an NxM (a size matrix which the entries in the matrix indicate the initial state of the objects in it) game board. The game board consists of NxM slots and contains 5 types of objects: wall, player, crates, targets and ice. The role of each one will be detailed below.
The purpose of the game is to put all the crates in all the targets without an urgency to a specific target. Therefore, you can put any crate in any target.
Note- There’s can be more crates than target, but the game finish when all the targets have crates on them.
The ice tiles are hidden from the agent. The agent can move on the game board in the directions up, down, right, left, provided that there is no wall in the square to which it is moving. The agent can move the crates along with his movement. You can only push one crate at a time, and you can not pull them.
you can not tell where the ice is, without taking action to uncover it. Therefore, you can not make a plan to solve each exercise in advance, and you will have to decide on the next action after receiving observations on the state of the world after an earlier operation.
Note- in the initial state a cart can stand on an ice tile.
I’m attachoing links to the game:
This exercise is accompanied by a test code that holds the true state of the world (which your agent can not access directly), that transfer the state of the partial world to the class SokobanController that you need to implement. In that class you need to implement the function get_next_action
Which receive the latest state of the world, and returns one of the four allowed operations - "U", "D", "L", "R"
the partial knowledge: in every input that class SokobanController will receive the agent will not be able to distinguish between empty tiles and tiles with ice (both will receive the same numeric code – 10, 17,15, depending on the objects in the tile). The only way to detect an ice is to operate an action (eg walk or push a crate) towards the tile in the desired direction and deduce if it’s an ice tile based on the result of this action. (which you can see in the input for the next action).
Finally, the goal is to bring the system to a goal position where all targets are covered by crates with minimum steps as possible.
You must use The attachment file ex2.py that contains the function signatures you need to implement.
The input to constructor and to get_next_action is the MxN matrix With every entry
represents an object found in the relevant tile.
The meaning of the cell content values is:
· 99- wall
· 10- a tile that looks empty
· 15 – a crate stands on a tile that looks empty
· 17- agent on a tile that looks empty
· 20- target
· 25- target with a crate on it
· 27 - target with an agent on it
When a square that looks empty can be a regular blank slot or a slot with ice.
Note – you can add and subtract 7 or 5 if you want to update the tile number. An easy way to solve the update.
Mode and legality of movement
The movement on a tile that appears empty is carried out according to its true type.
you have 4 actions of the player:
• Move right - Display by string "R"
• Move down - Display by string "D"
• Left shift - Display by "L"
• Move up - Display by string "U
Each action causes the player to move from one tile in the desired direction.
· Moving to an empty tile will take the player to her
· Move to a tile that has a wall is allowed, but the action will not change the game mode.
· There is an ice when the agent himself move to a tile with ice, he slides till he stopes. 1.He stopes when there is ice and then a wall, here he stands on the tile with the ice next to the wall.
2. He stopes when there is ice and then two crates or one crate and a wall, here he stands on the tile with the ice next to the crate.
3. He stopes when there is ice and then an empty tile, here he stands on the first empty tile after the ice.
· Another case is the agent push a crate to an ice tile, the crate slides to on the ice till it’s stopes and the agent move an empty tile where the crate was. The crates stop when there is: 1. Another crate after the ice. (a crate can’t move another crate), then the crate stands on the ice tile
2. a wall, then the crate stands on the ice tile next to the wall
3. an empty tile then the crate stands on the empty tile.
Packages that you can use
Only packages that are in the Python standard library are allowed.
You can not use threading , although it’s in the standard library.
you can not import a files: inputs.py or checker.py
You can not access the real map.
A brief explanation of the code provided
The code consists of 4 Python files:
1. ex2.py - in that file you do the main work. This is the only file you can change. That file should contain the class SokobanController that contains the function get_next_action.
2. checker.py - the file contains the test code, that in every call to get_next_action transform it the map with the hidden ice.
3. inputs.py- the file contains different maps
4. utils.py- A reference file that contains many functions that you may see as usefu
Test the exercise
The exercise will be automatically checked, so it is important to keep accurate names of files, classes, and operations.
The test will be performed by running checker.py file
end time that the program should stand in: constructor- ends within 60 sec and get_next_action- ends within 5 sec.
Also, every run of the code from start to finish should be completed within
Steps. Also N and M are the dimensions of the matrix that you receive as input.
Please download all prints before submitting the exercise! (please send me a version with and without prints so I can test if it works, you can send it to me without prints just after I aprroved it works as expected)
Don’t use another helping files
Don’t change the format of the files