This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#51 2012-02-26 08:52:40

roijac
Scratcher
Registered: 2010-01-19
Posts: 1000+

Re: Creating Code

https://sourceforge.net/p/m30w/svn/2/tree/
yeah, not much on there... still build 0.0.1

Offline

 

#52 2012-02-26 09:11:27

slinger
Scratcher
Registered: 2011-06-21
Posts: 1000+

Re: Creating Code

.class doesn't work on my machine...


http://s0.bcbits.com/img/buttons/bandcamp_130x27_blue.png

Offline

 

#53 2012-02-26 09:14:44

slinger
Scratcher
Registered: 2011-06-21
Posts: 1000+

Re: Creating Code

roijac wrote:

https://sourceforge.net/p/m30w/svn/2/tree/
yeah, not much on there... still build 0.0.1

Cool!


http://s0.bcbits.com/img/buttons/bandcamp_130x27_blue.png

Offline

 

#54 2012-02-26 09:18:55

16Skittles
Scratcher
Registered: 2009-08-26
Posts: 1000+

Re: Creating Code

slinger wrote:

.class doesn't work on my machine...

What do you mean? Navigate to the directory, then do "java philosoraptor" or make the .bat file.


http://16skittles.tk/sig.png
Are you a student? Check out OnSchedule!

Offline

 

#55 2012-02-26 09:24:06

slinger
Scratcher
Registered: 2011-06-21
Posts: 1000+

Re: Creating Code

What do you mean by do "java philosoraptor"?


http://s0.bcbits.com/img/buttons/bandcamp_130x27_blue.png

Offline

 

#56 2012-02-26 09:39:00

16Skittles
Scratcher
Registered: 2009-08-26
Posts: 1000+

Re: Creating Code

slinger wrote:

What do you mean by do "java philosoraptor"?

in command prompt. do "cd <directory>" until you get to the place you downloaded the files, then use the command "java philosoraptor" to run the file.


http://16skittles.tk/sig.png
Are you a student? Check out OnSchedule!

Offline

 

#57 2012-02-26 09:42:18

slinger
Scratcher
Registered: 2011-06-21
Posts: 1000+

Re: Creating Code

Didn't think of that  tongue  Awesome program  smile


http://s0.bcbits.com/img/buttons/bandcamp_130x27_blue.png

Offline

 

#58 2012-02-26 09:46:11

TRocket
Scratcher
Registered: 2009-08-18
Posts: 1000+

Re: Creating Code

just scrape through with 184 lines:

Code:

package scratch.TRocket.ScratchRemoteSonsorConnections;

import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.Socket;
/**
 * for connecting to the scratch program at scratch.mit.edu which uses the remote sensor connections protocol
 * @author TRocket
 * 
 * 
 * @version 1.0 - 1.4/1.4.1/1.3 
 */
