Skip to main content

Here is a question for you: "How complex a business process can be solved by Nintex Workflow Cloud?", well I think I do have an interesting answer for that, it solves business processes that is as complicated as the famous Farmer-Wolf-Goat-Cabbage cross a river puzzle. 

 

There are many programming languages out there, everyone will have its own strengths and focuses. You might find it easy to solve the old classic puzzle such as the "Farmer-Wolf-Goat-Cabbage cross a river" with much lesser code in Prolog or Lisp that is associated with Artificial Intelligence than a Java program. It will be interesting to find out solving the same puzzle without even writing a piece of code with Nintex Workflow Cloud.

 

For those who have not came across the "Farmer-Wolf-Goat-Cabbage cross a river" puzzle, you could simply do a search on the web to find enough article and solution for it. This is just a perfect puzzle trying to understand a real world business process is, it has: 

 

Objective:

  • To move all the objects (Wolf, Goat, and Cabbage) across a river

Rules: 

  • Wolf and Goat are not to be left alone
  • Goat and Cabbage are not to be left alone
  • Only farmer roars the boat
  • Farmer can only bring one object at a time

 

Let us define the required terminology or object(s) we can apply to our workflow design,

Terminology Description
fromBank The river bank where all the objects of Farmer, Wolf, Goat, and Cabbage are
toBank The destination river bank where all the objects to be moved to
F, W, G, C The acronyms representing Farmer, Wolf, Goat, and Cabbage
fromBank=>"F","W","G","C"] The initial state represents all the objects are at the fromBank river bank
riskState=r"WGC","GC","CG","WG","GW"] Sets of states both fromBank and toBank is at risk
toBank=;] The initial state represents none of the objects are on the toBank river bank
Embarkation, Disembarkation, ReturnTrip Represent three movement stages of forward movement from fromBank to toBank, disembarking of object to the toBank, and return trip with object to be brought back to the fromBank.

 

 

Algorithm:

  1. Initialize objects for:
    • fromBank=lF,W,G,C],
    • toBank= ],
    • embark farmer to boat (i.e. fromBank=eW,G,C]),
    • riskState,
    • etc.
  2. Start a loop until toBank=nF,W,G,C], 
    1. Embarkation Branch (i.e. always assuming to start with embarking an object to the boat)
      1. Check if we suppose to embark an object or return an object, if return object, change to ReturnTrip Branch. else continue
      2. try to embark the first Item from fromBank collection
      3. Verify if fromBank is "at risk" state by checking against the riskState collection
      4. If "at Risk" is true, revert the embarked item back to the fromBank collection's back of the queue, exit branch
      5. if "at Risk" is false, remove the Item from the fromBank, switch to Disembarkation branch
    2. Disembarkation Branch (i.e. this stage is always followed from Embarkation branch)
      1. Try to disembark the object to toBank
      2. If toBank items count is equal to the total object, the goal has achieved
      3. if toBank items count is less than 2, toBank is at Safe state, farmer go back alone to Embarkation stage (i.e. set variable returnTrip=false)
      4. if toBank is "at Risk" state, farmer need to go back bringing one item to avoid "at Risk" state of toBank (i.e. set variable returnTrip=True)
    3. ReturnTrip Branch
      1. Disembarkation was always done at the Disembarkation Branch by disembarking item to the back of the toBank collection queue
      2. We will try to return the first item from the toBank, and verify if the remaining left alone safe?
      3. Loop through to get an item to be returned avoiding the conflicts at toBank
  3. Exit of loop (i.e. mission completed), sending the log of the movement result.

 

You may see the demo by submitting the Public Form at the following URL FWGC Cross the river puzzle form , which you will need to supply an email to receive the result, and the object sequence in the format of e.g. "F,W,G,C", "W,F,C,G", etc. to get different movement results. Here is the example of the form:

197491_pastedImage_2.png

Note: Nintex Workflow Cloud do not currently support validation of the public form, you will need to fill in a valid email to receive the response, and right syntax for the FWGC Sequence field.

 

Here is a sample email content you will be getting from the submission of the above form:

 

