This program simulates a intersection in Prolog.
#####al v . #####
. . . .
cy v . . .
#####. . #####
al: north, straight
cy: west, right
al: blocked(straight,right_present)
cy: ok(right)
?- list_right_of_way.
al: blocked(straight,right_present)
cy: ok(right)
true.
- SWI - Prolog: https://www.swi-prolog.org/
- Visual Studio Code: https://code.visualstudio.com/
- type
cmdin Windows search box - type
cd <folder with downloaded code>\prolog-intersection-simulation - type
"C:\Program Files\swipl\bin\swipl-win.exe" --win_app -q -s "%CD%\main.prolog"
- open
<folder with downloaded code>\prolog-intersection-simulationinVisual Studio Code - select
main.prolog - press
CTRL + SHIFT + Bto run task:- starting current file with
C:\Program Files\swipl\bin\swipl-win.exe
- starting current file with
Note:
Path to SWI-Prolog can be changed in .vscode\tasks.json,
see "command": "C:\\Program Files\\swipl\\bin\\swipl-win.exe"
Call help. for listing available commands.
Call simulate. for automated control of the cars.
Call step. for stepwise clearing.
Adding or removing cars manually e.g. add_random_car. or clear_cars.,
need call to draw_grid_xpce or draw_grid to see changes.