public class ScratchRemoteSensorConnection{
    /**
     * the socket connected to scratch
     */
    private Socket scratchSocket;
    //int lastread = 0;
    //Socket scratchSocket = new Socket();
    /**
     * Connects to scratch running remotely/locally on the default port:42001
     * @author TRocket
     * @param host the hostname/ip of the computer running scratch to connect to
     * @throws Exception
     */
    public ScratchRemoteSensorConnection(String host) throws IOException{//constructor
        try {
            scratchSocket = new Socket(host, 42001);

            
            
        } catch (IOException e) {
            throw e;
        }
    }
    /**
     * Connects to scratch running remotely/locally on the specified port
     * @author TRocket
     * @param host hostname/ip of the computer running scratch to connect to
     * @param port port scratch is listening on 
     * @throws IOException
     */
    public ScratchRemoteSensorConnection(String host, int port) throws IOException{//constructor
        try {
            scratchSocket = new Socket(host, port);

            
            
        } catch (IOException e) {
            throw e;
        }
    }
    /**
     * Connects to scratch running locally on the default port:42001
     * @author TRocket
     * @throws IOException
     */
    public ScratchRemoteSensorConnection() throws IOException{//constructor
        try {
            scratchSocket = new Socket("127.0.0.1", 42001);

            
            
        } catch (IOException e) {
            throw e;
        }
    }
    /**
     * send the message
     * @author TRocket
     * @param message the message to be sent
     * @throws Exception
     */
    public void send(String message) throws IOException{//write
        PrintWriter out;
        try {
            out = new PrintWriter(scratchSocket.getOutputStream());
            int[] tosend = new int[4];
            int[] tosend2 = new int[message.length()];
            tosend[0] =(byte)( message.length() >> 24 );
            tosend[1] =(byte)( (message.length() << 8) >> 24 );
            tosend[2] =(byte)( (message.length() << 16) >> 24 );
            tosend[3] =(byte)( (message.length() << 24) >> 24 );
            for (int i = 0; i < message.length(); i++) {
                tosend2[i] = message.charAt(i);
            }
            for (int i = 0; i < tosend2.length; i++) {
                //System.out.println(tosend2[i]);
            }
            for (int i = 0; i < tosend.length; i++) {
                out.write(tosend[i]);
            }
            for (int i = 0; i < tosend2.length; i++) {
                out.write(tosend2[i]);
            }
            out.flush();
        } catch (IOException e) {
            throw e;
        }
    
    }
    /**
     * reads next massage:
     * <br>
     * broadcast "broadcast name"
     * <br>
     * sensor-update "variable/sensor name" "value"
     * <br>
     * <br>
     * locks thread until message recived
     * @author TRocket
     * @return the read message
     * @throws IOException 
     * @throws Exception
     */
    public String read() throws IOException {
        BufferedInputStream in;
        try {
    
            in = new BufferedInputStream(scratchSocket.getInputStream());
            int[] bytes = new int[4];
            bytes[0] = in.read();
            bytes[1] = in.read();
            bytes[2] = in.read();
            bytes[3] = in.read();
            int length = bytes[0] + bytes[1] + bytes[2] + bytes[3];
            int[] bytes2 = new int[length];
            for (int i = 0; i < bytes2.length; i++) {
                bytes2[i] = in.read();
            }
            for (int i = 0; i < bytes2.length; i++) {
            }
            String out = null;
            char outCurrent = (char)bytes2[0];
            out = Character.toString(outCurrent);
            for (int i = 1; i < bytes2.length; i++) {
                outCurrent = (char)bytes2[i];
                out = out + Character.toString(outCurrent);
            }
            return out;
        } catch (java.net.SocketException e) {
            throw e;
            
        } catch (IOException e) {
            throw e;
        }
        
        
        
    }
    /**
     * broadcasts the broadcast with the specified name  
     * @author TRocket
     * @param broadcastName the name of the broadcast to be sent
     * @throws Exception
     */
    public void broadcast(String broadcastName) throws Exception{//broadcast
        this.send("broadcast \"" + broadcastName + "\"");
    }
    /**
     * updates the specified sensor value
     * @author TRocket
     * @param sensorName name of the sensor to update
     * @param value the value to update the sensor to
     * @throws Exception
     */
    public void sensorupdate(String sensorName, String value) throws Exception{
        this.send("sensor-update \"" + sensorName + "\" " + value + " ");
    }
    //private void error(Exception e) throws Exception{
    //    throw e;
    //}
    /**
     * @author TRocket
     * @return weather this Connection is connected
     */
    public boolean connected(){
        try{
        return scratchSocket.isConnected();
        }catch(NullPointerException e){return false;}
    }
}

scratch java connector please give credit if you use it.


http://i.imgur.com/1QqnHxQ.png

Offline

 

#59 2012-02-26 09:49:16

slinger
Scratcher
Registered: 2011-06-21
Posts: 1000+

Re: Creating Code

Awesome! I'm working on one for pascal  smile
I'll change the limit to 500  tongue


http://s0.bcbits.com/img/buttons/bandcamp_130x27_blue.png

Offline

 

#60 2012-02-29 15:25:26

bananaman99
New Scratcher
Registered: 2012-02-04
Posts: 100+

