I am very new to python and this forum :) I have been struggling with dictionary and can really use some help.
For my question, the Input is:
frontier = [
{ 'state': (2, 5, 4, 3, 0, 1), 'path': [ 'PULL' ] },
{ 'state': (2, 4, 5, 0, 3, 1), 'path': [ 'SWAP','PULL' ] },
{ 'state': (2, 5, 4, 0, 1, 3), 'path': [ 'SWAP' ] },
{ 'state': (2, 0, 5, 4, 3, 1), 'path': [ 'PUSH', 'PUSH' ] },
]
We are told that the assigned value of each action:
- PUSH: 5
- PULL: 6
- SWAP: 8
FLIP: 2
eg. if [ push, swap] = 5+8
For this question, every state has an assigned value (heuristic) that I have calculated.
However, calculating the value of actions has me stumped. I have tried coding by splitting the item['path'] but the list it creates cannot be used. I have no idea how to approach this.
I want to make a list for the action. For the above question, it will look:
[6, 14, 8, 10]
Can someone please tell me how it can be achieve with explanation and code for the given example?