IRC Bots, Java Game Query and Control Libraries, and More ...
Sign Up!
Welcome to
Monday, September 25 2017 @ 01:19 AM CDT

 Forum Index > > Other Jibble
 JMegaHal and saving Brain
 |  Printable Version
By: Gnome (offline) on Saturday, October 30 2004 @ 02:27 PM CDT (Read 18257 times)  

I have been playing with JMegaHal and have created an IRC bot with pircbot and got it all working OK. My question is how do I get JMegaHal to save its brain (i.e. learnt text etc.) Question



Forum Newbie

Status: offline

Registered: 10/30/04
Posts: 1

Profile Email    
By: Anonymous: spheric () on Sunday, October 31 2004 @ 04:36 AM CST  
Anonymous: spheric

Although I dont have experience with JMegahal the basic idea is to make whatever object you want to save serializable. You do this by adding


to the end (before the { ) of your opening class statement. For example:

class myclass implements {

Then, you need to add the code to actually save it

You need to create 2 objects. The first is a FileOutputStream (in again) ostream = new"words.dat");

and next an ObjectOutputStream p = new;

Then you need to write your object: - which MUST be serializable, otherwise an exception will be thrown


and finally close the file


Because I havent really used JMegaHal, I dont know whether paul has included its own save method, or even whether the data structure is even serializable. If it isnt you'll need to edit the source to make it so.

Hope this helps


By: spheric (offline) on Sunday, October 31 2004 @ 04:37 AM CST  

apologies, that post was by me, not anonymous Smile

Forum Junior

Status: offline

Registered: 10/26/04
Posts: 22

Profile Email    
By: Anonymous: Gene () on Thursday, November 04 2004 @ 04:14 AM CST  
Anonymous: Gene

Í would like to know more about this too.

Sorry I'm total beginner on area and would like to see more explanation.. I have made with help of my friend pircbot with jmegahal feature on it. But I would like to save those learned phrases somewhere.



By: DeadEd (offline) on Friday, November 05 2004 @ 03:16 AM CST  

Simple example on how to save to "brain.ser" ...

PHP Formatted Code

   ObjectOutput out = new ObjectOutputStream(new FileOutputStream("brain.ser"));

... and to create from "brain.ser" (previously serialized JMegaHal object) ...

PHP Formatted Code

   File file = new File("brain.ser");
   ObjectInputStream in = new ObjectInputStream(new FileInputStream(file));
   JMegaHal hal = (JMegaHal) in.readObject();

Forum Moderator

Status: offline

Registered: 06/01/04
Posts: 602

Profile Email Website  
By: Anonymous: gene () on Sunday, November 07 2004 @ 07:37 AM CST  
Anonymous: gene

Thanks. It did work great.

By: Anonymous: tipx () on Wednesday, November 10 2004 @ 12:12 PM CST  
Anonymous: tipx

where did you include this, and how?

By: Anonymous: Zacksta () on Sunday, November 14 2004 @ 10:52 AM CST  
Anonymous: Zacksta

Um where do you put the code for the memory..... does it have to go in a certin place or something?

By: spheric (offline) on Tuesday, November 16 2004 @ 10:10 AM CST  

you can put it wherever you want it, although reason dictates that you'll want the loading to be done when the bot starts, and the saving done either when the bot quits, or with a special command, or on a timer

Forum Junior

Status: offline

Registered: 10/26/04
Posts: 22

Profile Email    
By: Anonymous: waitsa () on Tuesday, November 16 2004 @ 10:44 AM CST  
Anonymous: waitsa

example of the java?


 All times are CDT. The time is now 01:19 AM.
Normal Topic Normal Topic
Locked Topic Locked Topic
Sticky Topic Sticky Topic
New Post New Post
Sticky Topic W/ New Post Sticky Topic W/ New Post
Locked Topic W/ New Post Locked Topic W/ New Post
View Anonymous Posts 
Able to Post 
Filtered HTML Allowed 
Censored Content 

My Account

Sign up as a New User
Lost your password?

What's New


No new stories

Comments last 2 days

No new comments

Files last 14 days

No new files
No new comments

Links last 2 weeks

No new links