Re: Creating Code

I got mad at a kid at school today, so I opened up Notepad and made a bit of a "trolololol" virus that would crash his computer. I named it Medal of Duty so it would look legit  tongue

Code:

start Medal of Duty.bat
@echo off
echo WARNING WARNING VIRUS DETECTED
Medal of Duty.bat

It opens, says WARNING WARNING VIRUS DETECTED, then keeps duplicating itself until it crashes your pc  smile

Offline

 

#61 2012-02-29 15:44:05

16Skittles
Scratcher
Registered: 2009-08-26
Posts: 1000+

Re: Creating Code

bananaman99 wrote:

I got mad at a kid at school today, so I opened up Notepad and made a bit of a "trolololol" virus that would crash his computer. I named it Medal of Duty so it would look legit  tongue

Code:

start Medal of Duty.bat
@echo off
echo WARNING WARNING VIRUS DETECTED
Medal of Duty.bat

It opens, says WARNING WARNING VIRUS DETECTED, then keeps duplicating itself until it crashes your pc  smile

Lol I've done that before!  tongue


http://16skittles.tk/sig.png
Are you a student? Check out OnSchedule!

Offline

 

#62 2012-02-29 15:45:09

logiblocs
Scratcher
Registered: 2010-05-05
Posts: 100+

Re: Creating Code

bananaman99 wrote:

I got mad at a kid at school today, so I opened up Notepad and made a bit of a "trolololol" virus that would crash his computer. I named it Medal of Duty so it would look legit  tongue

Code:

start Medal of Duty.bat
@echo off
echo WARNING WARNING VIRUS DETECTED
Medal of Duty.bat

It opens, says WARNING WARNING VIRUS DETECTED, then keeps duplicating itself until it crashes your pc  smile

Heres one for linux/mac

Code:

#!/bin/sh
# virus.sh
echo "ERROR virus detected"
./virus.sh

Offline

 

#63 2012-02-29 17:00:13

16Skittles
Scratcher
Registered: 2009-08-26
Posts: 1000+

Re: Creating Code

I recreated Pong with exactly 335 lines of java code, link is over in the official topic.


http://16skittles.tk/sig.png
Are you a student? Check out OnSchedule!

Offline

 

#64 2012-03-01 05:58:18

rdococ
Scratcher
Registered: 2009-10-11
Posts: 1000+

Re: Creating Code

I added a few lines to my chatbot and I'll share the code now.

Code:

