Find the highest value in the grid Loop do: If current square (node) is the goal: end loop From initial square, find all neighbors of current square Calculate probabilities associated with each neighbor (neighbor.square/highest value) Pick the highest probability Move to the next square (node) with that probability
Current node: 1 Neighbors are 2, 4 and 5 Probabilities = {0.22: 2, 0.44: 4, 0.56: 5} Next node = 5
Current node: 5 Neighbors are 1,2,3, 4, 6,7,8,9 Probabilities = {0.11: 1, 0.22: 2, 0.33: 3, 0.44: 4, 0.67: 6, 0.78: 7, 0.89: 8, 1: 9} Next node: 9
Current node: 9 End loop
1. start at initial location 2. look at neighbours (left, right, up, down) 3. calculate probabilities - sum (S) up the neighbouring location values (V) - assign probabilities using V/S in discovery order - so if we always discover squares in left, right, up, down order and say the probabilities are 10, 40, 30, 20, then numbers 1-10 are for left, 11-50 are for right, 51-80 are for up, 81-100 are for down 4. move to next location - use a random number generator to find which location to move to - say for example we get 55 as our random number - based on this we would move UP
-------
simulation
9 8 7 6 5 4 3 2 1@
turn 1:
step 1: initial location is not the max step 2: neighbours = up, left step 3: sum = 6 probability assignment based on discovery order so 2/6 = 0.33 = 33 -> 1-33 mapped to left 4/6 = 0.667 = 67 -> 34-100 mapped to up
step 4: get a random number (google) = 45 move up new current location = 4
turn 2:
step 1: current location 4 is not the max step 2: neighbours = left, up, down step 3: sum = 13 probability assingment: left = 5/13 = 0.38 -> 1-38 mapped to left up = 7/13 = 0.54 -> 39-92 mapped to up down = 1/13 = 0.08 -> 93-100 mapped to down
step 4: random number (google) = 70 move up new current location = 7
continue until you reach 9(Edited: 2022-09-21)
- Sum the utility of local adjacent nodes - while summing each node, check for local maximum state - if local maximum return current state - assign different ranges between zero and Sum to each node with the size of the range proportional to the utility of the local node ex: N1:2 N2:5 N3:4 -> sum = 11 N1 range[0,2], N2 range(2,7], N3 range(7,11] - generate a random number between zero and sum - move to the node with the range including the randomly generated number - repeat until return for local maximum
Simulation to be continued
2 / 6 4 / 6
5 / 12 7 / 12
6 / 14 8 / 14
9 / 9 = 1
Pass the goal test.
I would set up my algorithm to look at the potential neighbors we could move to. I would add the value of the neighbor to the manhattan distance to the goal state. I would divide each value by 9 then select the highest probability of the neighbors. If the values are the same select the neighbor with the lowest manhattan cost to distance. The first move would evaluate 2,4,5=> probabilities 5/9, 7/9, 7,9 neighbor 5 is selected since its manhattan distance to the goal state is the smallest. next the algorithm evaluates neighbors 1,2,3,4,6,7,8,9 => probabilities 5/9, 5/9, 5/9, 7/9, 7,9, 9/9, 9/9 since 9 is the goal state its manhattan distance is 0 so we select the square with 9 to move to and we have reached our goal.
Look at the number of choices and give every move a base value. Ex. 2 possible space --> 50% base; 3 possible --> 33% base, 4 possible --> 25% base. Then look at all the spaces to find the largest and smallest number. The space with the smallest number has its chance halved, with the difference being added to the space with the largest number. Nothing occurs to the other spaces. Running the algorithm by hand: Start at 1: Neighbors --> 2, 4 Chance for 2 --> 50% / 2 = 25% Chance for 4 --> 50% + 25% = 75% Dice Roll: 0.48 --> Move to 4 Start at 4: Neighbors --> 1, 5, 7 Chance for 1 --> 33% / 2 = 16% Chance for 5 --> 33% Chance for 7 --> 33% + 16% = 49% Dice Roll: 0.11 --> Move to 1 Start at 1: Neighbors --> 2, 4 Chance for 2 --> 50% / 2 = 25% Chance for 4 --> 50% + 25% = 75% Dice Roll: 0.60 --> Move to 4 Start at 4: Neighbors --> 1, 5, 7 Chance for 1 --> 33% / 2 = 16% Chance for 5 --> 33% Chance for 7 --> 33% + 16% = 49% Dice Roll: 0.64 --> Move to 7 Start at 7: Neighbors --> 4, 8 Chance for 4 --> 50% / 2 = 25% Chance for 8 --> 50% + 25% = 75% Dice Roll: 0.45 --> Move to 8 Start at 8: Neighbors --> 5, 7, 9 Chance for 5 --> 33% / 2 = 16% Chance for 7 --> 33% Chance for 9 --> 33% + 16% = 49% Dice Roll: 0.60 --> Move to 9 Done
One thing to do is we can have the agent choose from the nodes in an upward or sideways direction(left or right depending on which direction is closer to the goal node). Then the agent would choose the maximum value within this group of nodes. Simple equation: f = n1 - n where n1 is a child or potential move and n is value of current node.
step 1: curVal = 0 Choices = [1] Choose 1 step 2: curVal = 1 Choices = [2, 4, 5] Choose 5 (5 - 1 = 4) step 3: curVal = 5 Choices = [6, 8, 9] Choose 9 (9 - 5 = 4) Done(Edited: 2022-09-21)