hey if any one have any idea of creating a text based game engine using java
BAsic idea is that create java applets and connect them please tell how to inter connect them and we have to use JESS (Java Expert System Shell) it is a plugin of java
we should use non-monotonic logic(Artificial Intelligence) in this game implementation1
So, please if any one have any idea please help mee
Wow, that's a tall order. You've got questions about creating a game engine, writing applets, implementing applet-server communication, using a rule engine (Jess), and implementing AI.
I am the creator of Jess (not JESS, Jess; I'm officially required to tell you that this does not stand for "Java Expert System Shell" -- it's just a name, "Jess".) I can help you with general or specific questions about Jess (and all this other stuff too, actually, but so can lots of other people here.)
To get started, why not tell us what you know already from the list above. Have you written applets? Done network communication? Visited the Jess website (http://www.jessrules.com) and skimmed the manual? What do you know about game development? Let us know where you're at, and then we can try to help you from there.
i am a student and i am wishing to create a game as a mobile application using jess
as jess is a rule engine we can make help of it to create rules for non-monotonic logic
connectivity between applets is done but connecting jess with those applets has become a problem
could you please help me how to get a connection created so that depending on the present rule it creates a new rule and displays it so that user can click the option and so on...... the game continues
plzzzzzz help me
Jess is just a Java library, like any other, and the manual includes many simple and complex examples of embedding Jess in Java programs. Using Jess in an applet (if we're talking about java.applet.Applet) could be as simple as
import jess.*; ... Rete engine = new Rete(this); engine.batch("rules.clp") engine.run();
If you pass "this" (the applet) to the engine constructor, as shown here, Jess is even smart enough to know to look for the file "rules.clp" on the web server.
I don't know what you mean here by "connecting" -- linking within a single process, or connecting to a remote service? And as far as "depending on the present rule it creates a new rule", that's really too vague to help with. At some point you need to learn the rule language and start writing code; then I can help you with specific questions.
baaru so
Greenhorn
Joined: Apr 02, 2008
Posts: 25
posted
0
Originally posted by Ernest Friedman-Hill:
Jess is just a Java library, like any other, and the manual includes many simple and complex examples of embedding Jess in Java programs. Using Jess in an applet (if we're talking about java.applet.Applet) could be as simple as
import jess.*; ... Rete engine = new Rete(this); engine.batch("rules.clp") engine.run();
If you pass "this" (the applet) to the engine constructor, as shown here, Jess is even smart enough to know to look for the file "rules.clp" on the web server.
I don't know what you mean here by "connecting" -- linking within a single process, or connecting to a remote service? And as far as "depending on the present rule it creates a new rule", that's really too vague to help with. At some point you need to learn the rule language and start writing code; then I can help you with specific questions.
I read the complete manual and i am familiar with many commanda but it is not being done when i am trying to add one more button to the same frame so please help me in finding my mistake in this code
This is just a guess, bu the way in which the exit button is described is different to the way the start button is described.
One uses set and the other uses set location.
Have you tried copying the existing button and renaming and relocating?
Personally I would start with what works, and if there is a similar element, copy it, and then change its parameters and see what affect that has. But then I dont have JESS so havent read the manual.
Gavin
baaru so
Greenhorn
Joined: Apr 02, 2008
Posts: 25
posted
0
Originally posted by Gavin Tranter: This is just a guess, bu the way in which the exit button is described is different to the way the start button is described.
One uses set and the other uses set location.
Have you tried copying the existing button and renaming and relocating?
Personally I would start with what works, and if there is a similar element, copy it, and then change its parameters and see what affect that has. But then I dont have JESS so havent read the manual.
Gavin
ya i have done in getting the buttons placing
but i am unable to connect the applets made in jess
i mean to connect two applets created in jess is there any connectivity rule to do it
Ernest Friedman-Hill
author and iconoclast
Marshal
Indeed, this isn't a Jess problem, but a Java GUI problem. I see lots of issues here, all of which have to do with the GUI code itself, irrespective of language.
First, as Gavin points out, Button doesn't have a "set" method, so you can't be calling it. setLocation() is, indeed, a valid method. This script would abort with an exception right there.
Secondly, you're putting AWT Buttons into a Swing JFrame; you're mixing toolkits, and you ought to be using JButton instead with your JFrame. This will work, it's just bad style and you'll have other problems down the road.
Third, using "setLocation" followed by add() to place buttons is a horrible practice; in Java, you should use a LayoutManager and let it decide where to place the components. But if you are going to use this technique, then you need to turn off the default layout manager by setting it to null; i.e.,
(?*f* setLayout nil)
otherwise, you're using the JFrame's default BorderLayout layout manager. Calling add() on the JFrame with one argument like this places the component in the CENTER location of the JFrame; calling it again replaces the previous CENTER component with a new one, which is why you'll only ever see one button here (and your carefully computed component dimensions will be ignored, anyway.)
If you're going to write GUI code in Jess rather than in Java -- and although it's certainly possible, I see no reason to do it here -- it's best to write the code in Java first, and get it working the way you like, and then translate it to Jess. That way the Java compiler, or your IDE, can point out many errors for you.
baaru so
Greenhorn
Joined: Apr 02, 2008
Posts: 25
posted
0
Originally posted by Ernest Friedman-Hill: Indeed, this isn't a Jess problem, but a Java GUI problem. I see lots of issues here, all of which have to do with the GUI code itself, irrespective of language.
First, as Gavin points out, Button doesn't have a "set" method, so you can't be calling it. setLocation() is, indeed, a valid method. This script would abort with an exception right there.
Secondly, you're putting AWT Buttons into a Swing JFrame; you're mixing toolkits, and you ought to be using JButton instead with your JFrame. This will work, it's just bad style and you'll have other problems down the road.
Third, using "setLocation" followed by add() to place buttons is a horrible practice; in Java, you should use a LayoutManager and let it decide where to place the components. But if you are going to use this technique, then you need to turn off the default layout manager by setting it to null; i.e.,
(?*f* setLayout nil)
otherwise, you're using the JFrame's default BorderLayout layout manager. Calling add() on the JFrame with one argument like this places the component in the CENTER location of the JFrame; calling it again replaces the previous CENTER component with a new one, which is why you'll only ever see one button here (and your carefully computed component dimensions will be ignored, anyway.)
If you're going to write GUI code in Jess rather than in Java -- and although it's certainly possible, I see no reason to do it here -- it's best to write the code in Java first, and get it working the way you like, and then translate it to Jess. That way the Java compiler, or your IDE, can point out many errors for you.
ok thank you for correcting my mistakes but i want to implement in Jess and one more thing i succeded with your suggession
and how to connect the two gui interfaces in Jess now this is the main problem i am facing
Ernest Friedman-Hill
author and iconoclast
Marshal
This chapter of the Jess manual is devoted to building GUIs in the Jess language; there are several examples of responding to button presses and other events.
baaru so
Greenhorn
Joined: Apr 02, 2008
Posts: 25
posted
0
Originally posted by Ernest Friedman-Hill: This chapter of the Jess manual is devoted to building GUIs in the Jess language; there are several examples of responding to button presses and other events.
yes it is given about many of the gui interactings of the buttons but there is no example or atleast the header or the methods which are to be imported or called to invoke another applet from the present applet
so please help with the sample code sinppet
Ernest Friedman-Hill
author and iconoclast
Marshal
You need to understand what you're doing first, and how you would write it in Java, before trying to write any kind of Java scripting code like this in Jess. Once you understand what you want to do in Java, and then how Jess scripting works, it's trivial to write your code in Jess. But it really sounds like your understanding of what you want to do in Java is very weak, and I think you need to work on your design. Get something working in Java, and then add Jess to the mix only after you have a better idea of what you're trying to accomplish.
Code to make a JFrame appear when a button is pressed is trivial in both Java and Jess, and in fact the page I pointed to shows exactly what to do, with detailed code examples. So somehow I think you must be looking for something else.
On the other hand, now that you've changed the description to "invoking one applet from another applet", that's a whole different ballgame. First of all, that phrase doesn't really mean anything clearly. Do you mean communicating between two applets on a single HTML page (that can be done; but it has nothing to do with Jess). Do you mean creating one applet from another (strictly, that's possible, but not really in a useful way.) I suspect what you actually mean is something about communicating between applets in two different web browsers, on two different machines -- and that's an enormous topic, and one that has nothing at all to do with Jess, or GUIs, or buttons, or Frames, or anything else you're asking about here. If your question has anything to do with this last topic, then you need to go do some reading on Java networking, and the browser security model, and all sorts of other stuff. You might start here. [ April 15, 2008: Message edited by: Ernest Friedman-Hill ]
baaru so
Greenhorn
Joined: Apr 02, 2008
Posts: 25
posted
0
Originally posted by Ernest Friedman-Hill: You need to understand what you're doing first, and how you would write it in Java, before trying to write any kind of Java scripting code like this in Jess. Once you understand what you want to do in Java, and then how Jess scripting works, it's trivial to write your code in Jess. But it really sounds like your understanding of what you want to do in Java is very weak, and I think you need to work on your design. Get something working in Java, and then add Jess to the mix only after you have a better idea of what you're trying to accomplish.
Code to make a JFrame appear when a button is pressed is trivial in both Java and Jess, and in fact the page I pointed to shows exactly what to do, with detailed code examples. So somehow I think you must be looking for something else.
On the other hand, now that you've changed the description to "invoking one applet from another applet", that's a whole different ballgame. First of all, that phrase doesn't really mean anything clearly. Do you mean communicating between two applets on a single HTML page (that can be done; but it has nothing to do with Jess). Do you mean creating one applet from another (strictly, that's possible, but not really in a useful way.) I suspect what you actually mean is something about communicating between applets in two different web browsers, on two different machines -- and that's an enormous topic, and one that has nothing at all to do with Jess, or GUIs, or buttons, or Frames, or anything else you're asking about here. If your question has anything to do with this last topic, then you need to go do some reading on Java networking, and the browser security model, and all sorts of other stuff. You might start here.
[ April 15, 2008: Message edited by: Ernest Friedman-Hill ]
(answer (ident fire) (text no)) (answer (ident wind) (text no)) (answer (ident light-on) (text no)) => (assert (check surrounding)) (recommend-action "you are some where stuck in a place with a very calm climate"))
;;..........................................some more code to be written ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; forest domain rules
(defrule MAIN::forest (declare (auto-focus TRUE)) (explicit (answer (ident place) (text in-city))) => (recommend-action "to ask a human expert before going out of city to guide you to a better place") (halt))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Results output
(deffunction recommend-action (?action) "check final condition about the house" (call JOptionPane showMessageDialog ?*frame* (str-cat "I recommend that you " ?action) "Recommendation" (get-member JOptionPane INFORMATION_MESSAGE)))
(defadvice before halt (?*qfield* setText "Close window to exit"))
(deffunction is-of-type (?answer ?type ?valid) "Check that the answer has the right form" (if (eq ?type multi) then (foreach ?item ?valid (if (eq (sym-cat ?answer) (sym-cat ?item)) then (return TRUE))) (return FALSE))
(if (eq ?type number) then (return (is-a-number ?answer)))
;; plain text (return (> (str-length ?answer) 0)))
(deffunction combo-input (?EVENT) "An event handler for the combo box" (assert (ask::user-input (sym-cat (?*acombo* getSelectedItem)))))
(bind ?handler (new jess.awt.ActionListener combo-input (engine))) (?*acombo-ok* addActionListener ?handler)
(deffacts MAIN::question-data (question (ident place) (type multi) (valid in-city out-city strange) (text "What kind of place is it?")) (question (ident sound) (type multi) (valid yes no) (text "Do you hear any different sounds?")) (question (ident open-door) (type multi) (valid yes no) (text "Do you hear any sound that seem different ?")) (question (ident fire) (type multi) (valid yes no) (text "Do you see fire on far hills?")) (question (ident wind) (type multi) (valid yes no) (text "Is there a severe winds blowing?")) (question (ident light-on) (type multi) (valid yes no) (text "Does the surroundings seem to have light?")) (ask place))
(reset) (run-until-halt)
this code will create a frame
so now my aim is to create a program such that when i click the button in first frame i should come to the frame [B]sample game [/B]
Gavin Tranter
Ranch Hand
Joined: Jan 01, 2007
Posts: 333
posted
0
It has been a very very long time since I did anything with swing or GUI components, but surely its a rather easy case to control the visibility of two frames with a toggle?
Ernest Friedman-Hill
author and iconoclast
Marshal
Much of this code is copied directly from the "Diagnostic Assistant" example from the textbook; I don't know that it's particularly applicable to playing a game. Furthermore, the code already contains a couple of examples of adding ActionListeners to components, so I'm really unclear as to why you're asking this particular question. But in any case, you'd define a function and put your frame-creating code into it; i.e.,
Then if you want to call this function when the button in ?*start* is pressed, you'd just say
baaru so
Greenhorn
Joined: Apr 02, 2008
Posts: 25
posted
0
Originally posted by Ernest Friedman-Hill: Much of this code is copied directly from the "Diagnostic Assistant" example from the textbook; I don't know that it's particularly applicable to playing a game. Furthermore, the code already contains a couple of examples of adding ActionListeners to components, so I'm really unclear as to why you're asking this particular question. But in any case, you'd define a function and put your frame-creating code into it; i.e.,
Then if you want to call this function when the button in ?*start* is pressed, you'd just say
i am not asking for the button in the same frame
for example say
i have created a frames naming f1 and f2 now the main thing is that code of frame1 is at "f1.clp" and frame2 is in "f2.clp" now if i press a button in f1.clp then i should get the f2 frame to be executed( or poped out) and destroying frame1
baaru so
Greenhorn
Joined: Apr 02, 2008
Posts: 25
posted
0
Originally posted by bharadwaz somavarapu:
i am not asking for the button in the same frame
for example say
i have created a frames naming f1 and f2 now the main thing is that code of frame1 is at "f1.clp" and frame2 is in "f2.clp" now if i press a button in f1.clp then i should get the f2 frame to be executed( or poped out) and destroying frame1
one more thing to ask why do i get errors when i tr to execute the files using rete object in java i have imported all required files and even copied the jess.jar file to lib also even then its not getting executed whats problem with it...?
Originally posted by bharadwaz somavarapu: why do i get errors when i tr to execute the files using rete object in java
I don't know Jess, but I can tell there isn't enough information in this post for anyone to answer your question. Be sure to "Tell the Details" when you have a question. For example, post the errors you get when asking why you get the errors. See my signature for more on asking good questions.