@echo off
cls
echo The Rdococian Chatbot
title The Rdococian Chatbot - Start
echo Press any key to chat...
pause > null
set msg="Hey there! What should we talk about?"
cls
echo Please login...
set /p username="Username: "
cls
goto chat
:chat
title The Rdococian Chatbot - Chatting
echo Computer: %msg%
set /p chat="%username%: "
set chat="%chat%"
set oldmsg=%msg%
if /i %chat%=="hello" set msg="What should we talk about?"
if /i %chat%=="hi" set msg="Hey there! Who are you?"
if /i %chat%=="hey" set msg="Hello! What should we talk about?"
if /i %chat%=="lets talk about scratch" set msg="Oh, I love that application!"
if /i %chat%=="i love it too" set msg="Cool. So what else?"
if /i %chat%=="yes" set msg="Cool!"
if /i %chat%=="go on scratch" set msg="Go on it! Yeah!"
if /i %chat%=="lol" set msg="Hehehe, lol."
if /i %chat%=="rofl" set msg="Haha... LOL!!!"
if /i %chat%=="youre weird" set msg="So hilarious."
if /i %chat%=="youre crazy" set msg="So are you! Lol."
if /i %chat%=="scratch is bab" set msg="Go away!"
if /i %chat%=="i hate scratch" set msg="..."
if /i %chat%=="i dislike scratch" set msg="I love Scratch, but I respect your opinion."
if /i %chat%=="i like scratch" set msg="I don't like it. Instead, I love it."
if /i %chat%=="scratch is lovely" set msg="It and you is lovely too!"
if /i %chat%=="bye" set msg="See you soon!"
if /i %chat%=="goodbye" set msg="Cya. Out the door you go..."
if /i %chat%=="*" set msg="Huh? What is weird?"
if /i %chat%=="i love scratch" set msg="So do I!"
if /i %chat%=="lolwut" set msg="Very funny, isn't it?"
if /i %chat%=="hehe" set msg="...lol."
if /i %chat%=="haha" set msg="Hahaha! It is so funny!"
if /i %chat%=="scratch" set msg="I love Scratch!"
if /i %chat%=="so do i" set msg="Cool!"
if /i %chat%=="i love squeak" set msg="Squeak is the best programming language in the world!"
if /i %chat%=="i like squeak" set msg="I agree. But I love it, not like it."
if /i %chat%=="i hate squeak" set msg="Hate is a strong word, but I respect your opinion."
if /i %chat%=="i dislike squeak" set msg="I like Squeak, but I respect your opinion."
if /i %chat%=="i agree" set msg="Cool."
if /i %chat%=="i disagree" set msg="Still cool. xP"
if /i %chat%=="go on squeak" set msg="I might."
if /i %chat%=="i love smalltalk" set msg="I don't really go on Smalltalk..."
if /i %chat%=="i like smalltalk" set msg="I don't know Smalltalk syntax, I don't program on it."
if /i %chat%=="i hate smalltalk" set msg="Hate is a strong word, but I don't use it anyway."
if /i %chat%=="i dislike smalltalk" set msg="I don't use Smalltalk."
if /i %chat%=="go on smalltalk" set msg="I might."
if /i %msg%==%oldmsg% set msg="Huh? I said... %oldmsg%. Or did you repeat what you said?"
goto chat

Oh? Something weird with my computer. Oh, it's just a client-side error that occured. The text blanked out, it's just an error.

Last edited by rdococ (2012-03-01 06:01:58)

Offline

 

#65 2012-03-01 06:06:39

slinger
Scratcher
Registered: 2011-06-21
Posts: 1000+

Re: Creating Code

Nope, the code is there, i'm making a .bat file now  tongue
edit: interesting, you may want to think about a "help" command 'cause I have no idea what I'm supposed to talk about lol.

Last edited by slinger (2012-03-01 06:09:53)


http://s0.bcbits.com/img/buttons/bandcamp_130x27_blue.png

Offline

 

#67 2012-03-01 06:14:15

slinger
Scratcher
Registered: 2011-06-21
Posts: 1000+

Re: Creating Code

interesting, you may want to think about a "help" command 'cause I have no idea what I'm supposed to talk about lol.


http://s0.bcbits.com/img/buttons/bandcamp_130x27_blue.png

Offline

 

#68 2012-03-01 06:38:55

rdococ
Scratcher
Registered: 2009-10-11
Posts: 1000+

Re: Creating Code

I updated my code! It can now log chat history in a specified file.
I also added a few more sentences that the bot can understand.

Code:

@echo off
cls
set logs=0
echo The Rdococian Chatbot
title The Rdococian Chatbot - Start
echo Press any key to chat...
pause > null
set msg="Hey there! What should we talk about?"
cls
echo Please login...
set /p username="Username: "
cls
goto chat
:chat
title The Rdococian Chatbot - Chatting
echo Computer: %msg%
set /p chat="%username%: "
set chat="%chat%"
set oldmsg=%msg%
if /i %chat%=="hello" set msg="What should we talk about?"
if /i %chat%=="hi" set msg="Hey there! Who are you?"
if /i %chat%=="hey" set msg="Hello! What should we talk about?"
if /i %chat%=="lets talk about scratch" set msg="Oh, I love that application!"
if /i %chat%=="i love it too" set msg="Cool. So what else?"
if /i %chat%=="yes" set msg="Cool!"
if /i %chat%=="go on scratch" set msg="Go on it! Yeah!"
if /i %chat%=="lol" set msg="Hehehe, lol."
if /i %chat%=="rofl" set msg="Haha... LOL!!!"
if /i %chat%=="youre weird" set msg="So hilarious."
if /i %chat%=="youre crazy" set msg="So are you! Lol."
if /i %chat%=="scratch is bab" set msg="Go away!"
if /i %chat%=="i hate scratch" set msg="..."
if /i %chat%=="i dislike scratch" set msg="I love Scratch, but I respect your opinion."
if /i %chat%=="i like scratch" set msg="I don't like it. Instead, I love it."
if /i %chat%=="scratch is lovely" set msg="It and you is lovely too!"
if /i %chat%=="bye" set msg="See you soon!"
if /i %chat%=="goodbye" set msg="Cya. Out the door you go..."
if /i %chat%=="*" set msg="Huh? What is weird?"
if /i %chat%=="i love scratch" set msg="So do I!"
if /i %chat%=="lolwut" set msg="Very funny, isn't it?"
if /i %chat%=="hehe" set msg="...lol."
if /i %chat%=="haha" set msg="Hahaha! It is so funny!"
if /i %chat%=="scratch" set msg="I love Scratch!"
if /i %chat%=="squeak" set msg="I love Squeak!"
if /i %chat%=="smalltalk" set msg="I don't go on Smalltalk."
if /i %chat%=="go on java" set msg="No thank you."
if /i %chat%=="i love java" set msg="I don't go on Java..."
if /i %chat%=="i like java" set msg="I don't know Java syntax, I don't program on it."
if /i %chat%=="i hate java" set msg="Hate is a strong word, but I don't use it anyway."
if /i %chat%=="i dislike java" set msg="I don't use Java."
if /i %chat%=="so do i" set msg="Cool!"
if /i %chat%=="i love squeak" set msg="Squeak is the best programming language in the world!"
if /i %chat%=="i like squeak" set msg="I agree. But I love it, not like it."
if /i %chat%=="i hate squeak" set msg="Hate is a strong word, but I respect your opinion."
if /i %chat%=="i dislike squeak" set msg="I like Squeak, but I respect your opinion."
if /i %chat%=="i agree" set msg="Cool."
if /i %chat%=="i disagree" set msg="Still cool. xP"
if /i %chat%=="go on squeak" set msg="I might."
if /i %chat%=="i love smalltalk" set msg="I don't really go on Smalltalk..."
if /i %chat%=="i like smalltalk" set msg="I don't know Smalltalk syntax, I don't program on it."
if /i %chat%=="i hate smalltalk" set msg="Hate is a strong word, but I don't use it anyway."
if /i %chat%=="i dislike smalltalk" set msg="I don't use Smalltalk."
if /i %chat%=="go on smalltalk" set msg="I might."
if /i %chat%=="!help" goto help
if /i %chat%=="!log" goto log
if /i %msg%==%oldmsg% set msg="Huh? I said... %oldmsg%. Or did you repeat what you said?"
if /i %logs%==1 goto logtest
:logtest
if exist %logsname% echo Computer: %msg% >> %logsname%
if not exist %logsname% echo Computer: %msg% > %logsname%
goto chat
:help
cls
echo Rdococian Chatbot Help
echo.
echo Talk about your favourite
echo programming language, whether
echo it be Scratch, Smalltalk,
echo or Squeak! I am implementing
echo talking about Java too.
pause
cls
goto chat
:log
if %logs%==0 set logs=1 & set /p logsname="File to place log in:"
if %logs%==1 set logs=0
echo Logging successifully toggled.
pause
cls
goto chat

Offline

 

#69 2012-03-01 06:45:16

rdococ
Scratcher
Registered: 2009-10-11
Posts: 1000+

Re: Creating Code

I updated it AGAIN to show what the user says in the log.

Code:

@echo off
cls
set logs=0
echo The Rdococian Chatbot
title The Rdococian Chatbot - Start
echo Press any key to chat...
pause > null
set msg="Hey there! What should we talk about?"
cls
echo Please login...
set /p username="Username: "
cls
goto chat
:chat
title The Rdococian Chatbot - Chatting
echo Computer: %msg%
set /p chat="%username%: "
set chat="%chat%"
set oldmsg=%msg%
if /i %chat%=="hello" set msg="What should we talk about?"
if /i %chat%=="hi" set msg="Hey there! Who are you?"
if /i %chat%=="hey" set msg="Hello! What should we talk about?"
if /i %chat%=="lets talk about scratch" set msg="Oh, I love that application!"
if /i %chat%=="i love it too" set msg="Cool. So what else?"
if /i %chat%=="yes" set msg="Cool!"
if /i %chat%=="go on scratch" set msg="Go on it! Yeah!"
if /i %chat%=="lol" set msg="Hehehe, lol."
if /i %chat%=="rofl" set msg="Haha... LOL!!!"
if /i %chat%=="youre weird" set msg="So hilarious."
if /i %chat%=="youre crazy" set msg="So are you! Lol."
if /i %chat%=="scratch is bab" set msg="Go away!"
if /i %chat%=="i hate scratch" set msg="..."
if /i %chat%=="i dislike scratch" set msg="I love Scratch, but I respect your opinion."
if /i %chat%=="i like scratch" set msg="I don't like it. Instead, I love it."
if /i %chat%=="scratch is lovely" set msg="It and you is lovely too!"
if /i %chat%=="bye" set msg="See you soon!"
if /i %chat%=="goodbye" set msg="Cya. Out the door you go..."
if /i %chat%=="*" set msg="Huh? What is weird?"
if /i %chat%=="i love scratch" set msg="So do I!"
if /i %chat%=="lolwut" set msg="Very funny, isn't it?"
if /i %chat%=="hehe" set msg="...lol."
if /i %chat%=="haha" set msg="Hahaha! It is so funny!"
if /i %chat%=="scratch" set msg="I love Scratch!"
if /i %chat%=="squeak" set msg="I love Squeak!"
if /i %chat%=="smalltalk" set msg="I don't go on Smalltalk."
if /i %chat%=="go on java" set msg="No thank you."
if /i %chat%=="i love java" set msg="I don't go on Java..."
if /i %chat%=="i like java" set msg="I don't know Java syntax, I don't program on it."
if /i %chat%=="i hate java" set msg="Hate is a strong word, but I don't use it anyway."
if /i %chat%=="i dislike java" set msg="I don't use Java."
if /i %chat%=="so do i" set msg="Cool!"
if /i %chat%=="i love squeak" set msg="Squeak is the best programming language in the world!"
if /i %chat%=="i like squeak" set msg="I agree. But I love it, not like it."
if /i %chat%=="i hate squeak" set msg="Hate is a strong word, but I respect your opinion."
if /i %chat%=="i dislike squeak" set msg="I like Squeak, but I respect your opinion."
if /i %chat%=="i agree" set msg="Cool."
if /i %chat%=="i disagree" set msg="Still cool. xP"
if /i %chat%=="go on squeak" set msg="I might."
if /i %chat%=="i love smalltalk" set msg="I don't really go on Smalltalk..."
if /i %chat%=="i like smalltalk" set msg="I don't know Smalltalk syntax, I don't program on it."
if /i %chat%=="i hate smalltalk" set msg="Hate is a strong word, but I don't use it anyway."
if /i %chat%=="i dislike smalltalk" set msg="I don't use Smalltalk."
if /i %chat%=="go on smalltalk" set msg="I might."
if /i %chat%=="!help" goto help
if /i %chat%=="!log" goto log
if /i %msg%==%oldmsg% set msg="Huh? I said... %oldmsg%. Or did you repeat what you said?"
if /i %logs%==1 goto logtest
:logtest
if exist %logsname% echo You: %chat% >> %logsname%
if not exist %logsname% echo You: %chat% > %logsname%
if exist %logsname% echo Computer: %msg% >> %logsname%
if not exist %logsname% echo Computer: %msg% > %logsname%
goto chat
:help
cls
echo Rdococian Chatbot Help
echo.
echo Talk about your favourite
echo programming language, whether
echo it be Scratch, Smalltalk,
echo or Squeak! I am implementing
echo talking about Java too.
pause
cls
goto chat
:log
if %logs%==0 set logs=1 & set /p logsname="File to place log in:"
if %logs%==1 set logs=0
echo Logging successifully toggled.
pause
cls
goto chat

Offline

 

#70 2012-03-01 07:47:55

bbbeb
Scratcher
Registered: 2009-06-11
Posts: 1000+

Re: Creating Code

bananaman99 wrote:

I got mad at a kid at school today, so I opened up Notepad and made a bit of a "trolololol" virus that would crash his computer. I named it Medal of Duty so it would look legit  tongue

Code:

start Medal of Duty.bat
@echo off
echo WARNING WARNING VIRUS DETECTED
Medal of Duty.bat

It opens, says WARNING WARNING VIRUS DETECTED, then keeps duplicating itself until it crashes your pc  smile

Make it do 4 more medal of duty.bat launches before re-iterating, it duplicates at exponents of 4 then (4 programs, 16, 64, 256, 1024...)
Yeah, fastcrash.


Back in my day.... there were no laws that censored the internet... now, there are.... nah.

Offline

 

#71 2012-03-01 07:52:36

slinger
Scratcher
Registered: 2011-06-21
Posts: 1000+

Re: Creating Code

slinger wrote:

Really old AI chat bot I just fixed up, it's called "learnbot".

Code:

program LearnBot;

{$mode objfpc}{$H+}

uses
  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}
  Classes
  { you can add units after this };

{$R *.res}
procedure spacer;  // creates a space
begin
  writeln;
  writeln;
end;
procedure intro;  // feel free to edit :P
begin
  writeln('LearnBot is currently under development by Slinger.');
end;
procedure instructions;
begin
  writeln('This is LearnBot a chatbot AI.');
  writeln('Type "teach" to teach me something and type "wipe" to clear my memory');
  writeln('Press <Enter> to continue');
  readln;
end;
var
  command: string;
  wipe: integer;
  teachLoop: integer;
  lookUpLoop: integer;
  phraseMemory: array[1..100] of string;
  responseMemory: array[1..100] of string;

begin
  intro;
  spacer;
  instructions;
  spacer;
  teachLoop := 1;
  repeat
    write('Command: ');
    readln(command);

    if command = 'wipe' then  //wipes the memory
      begin
        wipe := 1;
        repeat
          phraseMemory[wipe] := '';
          responseMemory[wipe] := '';
          wipe := wipe + 1;

        until wipe > 100 ;
        writeln('Memory wiped.');
        teachLoop := 1;

      end;

    if command = 'teach' then
      begin
      write('Teach me what? ');
      readln(phraseMemory[teachLoop]);
      write('How should I respond? ');
      readln(responseMemory[teachLoop]);
      writeln;
      teachLoop := teachLoop + 1;

      end
    else
      begin

        lookUpLoop := 0;
        repeat
          lookUpLoop := lookUpLoop + 1;
        until (command = phraseMemory[lookUpLoop]) or (lookUpLoop > 101);
        writeln(responseMemory[lookUpLoop]);
      end;


  until command = 'done';

end.

If you want the program it's on sourceforge (the fixed up one) right here.


http://s0.bcbits.com/img/buttons/bandcamp_130x27_blue.png

Offline

 

#72 2012-03-01 07:56:18

roijac
Scratcher
Registered: 2010-01-19
Posts: 1000+

Re: Creating Code

bananaman99 wrote:

I got mad at a kid at school today, so I opened up Notepad and made a bit of a "trolololol" virus that would crash his computer. I named it Medal of Duty so it would look legit  tongue

Code:

start Medal of Duty.bat
@echo off
echo WARNING WARNING VIRUS DETECTED
Medal of Duty.bat

It opens, says WARNING WARNING VIRUS DETECTED, then keeps duplicating itself until it crashes your pc  smile

i ran this and had to plug it out xD

Offline

 

Board footer