Consider a collection of blocks and several tables. A block A can be in the box or on
one of the tables at a given time. While on a table, a block A can be on the surface of the table or
on top of another block B. The following actions are possible:
put a block A on a table;
put a block A on top of a block B.
Note that putting a block on a table is possible if the block is in the box or on top of another block
on the same table. As well, putting a block on top of another block requires the former block to be
on the same table as the latter. Finally, there is a limit to the number of blocks one can have on
the surface of a given table.
Your task is to write a Julia program that fulfils the following functionality:
accepts a user input that defines the world (how many blocks and how many tables) and a
goal (final layout of blocks on the tables) and generates a plan1
to achieve the goal;
accepts a user input that defines the world, a goal and the current configuration (the current
layout of blocks on the tables) and generates a plan to achieve the goal.
Can you be a little more specific on how you are lost? Are you having trouble finding good Julia tutorials? Which other language you know? The problem is the datastructures for the problem? Reading input from the terminal?
Your best chance of getting help on this forum is showing some work, explaining where you got stuck, and asking specific questions with code.
I am assuming that you got some kind of introduction to Julia programming in this course. Also, there may be local resources you can turn to to get started, eg a TA. I would try those first.
Thanks for your feedback.
I am a new bie in Julia. I have knowledge of C#. my main challenge is implementing the Algorithms like Say the Markov Process or BFS to solve the problem.
Yes, i have started with some code will soon post the here for further assistance.
Could possibly share a link to the TA.I? thanks a million for your support
Hi, so i have tried to prompt the tables and the blocks from the user and now am stuck with how to implement the preconditions, and the goal. Also, i have attempted to write the depth Search to fit my scenario but some how am stuck . Here is my code
using Statistics
using Random
println(“-----------------------”)
println(“- BLOCK WORLD PLANNER -”)
println(“-----------------------”)
print(“”)
function initialState()
#prompt number of tables
print("Enter number of tables : ")
teb = chomp(readline())
global num_tables = parse(Int, teb)
#Collection to store tables in array
global tableCollection = Array{String}(undef, num_tables)
for i ∈ 1:num_tables #
println()
print("Enter Table $i : ")
tableCollection[i] = chomp(readline()) #prompt tables
println()
end
println("#####################################")
print("Enter number of Blocks: ")
blc = chomp(readline())
global num_blocks = parse(Int, blc)
global blockCollection = Array{String}(undef, num_blocks)
for i ∈ 1:num_blocks
println()
print("Enter Block $i : ")
blockCollection[i] = chomp(readline()) #blocks
end
#return tableCollection,blockCollection
In Julia, you typically don’t write objectA.function(objectB). (You could write that, but only if you have a reason to store a function in an object.)
The normal Julia syntax would be function(objectA, objectB). The first argument does not play any special role in Julia like it does in many object oriented languages.
In your specific case the code currentState.isGoal(goalState) should therefore probably read isGoal(currentState, goalState). However, it seems the function isGoal is not yet defined in your code.
Also, to make your code look nice, put tripple backticks around it in your post, like this:
```
function foo(x)
sqrt(5x)
end
```
This will make it show up with syntax highlighting
So i came out with this approach of prompting all the blocks and tables from the keyboard and store them in some random arrays which can act as an initial state or problem and later the goal is to have this blocks arranged in tables in an alphabetical order using Backward Search the program should make all the preconditions true using backwards checking and , then it will use forward checking to get to the goal state.
Hi guys as i explained above, the function initialState prompts the tables and blocks from the keyboard and store them in array and later define the goal State of how the blocks were suppose to be arranged on tables.
now i would like to implement backtracking(Depth First search ) and fowardtraking (Breadth First search ) algorithms to get to the goal defined in the initialState functions any help on how i should implement this algorithms in julia? and also i would lie to have the following preconditions to be evaluated to true to guide my program
‘’‘[“clearTable”,“pickUp”,“putInBox”,“putOnTable”,“putOnTop”,“moveToTable”,“on”]’‘’
#prompt number of tables
print("Enter number of tables : ")
teb = chomp(readline())
global num_tables = parse(Int, teb)
#Collection to store tables in array
global tableCollection = Array{String}(undef, num_tables)
for i ∈ 1:num_tables #
println()
print("Enter Table $i : ")
tableCollection[i] = chomp(readline()) #prompt tables
println()
end
println("*************************************")
print("Enter number of Blocks: ")
blc = chomp(readline())
global num_blocks = parse(Int, blc)
global blockCollection = Array{String}(undef, num_blocks)
for i ∈ 1:num_blocks
println()
print("Enter Block $i : ")
blockCollection[i] = chomp(readline()) #blocks
end
#return tableCollection,blockCollection
println("*********************************************")
println("** Initial state configuration of blocks **")
println("*********************************************")
for i ∈ 1:num_blocks
println(blockCollection[i])
end
println("")
println("***********************")
println("** Number of tables **")
println("***********************")
for i ∈ 1:num_tables
println(tableCollection[i])
end
println("**********************")
println("")
println("*******************")
println("** Goal state ***")
println("*******************")
goalState = sort!(blockCollection)
print(goalState)
println("****************")
end```
I would suggest you break up your problem to a small set of functions manipulating the state of the world and the planner, each doing one little thing, and then test and develop with variables that represent inputs, and see if they return the desired output, and then combine them.
Reading user input from the command line is probably the last thing I would write.
This is not my field so I am sorry but I cannot help with the specifics, but if I wanted to learn classic AI in Julia, I would just implement everything in
Norvig, Peter. Paradigms of artificial intelligence programming: case studies in Common LISP . Morgan Kaufmann, 1992.
in Julia (using Vectors for flat lists, and other appropriate structures instead of CONSes, but the algorithms are pretty easy to port).
I am curious what resources you were assigned for this course, can you link the course website or a syllabus?