9277- game Neyro7ety Logic
;???:
Graphics 800,600,32,2
Global g_text_pos = 0;
Global g_text$;
Global g_text_word$;
Global MAX_WORDS=1
Dim knowledge$(10000000);
Dim theme_log$(10000000);
Global log_pos=1;
Global CHAT_L_N=10
Dim chat$(CHAT_L_N+1);
f=LoadFont("system") : SetFont(f)
ChatDraw()
Flip()
While(1)
SeedRnd(MilliSecs());
ReadKnowledge()
user_text$=Input("User- ")
TextBegin(user_text$) : TextReadWord()
If g_text_word="+"
While TextReadWord()
If Word_Qu(g_text_word)=0 AddToKnowledgeWord(g_text_word)
Wend
EndIf
If user_text<>"" ChatAdd("User- "+user_text)
txt$=""
words_num=Rand(1,7);
For i=1 To words_num
word$=knowledge(Rand(1, MAX_WORDS))
txt$=txt+word+" ";
Next
ChatAdd("NS- "+txt)
Cls
ChatDraw()
Text 466,66,MAX_WORDS
Wend
Function ChatAdd(s$)
For i=1 To CHAT_L_N
chat(i)=chat(i+1)
Next
chat(CHAT_L_N)=s;
AddToLog(s)
End Function
;----------------------------------
Function ChatDraw()
Locate 0,100
For i=1 To CHAT_L_N
Print chat(i);
Next
End Function
;----------------------------------
Function ReadKnowledge()
MAX_WORDS=0
file1=FileOpen("knowledge.txt");
While(Eof(file1)<>1)
ReadLine(file1)
MAX_WORDS=MAX_WORDS+1
Wend
CloseFile(file1)
file1 = FileOpen("knowledge.txt");
For i=1 To MAX_WORDS
knowledge(i) = ReadLine(file1);
Next
CloseFile(file1);
End Function
Function AddToKnowledgeWord(s$)
If(s = "") Return
f=FileOpen("knowledge.txt")
SeekFile(f, FileSize("knowledge.txt"));
WriteLine(f, s)
MAX_WORDS=MAX_WORDS+1
CloseFile(f);
ReadKnowledge()
End Function
Function FileOpen(fn$)
file1 = OpenFile(fn$);
If(file1=0)file1=WriteFile(fn$);
Return file1;
End Function
Function AddToLog(s$)
f=FileOpen("log.txt")
SeekFile(f, FileSize("log.txt"));
WriteLine(f, s)
CloseFile(f);
End Function
Function Word_Qu(w$)
q=0
ReadKnowledge()
For i=1 To MAX_WORDS
If w=knowledge(i) q=q+1
Next
Return q
End Function
;------------------
Function TextBegin(text_$)
g_text=text_
g_text_pos = 1
g_text_word=""
End Function
Function TextReadWord()
g_text_word =""
If (g_text_pos > Len(g_text))Return 0;
While (Mid(g_text,g_text_pos,1) <> " " And g_text_pos<=Len(g_text))
g_text_word =g_text_word+ Mid(g_text,g_text_pos,1);
g_text_pos=g_text_pos+1
Wend
g_text_pos=g_text_pos+1;
Return 1;
End Function