Please find below the movement required to move all the objects from fromBank to toBank (i.e. each --> denotes the beginning of a line)

 

--->Initialized: fromBank = i"F", "W", "G", "C"], ristState = G"WGC", "GC", "WG", "CG", "GW"], toBank = "], initStateCount = 4, --->Embark W: fromBank = ;"G", "C"], toBank = ], atRisk = true, --->Revert W: fromBank= t"G", "C", "W"], toBank=G], --->Embark G: fromBank = ;"C", "W"], toBank = ], atRisk = false, --->Disembark G: fromBank = s"C", "W"], toBank = "G"], embark option in return trip= false, --->Embark C: fromBank = ;"W"], toBank = a"G"], atRisk = false, --->Disembark C: fromBank = s"W"], toBank = a"G", "C"], embark option in return trip= true, --->Return trip with G: fromBank = i"W", "G"], toBank = "C"], --->Embark W: fromBank = ;"G"], toBank = a"C"], atRisk = false, --->Disembark W: fromBank = s"G"], toBank = a"C", "W"], embark option in return trip= false, --->Embark G: fromBank = 😉, toBank = o"C", "W"], atRisk = false, --->Disembark G: fromBank = s], toBank = o"C", "W", "G"], embark option in return trip= false

 

Completed State:

fromBank = n]

toBank = r"C", "W", "G"]

 

This exercise helps me with list of Asks on features and enhancements that I am looking forward to, I have most of them logged to the uservoice, here are some of them:

1. There is currently no way to construct a rich text variable with formatting I want, so I could compose the "Send email" action's body by inserting a formatted string/rich text variable at the final stage. (i.e. the email content in the above example will be more readable if I could insert a formatted text of the below example:

--->Initialized:           fromBank = d"F", "W", "G", "C"], ristState = "WGC", "GC", "WG", "CG", "GW"], toBank = ]

--->Embark W:        fromBank = ;"G", "C"], toBank =  ], atRisk = true,

--->Revert W:          fromBank= &"G", "C", "W"], toBank= ],

--->Embark G:         fromBank = ""C", "W"], toBank = ], atRisk = false,

--->Disembark G:    fromBank = 0"C", "W"], toBank = a"G"], embark option in return trip= false,

--->Embark C:         fromBank = 0"W"], toBank = m"G"], atRisk = false,

--->Disembark C:    fromBank = l"W"], toBank = -"G", "C"], embark option in return trip= true,

--->Return trip with G: fromBank = r"W", "G"], toBank = t"C"],

--->Embark W:         fromBank = l"G"], toBank = -"C"], atRisk = false,

--->Disembark W:    fromBank = f"G"], toBank = 6"C", "W"], embark option in return trip= false,

--->Embark G:         fromBank = f], toBank = 3"C", "W"], atRisk = false,

--->Disembark G:    fromBank = r], toBank = o"C", "W", "G"], embark option in return trip= false

 

2. Import / Export of workflow design. I will be able to share my workflow design once the feature is available for me to export my workflow and attach it to this blog for sharing..

 

3. Print workflow design, and Save as.. to export workflow design as JPG, PNG, etc.

 

4. As I am using a lot of Collection operation for the exercise, there is a long list of collection operations I am looking for that is missing for the time being, the challenge results a workflow with additional actions to solve simple issue, here are some of the features that I think is missing:

  • Copy a collection from one to the other
  • Store Item for "Remove Item from Collection" action
  • Compare if two collections are equivalent
  • Dictionary variable
  • Concatenate collection items into string

 

5. Other features such as Log history action, Workflow constant, Go-to node action, sub workflow and/or grouping of actions.

 

Until my workflow could be exported for sharing, the best I could do for the time being is the captured design of the workflow solving the Farmer-Wolf-Goat-Cabbage puzzle.

Great read!


HA! This is awesome! Thanks for the different approach.

I have tossed around ideas for "other uses" with Nintex and have a few things I want to try; this might be my motivation


Cool! great to hear that it motivates you.

Get Outlook for iOS<https://aka.ms/o0ukef>


I really like this post. It must have been an interesting journey to think about the logic and then converting it to a workflow. Great that you also added uservoice ideas.


Reply