Support

If you have a problem or need to report a bug please email : support@dsprobotics.com

There are 3 sections to this support area:

DOWNLOADS: access to product manuals, support files and drivers

HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects

USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here

NEW REGISTRATIONS - please contact us if you wish to register on the forum

Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright

Training A.I. to understand FS RUby

For general discussion related FlowStone

Training A.I. to understand FS RUby

Postby billv » Tue Jan 27, 2026 8:50 pm

I was working on a bouncing ball and I was using ChatGBT to help me write the code. It took me the whole day,
ChatGBT had about 30 attempts before we got it right. ChatGBT is very smart, but with FSRuby, it's really dumb.
And to make things worse, if you start a fresh chat, it does not remember any previous chats.
The solution was simple, i told Chat to go through the entire thread, collect all stuff it learnt
that it didn't know, compress it all down to one rubyedit, so I can then copy and paste into new chats,
thereby giving ChatGBT a FSR code BRAIN, saving a shitload of time. I wasn't really happy with the result.
So after seeing the potential, I decided to this properly.
I uploaded a shitload of FSR Code. The Ai is behaving perfectly, taking only the logic that it needs,
and then breaking down everything that it learns.
The end result, is one simple rubyedit, filled with lots of FSR code, that ChatGBT, dosn't know.
Just Paste the rubyedit into the start of your chat, and WHAM!...your A.I. is now FSRuby smart.
I Tried it with Conways game of life...took 3 attempts but it worked. Download at Discord.
Code updated 31/1/26
Code: Select all
# ============================================================
# FSR BRAIN – MASTER RUBYEDIT
# Ruby + FlowStone Runtime + Graphics + UI
# ============================================================


# ============================================================
# PILLAR 1 – CORE RUBY LANGUAGE (COMPUTATION ENGINE)
# ============================================================

# Arrays
@a = []
@a = Array(0..10)
@a << 5
@a[3]
@a[2..5]
@a.shuffle!
@a.sample
@a.uniq
@a.include?(3)

# Loops
10.times do |i|
end

for i in 0..10
end

x = 0
while x < 10
  x += 1
end

until x == 0
  x -= 1
end

# Enumeration
@a.each do |v|
end

@a.map { |x| x * 2 }
@a.select { |x| x > 5 }
@a.inject(:+)

# Hashes
@h = {}
@h[:score] = 10
@h["name"] = "CPU"

# Conditionals
if x > 10
elsif x < 5
else
end

case x
when 0
when 1
else
end

# Math
rand(0..10)
Math.sin(x)
Math.cos(x)
(x - y).abs
[x,1].min
[x,1].max

# Strings
"Score: #{@score}"
str = "hello world"
str.length
str.split
str.upcase

# Methods
def myMethod(a,b)
  return a + b
end

# Object state
@counter = 0
@counter += 1
@array = @array || []

# LOCKED TRUTH:
# Any algorithm that works in Ruby
# works inside FlowStone Ruby.
# FlowStone Ruby is computationally complete.


# ============================================================
# PILLAR 2 – FLOWSTONE RUNTIME (EVENT + TIME ENGINE)
# ============================================================

def init
  @count = 0
  @running = false
end

def event(i, v, t)
  if i == 0
    @count = 0
    @running = true
    output 0, "START"
  end

  if i == 1
    @running = false
    output 0, "STOP"
  end
end

# Scheduling
def tick
  return unless @running
  @count += 1
  output 1, @count
  scheduleMethod('tick', time + 0.1)
end

# Watchers
watch @count

# FlowStone timing model:
# - event(i,v,t) = entry point
# - time = global clock
# - scheduleMethod(name, future_time)
# - watch variable triggers when changed
# - everything is event-driven


# ============================================================
# PILLAR 3 – UI / GRAPHICS / INPUT ENGINE
# ============================================================

# ---- Bitmap Button Logic (from your code) ----

def event(i, v)
  if (i == 'iDisable')
    output('oState', v ? 'disabled' : '')
  end
end

def isInMousePoint(x, y)
  return true
end

def mouseEnter
  return if (@oState == 'disabled')
  @over = true
  output('oState', 'over') unless (['down'].include?(@oState))
end

def mouseLeave
  return if (@oState == 'disabled')
  @over = false
  output('oState', '') unless (['down'].include?(@oState))
end

def mouseLDown(x, y)
  return if (@oState == 'disabled')
  @down = true
  captureMouse
  output('oState', 'down')
  trigger unless (['Up'].include?(@iMode))
end

def mouseLUpCaptured(x, y)
  return if (@oState == 'disabled')
  @down = false
  clearEvents
  releaseMouse
  output('oState', @over ? 'over' : '')   
  output('oTrigger', nil) if (['Up'].include?(@iMode))
end

def trigger
  return if (@oState == 'disabled')
  return unless (@down)
  output('oTrigger', nil)
  scheduleMethod('trigger', time + 0.5) if (['Repeat'].include?(@iMode))
end


# ---- Drawing Model (conceptual – draw v) ----
# (based on your previous drawing uploads)

def draw(v)
  # v is the graphics context
  # Typical operations:
  # v.clear
  # v.penColor = [r,g,b]
  # v.brushColor = [r,g,b]
  # v.rectangle(x1,y1,x2,y2)
  # v.circle(x,y,r)
  # v.line(x1,y1,x2,y2)
  # v.text(x,y,"Hello")
end

# FlowStone Graphics Truth:
# draw(v) gives a drawing context.
# You CAN draw:
# - rectangles
# - circles
# - lines
# - text
# - sprites
# - bitmaps
# There is a real drawing API.


# ============================================================
# REAL GAME LOGIC EXAMPLE (YOUR MANILLA CORE)
# ============================================================

def init
  output 9,0
end

def event i,v,t

if i == 0 then
  @count=0
  (@joker==false )?(@deck=31):(@deck=32)
  output 0,"WELCOME TO MANILLA"
  output 9,0
  @a = Array(0..@deck)
  @a.shuffle!
  @b=[]
  @deck.times do|x|     
    @b[x]= 0 if @a[x]==33
    @b[x]= 7 if [0,8,16,24].include?(@a[x])
    @b[x]= 8 if [1,9,17,25].include?(@a[x])
    @b[x]= 9 if [2,10,18,26].include?(@a[x])         
    @b[x]= 10 if [3,11,19,27].include?(@a[x])
    @b[x]= 11 if [4,12,20,28].include?(@a[x])
    @b[x]= 12 if [5,13,21,29].include?(@a[x])
    @b[x]= 13 if [6,14,22,30].include?(@a[x])
    @b[x]= 14 if [7,15,23,31].include?(@a[x])
    @b[x]= 15 if [32].include?(@a[x])                                                   
  end 

  @clubs=Array.new(8,"Clubs")
  @Spades=Array.new(8,"Spades")
  @Hearts=Array.new(8,"Hearts")
  @Diamonds=Array.new(8,"Diamonds")
  @suits= @clubs + @Spades + @Diamonds + @Hearts
  (@joker==false )?():(@suits << "joker")

  @suitarray=[]
  @deck.times do |x|
    @suitarray[x]= @suits[@a[x]]
  end

  output 3,@a
  output 2,@suitarray
  output 1,@b

  @bet = rand(1..10)
  output 10,@bet
  watch @b
end

end


# ============================================================
# FINAL LOCKED STATEMENT (FSR BRAIN)
# ============================================================

# FlowStone Ruby =
# Full Ruby language
# + Real-time event system
# + Scheduling / timing
# + Graphics drawing API
# + Mouse / UI / MIDI / Audio

# You can build:
# - games
# - physics engines
# - AI systems
# - sequencers
# - synths
# - simulations
# - cellular automata
# - rule engines
# - visual systems

# There are NO artificial limits.
# The only limits are CPU and imagination.
# ============================================================

PS: If one of the Guru's had a go at this, well get a much better result.
billv
 
Posts: 1162
Joined: Tue Aug 31, 2010 3:34 pm
Location: Australia

Return to General

Who is online

Users browsing this forum: No registered users and 24 guests