All Downloads are FREE. Search and download functionalities are using the official Maven repository.

APT.Arithmetic-smem.arithmetic.generate-problem.soar Maven / Gradle / Ivy

## Generates problems
## For now only generates 3 column addition problems

sp {arithmetic*propose*generate-problem
   (state  ^name arithmetic
             -^arithmetic-problem
              ^digits.complete true
             -^count 0)
-->
   ( ^operator  + =)
   ( ^name generate-problem)
}


# Terminated in generate-problem/finish-problem-generation


###########################################
## If have a current-problem (pre-generated) in working memory

sp {generate-problem*apply*generate-problem
   (state  ^operator.name generate-problem
              ^current-problem )
   ( ^top-number  ^bottom-number )
-->
   ( ^top-number-1 (mod  10) ^top-number-10 (mod (div  10) 10) ^top-number-100 (mod (div  100) 10)
         ^bottom-number-1 (mod  10) ^bottom-number-10 (mod (div  10) 10) ^bottom-number-100 (mod (div  100) 10))}

sp {generate-problem*apply*generate-operation*addition
   (state  ^operator.name generate-problem
              ^current-problem 
              ^digits.digit      )
   ( ^operation addition
         ^top-number-1  ^top-number-10  ^top-number-100 
         ^bottom-number-1  ^bottom-number-10  ^bottom-number-100 )
   ( ^digit )
   ( ^digit )
   ( ^digit )
   ( ^digit )
   ( ^digit )
   ( ^digit )
-->
   ( ^arithmetic-problem 

) (

^operation addition ^operation-symbol |+| ^current-column ^one-column ) ( ^next-column ^digit1 ^digit2 ^column t) ( ^next-column ^digit1 ^digit2 ^column t) ( ^next-column nil ^digit1 ^digit2 ^column t)} sp {generate-problem*apply*generate-operation*subtraction (state ^operator.name generate-problem ^current-problem ^digits.digit ) ( ^operation subtraction ^top-number-1 ^top-number-10 ^top-number-100 ^bottom-number-1 ^bottom-number-10 ^bottom-number-100 ) ( ^digit ) ( ^digit ) ( ^digit ) ( ^digit ) ( ^digit ) ( ^digit ) --> ( ^arithmetic-problem

) (

^operation subtraction ^operation-symbol |-| ^current-column ^one-column ) ( ^next-column ^digit1 ^digit2 ^column t) ( ^next-column ^digit1 ^digit2 ^column t) ( ^next-column nil ^digit1 ^digit2 ^column t)} ####### If no problem - try retrieving the first from smem sp {generate-problem*apply*generate-problem*retrieve*first*problem*from*smem (state ^operator.name generate-problem ^smem.command -^current-problem ) --> ( ^query.problem 0)} sp {generate-problem*apply*generate-problem*use-retrieval (state ^operator.name generate-problem ^smem ) ( ^command ^result.retrieved ) ( ^query ) ( ^problem 0) --> ( ^current-problem )} ####### If problem not defined - try retrieving the rest of it from smem sp {generate-problem*apply*generate-problem*retrieve*from*smem (state ^operator.name generate-problem ^smem.command ^current-problem ) -( ^top-number ^bottom-number ) --> ( ^retrieve )}