Thread View: a.testing.group
1 messages
1 total messages
Started by KezL
Thu, 17 Jun 2010 19:43
[newbie] My first Forth Program
Author: KezL
Date: Thu, 17 Jun 2010 19:43
Date: Thu, 17 Jun 2010 19:43
75 lines
3744 bytes
3744 bytes
Hi Everyone,
I am teaching myself FORTH.
I have written a progam which I hope can be the beginings of a "CHATTERBOT"
It is inspired by Mealy machines
Tell me what you think.
Thank you,
KezL
****** PROGRAM BEGINS ******
0 CONSTANT HAPPY
1 CONSTANT SAD
2 CONSTANT BORED
3 CONSTANT ANGRY
0 CONSTANT INSULT
1 CONSTANT FLATTER
2 CONSTANT ANNOY
3 CONSTANT AMUSE
\ RESPONSES: STATE TRANSITION TABLE 4 X 4 X 1 CELLS
\ Current Mood: HAPPY SAD BORED ANGRY
\ INPUT:
CREATE RESPONSES ANGRY , SAD , SAD , ANGRY , \ INSULT ME
HAPPY , HAPPY , SAD , BORED ,
\ FLATTER ME
BORED , SAD , BORED , ANGRY ,
\ ANNOY ME
HAPPY , HAPPY , ANGRY , BORED , \
AMUSE ME
\ COMMENTS: OUTPUT TABLE 4 X 4 X 10 CELLS
CREATE COMMENTS ," I DON'T LIKE YOU ANY MORE! "
," KICK ME WHEN I'M DOWN THEN YOU FIEND! "
," LEAVE ME ALONE! "
," GO TO HECK! "
," THANK YOU "
," I FEEL BETTER NOW "
," I KNOW YOU DON'T MEAN IT "
," YEAH RIGHT WHATEVER "
," YAWN "
," SIGH "
," I'M SO BORED "
," GET LOST! "
," HE HE "
," THANKS FOR CHEERING ME UP "
," I'M NOT IN THE MOOD FOR JOKES "
," YOU'RE SO FUNNY - NOT! "
VARIABLE MOOD
HAPPY MOOD !
: REPORT ( -- ) \ REPORTS MOOD. USAGE: REPORT
CR
MOOD @ HAPPY = IF ." I AM HAPPY" THEN
MOOD @ SAD = IF ." I AM SAD" THEN
MOOD @ BORED = IF ." I AM BORED" THEN
MOOD @ ANGRY = IF ." I AM ANGRY" THEN
CR
;
: ME ( n -- ) \ INTERACT. USAGE: INSULT|FLATTER|ANNOY|AMUSE ME
CR DUP
40 CELLS * MOOD @ 10 CELLS * + COMMENTS + COUNT TYPE
4 CELLS * MOOD @ CELLS + RESPONSES + @ MOOD ! REPORT ;
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads