Skip to content
dzpan0Public

About

Project I made for the Logic for Programming course at IST: Tents & Trees Solver.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

5 Commits

Folders and files

Repository files navigation

Overview

This was developed as part of the Logic for Programming (LP) course at IST-UL.

The objective was to implement a Prolog-based solver for the classic logic puzzle “Tents and Trees”.

This project leverages constraint logic programming and backtracking to automatically solve grid-based puzzles under strict logical constraints.

Data Representation

A puzzle is represented as:

  • (Tabuleiro, TendasPorLinha, TendasPorColuna)
    • Translated: (Table, TentsPerLine, TentsPerColumn)

Example:

([
[_, _, _, _, a, _],
[a, _, _, _, _, _],
[_, a, _, a, a, _],
[_, _, _, a, _, a],
[_, _, _, _, _, _],
[_, a, _, _, _, _]],
[2,1,2,1,1,1],
[3,0,1,1,0,3])

Symbols:

  • a → tree
  • t → tent
  • r → grass
  • _ → empty cell

Usage

  • Using puzzle from the auxiliary file ``puzzlesAcampar.pl`
?- puzzle(6-14, P), resolve(P).
  • Manually inserting data
?- P = ([
[_, a, _, a, _, _],
[a, _, _, _, _, _],
[_, _, _, _, _, _],
[_, _, a, a, _, _],
[_, _, _, _, _, _],
[_, a, _, _, a, _]],
[3, 0, 1, 1, 1, 1], [2, 1, 1, 1, 2, 0]), resolve(P).
  • Output
P = ([[t,a,t,a,t,r],
      [a,r,r,r,r,r],
      [r,r,r,t,r,r],
      [r,t,a,a,r,r],
      [r,r,r,r,t,r],
      [t,a,r,r,a,r]],
     [3,0,1,1,1,1],
     [2,1,1,1,2,0]).

Technologies

About

Project I made for the Logic for Programming course at IST: Tents & Trees Solver.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages