This is very inspiring! I’ll be checking it out soon! as well as adding exponents and PEMDAS and do some long arithmetic with worded step by step descriptions. also here’s a standalone function that generates Geometry Questions of varying difficulty.

```
function cm.CreateGeometryQuestion(Num1,Num2,Shape)
-- Get the shapes table from the ReplicatedStorage
--local Shapes = game.ReplicatedStorage.Items.Shapes.Icons:GetChildren()
-- Pick a random shape from the Shapes table
--local Shape = Shapes[mathrandom(1, #Shapes)].Name
-- Define the opening phrases for the word problem
local Opening = {
"If I have a ",
"If I possess a ",
"So we have a ",
"So starting with a ",
"Imagine I have a ",
"Suppose I own a ",
"Let's say we have a ",
"Given that I start with a "
}
-- Define the phrases for each shape
local SquareConstruct = {
"square with side length of ",
"square with edge width of ",
"square with each side measuring ",
}
local RectangleConstruct = {
"rectangle with length of ",
"and a width of ",
}
local CircleConstruct = {
"circle with radius of ",
" with diameter of ",
}
local TriangleConstruct = {
"triangle with base of ",
"and a height of ",
}
-- Define the questions for each shape
local SquareQuestion = {
"What is the area of the square?",
"What is the perimeter of the square?",
}
local RectangleQuestion = {
"What is the area of the rectangle?",
"What is the perimeter of the rectangle?",
}
local CircleQuestion = {
"What is the area of the circle?",
"What is the circumference of the circle?",
-- "circumference"
}
local TriangleQuestion = {
"What is the area of the triangle?",
"What is the perimeter of the triangle?",
}
-- Define some random numbers for the dimensions
--local Num1 = mathrandom(1, 10)
--local Num2 = mathrandom(1, 10)
-- Pick a random phrase for the opening and the shape
local OpeningPhrase = Opening[mathrandom(1, #Opening)]
local ShapePhrase = ""
local QuestionPhrase = ""
if Shape == "Square" then
ShapePhrase = SquareConstruct[mathrandom(1, #SquareConstruct)] .. Num1 .. " units."
QuestionPhrase = SquareQuestion[mathrandom(1, #SquareQuestion)]
elseif Shape == "Rectangle" then
ShapePhrase = RectangleConstruct[1]..Num1.." units and "..RectangleConstruct[2]..Num2.." units."
QuestionPhrase = RectangleQuestion[mathrandom(1, #RectangleQuestion)]
elseif Shape == "Circle" then
ShapePhrase = CircleConstruct[mathrandom(1, 2)] .. Num1 .. " units."
QuestionPhrase = CircleQuestion[mathrandom(1, #CircleQuestion)]
elseif Shape == "Triangle" then
ShapePhrase = TriangleConstruct[1] .. Num1 .. " units and " .. TriangleConstruct[2] .. Num2 .. " units."
QuestionPhrase = TriangleQuestion[mathrandom(1, #TriangleQuestion)]
end
-- Calculate the answer by applying the formula to the numbers
local Answer = nil
if Shape == "Square" then
if QuestionPhrase == SquareQuestion[1] then -- area
Answer = Num1 * Num1
elseif QuestionPhrase == SquareQuestion[2] then -- perimeter
Answer = Num1 * 4
end
elseif Shape == "Rectangle" then
if QuestionPhrase == RectangleQuestion[1] then -- area
Answer = Num1 * Num2
elseif QuestionPhrase == RectangleQuestion[2] then -- perimeter
Answer = (Num1 + Num2) * 2
end
elseif Shape == "Circle" then
-- Define a function to calculate the circumference of a circle, given the radius
local function circumference(radius)
-- Use the formula C = 2 * pi * r, where C is the circumference, pi is a constant, and r is the radius
local C = 2 * math.pi * radius
-- Return the result
return C
end
if QuestionPhrase == CircleQuestion[1] then -- area
Answer = math.pi * Num1 * Num1 -- assuming radius
elseif QuestionPhrase == CircleQuestion[2] then -- circumference
Answer = circumference(Num1)--math.pi * Num1 * 2 -- assuming radius
end
elseif Shape == "Triangle" then
if QuestionPhrase == TriangleQuestion[1] then -- area
Answer = (Num1 * Num2) / 2 -- assuming base and height
elseif QuestionPhrase == TriangleQuestion[2] then -- perimeter
Answer = nil -- cannot be calculated without knowing all sides or angles
end
end
-- Format the word problem as a string and round the answer to two decimal places
local WordProblem = OpeningPhrase .. ShapePhrase .. " " .. QuestionPhrase
if Answer then
Answer = math.floor(Answer * 100 + 0.5) / 100 -- round to two decimal places
else
Answer = "Cannot be calculated"
end
-- Return the word problem and the answer as variables
return WordProblem, Answer
end
--Decode the Geometry question
function cm.InterpretGeometryQuestion(str)
local Answer=nil
local Shape
local Opening = {
"If I have a ",
"If I possess a ",
"So we have a ",
"So starting with a ",
"Imagine I have a ",
"Suppose I own a ",
"Let's say we have a ",
"Given that I start with a "
}
local RectangleConstruct = {
"with length of ",
"width of ",
}
local open=mathquery(str,Opening,false,true,false)
local square,rectangle,circle,triangle=nil,nil,nil,nil
local qsquare,qrectangle,qtriangle,qcircle
square=mathquery(str,SquareConstruct,true,true,false)
if not square then
rectangle=mathquery(str,RectangleConstruct,true,true,false)
if not rectangle then
print("Circle")
circle=mathquery(str,CircleConstruct,true,true,false)
if not circle then
triangle=mathquery(str,TriangleConstruct,false,true,false)
end
end
end
if square then qsquare=mathquery(str,SquareQuestion,false,true,false)
elseif rectangle then qrectangle=mathquery(str,RectangleQuestion,false,true,false)
elseif circle then
qcircle=mathquery(str,CircleQuestion,false,true,false)
elseif triangle then
qtriangle=mathquery(str,TriangleQuestion,false,true,false)
end
if square or rectangle or circle or triangle then
local score=0
local QuestionPhrase = nil
if open~=nil then score=score+1 end
if square~=nil and qsquare~=nil then
Shape="Square"
QuestionPhrase = qsquare
elseif rectangle~=nil and qrectangle~=nil then
Shape="Rectangle"
QuestionPhrase = qrectangle
elseif circle~=nil and qcircle~=nil then
Shape="Circle"
QuestionPhrase = qcircle
elseif triangle~=nil and qtriangle~=nil then
Shape="Triangle"
QuestionPhrase = qtriangle
end
local function SplitQuery(query, num1)
local parts = {}
-- Find index of first number in query
local num1Index = string.find(query, tostring(num1))
-- Get substring before number
parts[1] = string.sub(query, 1, num1Index - 1)
-- Get substring after number
parts[2] = string.sub(query, num1Index + 1)
return parts[1], parts[2]
end
local function GetNumber(query)
local Num1, Num2 = nil, nil
local identifers={"length","width","diameter","radius"}
local identifier=nil
local part1,part2=nil,nil
for word in string.gmatch(query, "%w+") do
if tonumber(word) then
if not Num1 then
Num1 = tonumber(word)
print(Num1)
part1,part2=SplitQuery(query,Num1)
identifier=mathquery(part1,identifers,false,true,false)
else
if identifier==nil then
identifier=mathquery(part2,identifers,false,true,false)
end
Num2 = tonumber(word)
print(Num2)
break -- stop after 2 numbers found
end
end
end
return Num1,Num2,identifier
end
local part1
local Num1,Num2,identfier=GetNumber(str)
-- Pick a random phrase for the opening and the shape
local OpeningPhrase=open
if OpeningPhrase==nil then OpeningPhrase= Opening[mathrandom(1, #Opening)] end
local ShapePhrase = ""
if Shape == "Square" then
ShapePhrase = square .. Num1 .. " units."
elseif Shape == "Rectangle" then
part1=mathquery(identfier,RectangleConstruct,false,true,false)
local part2
if part1==RectangleConstruct[1] then
part2=RectangleConstruct[2]
else part2=RectangleConstruct[1]
end
ShapePhrase = "rectangle "--rectangle
..Num1.." units and "
..part2
..Num2.." units."
elseif Shape == "Circle" then
part1=mathquery(identfier,CircleConstruct,false,true,false)
if part1==nil then
part1=circle
end
ShapePhrase = part1 .. Num1 .. " units."
elseif Shape == "Triangle" then
ShapePhrase = TriangleConstruct[1] .. Num1 .. " units and " .. TriangleConstruct[2] .. Num2 .. " units."
end
-- Calculate the answer by applying the formula to the numbers
local Answer = nil
if Shape == "Square" then
if QuestionPhrase == SquareQuestion[1] then -- area
Answer = Num1 * Num1
elseif QuestionPhrase == SquareQuestion[2] then -- perimeter
Answer = Num1 * 4
end
elseif Shape == "Rectangle" then
if QuestionPhrase == RectangleQuestion[1] then -- area
Answer = Num1 * Num2
elseif QuestionPhrase == RectangleQuestion[2] then -- perimeter
Answer = (Num1 + Num2) * 2
end
elseif Shape == "Circle" then
if QuestionPhrase == CircleQuestion[1] then -- area
Answer = math.pi * Num1 * Num1 -- assuming radius
elseif QuestionPhrase == CircleQuestion[2] then -- circumference
Answer = math.pi * Num1 * 2 -- assuming diameter
end
elseif Shape == "Triangle" then
if QuestionPhrase == TriangleQuestion[1] then -- area
Answer = (Num1 * Num2) / 2 -- assuming base and height
elseif QuestionPhrase == TriangleQuestion[2] then -- perimeter
Answer = nil -- cannot be calculated without knowing all sides or angles
end
end
if Answer then
Answer = math.floor(Answer * 100 + 0.5) / 100 -- round to two decimal places
Answer = OpeningPhrase .. ShapePhrase .. " " .. QuestionPhrase.." The answer is "..Answer.."."
else
Answer = nil
end
-- Return the word problem and the answer as variables
return Answer
else return nil
end
end
function mathquery(query,group)
local words=cm.splitString(query,true)
for i,v in group do
if string.match(query,v) then
-- print(v)
return v
end
end
local importance={"circle","square","rectangle","triangle"}
local geomclass={"area","circumference","perimeter","radius","height","diameter","length","width","base"}
-- for t,o in words do
--print(group)
for y,p in group do
local gwords=cm.splitString(p,true)
for i,v in importance do
local imp=false
for q,w in geomclass do
local geom=false
for t,o in words do
for tt,oo in gwords do
--words=cm.splitString(query,true)
if string.match(o,w) and string.match(oo,w) then
geom=true
end
if string.match(o,v) and string.match(oo,v) then
imp=true
end
if geom and imp then
print(v)
return p
end
end
end
end
end
end
```