Foolish and Hungry
Foolish and Hungry

Reputation: 66

How to get the functionality of break in PDDL forall

I am trying to solve the Light Up puzzle using PDDL. To implement the effect of the action placing a bulb in a cell, I have to place a bulb in (x, y) and then lit up the same row and column as long as there is no black cell. I am unable to lit up the cells till the black cell.

For example, for a 5*5 grid, if I want to place a bulb at (0,1) and there is black cell at (3, 1), I would want to lit up only cells (0,1), (1,1), (2,1) if I am only considering the column. But I would not want to lit up cell (4,1) as it is after the black cell.

So, if I use something like forall, how would I break the for all loop when it finds a black cell on it's way in a row/column?

Upvotes: 2

Views: 421

Answers (1)

David Speck
David Speck

Reputation: 83

I think it would be worth taking a look at axioms and derived predicates in PDDL. This makes it possible to build the transitive closure and derive information from other variables.

In fact, you can derive which cells have light from the information of the grid structure (which cells are black) and the light bulbs. So you can define a derived predicate lit((x,y)) for each cell and write a background theory with axioms:

  • lit((x,y)) <= bulb((x,y))
  • lit((x,y)) <= lit((x',y')) and connected((x,y),(x',y')) and ~black((x,y))

The goal formula would probably be something like: "lit((0,0)) and ... and ... lit((n,m))" for all cells that are not black.

Upvotes: 2

Related Questions