*****......SALUDOS!!...BIENVENIDOS.....*****

Systemkiricorp!

FORO ACTIVO

HOLA!! A TODA LA COMUNIDAD DE PROGRAMADORES
Este foro es presentado por sk
LA MATERIA DE INTELIGENCIA ARTIFICIAL

INNOVANDO Y RECREANDO IDEAS PARA LA VIDA

INICIANDO

El hombre cada dia es mejor

¿QUE ES LA INTELIGENCIA ARTIFICIAL?


Él termino "inteligencia artificial" fue acuñado formalmente en 1956 durante la conferencia de Darthmounth, más para entonces ya se había estado trabajando en ello durante cinco años en los cuales se había propuesto muchas definiciones distintas que en ningún caso habían logrado ser aceptadas totalmente por la comunidad investigadora. La AI es una de las disciplinas más nuevas que junto con la genética moderna es el campo en que la mayoría de los científicos " más les gustaría trabajar".

lunes, 21 de junio de 2010

EJECUCION DE PROGRAMAS EN JAVA Y APPLEST

JEMPLO 1
package proyectos1; //crear proyecto
import java.applet.Applet; //crear el applet
import java.awt.Color;
import java.awt.Graphics;

public class Ej1 extends Applet{ //agregarsiempre extends Applets
@Override //indicacion para utilizar un tipo de meétodo
public void paint(Graphics g) //sintaxis general parametro g de tipo graphics
{
g.setColor(Color.blue); //cambia color
g.drawString("Hola mundo",20,20); //dibuja
}
}
EN ESTE EJEMPLO PODEMOS VER LA EJECUCION DE UN APPLET EL RESULTADO SOLO ES UN MENSAJE DE HOLA MUNDO.

CODIGO DE APPLET EN HTML.


<br />HTML Test Page<br />

<br />HTML Test Page<br />


Ejemplo 1










JEMPLO 2

package proyectos1;
import java.applet.Applet;
import java.awt.Color;
import java.awt.Graphics;
public class Ej2 extends Applet {
String cadena1;
int xCadena1,yCadena2;
Color colorCad;
@Override
public void init() //se ejecuta primero porque guarda las acciones de los botones
{
cadena1="hola a todos";
xCadena1=20;
yCadena2=30;
colorCad=Color.BLUE;

}
@Override
public void paint(Graphics g) //se ejecuta despues porque es lo que se modifica
{
g.setColor(colorCad);
g.drawString(cadena1,xCadena1,xCadena1);
}
}
JEMPLO 3


package proyectos1;
import java.applet.Applet;
import java.awt.*;

public class Ej3 extends Applet {
String cadena1;
int xCadena1, yCadena2;
Color colorCad;
Button boton1;
String msgBoton1;
@Override
public void init()
{
cadena1="hola a todos";
xCadena1=20;
yCadena2=30;
colorCad=Color.BLUE;
msgBoton1="Mi primer boton";
boton1=new Button (msgBoton1);
this.add(boton1);

}

@Override
public void paint(Graphics g)
{
g.setColor(colorCad);
g.drawString(cadena1,xCadena1,xCadena1);
}
}

JEMPLO 4
package proyectos1;
import java.applet.Applet;
import java.awt.*;
public class Ej4 extends Applet {
Color colorFondo;
String cadena1;
int xCadena1, yCadena2;
Color colorCad;
Button boton1;
String msgBoton1;
TextArea txtAreaSaludo;
String textoTxtArea;
Checkbox seleccion;
Scrollbar colores;
Choice selector;
CheckboxGroup radio;
TextField txtMensaje;
String msgTxt;
@Override
public void init()
{
colorFondo=Color.LIGHT_GRAY;
setBackground(colorFondo);
cadena1="Hola a todos";
xCadena1=20;
yCadena2=30;
colorCad=Color.white;
msgBoton1="Mi primer boton";
boton1=new Button (msgBoton1);
add(boton1);
textoTxtArea="Hola otra vez";
txtAreaSaludo=new TextArea();
txtAreaSaludo.setText(textoTxtArea);
seleccion=new Checkbox("Seleccioname");
add(seleccion);
colores=new Scrollbar();
add(colores);
selector=new Choice();
selector.addItem("Rojo");
selector.addItem("Verde");
selector.addItem("Azul");
add(selector);
radio=new CheckboxGroup();
add(new Checkbox("Primero",radio,true));
add(new Checkbox("Segundo",radio,false));
add(new Checkbox("Tercero",radio,false));
msgTxt="hola de nueva cuenta";
txtMensaje=new TextField();
txtMensaje.setText(msgTxt);
add(txtMensaje);
}
@Override
public void paint(Graphics g)
{
setSize(500,300);
g.setColor(colorCad);
g.drawString(cadena1,xCadena1,xCadena1);




}

}

JEMPLO 5


package proyectos1;
import java.awt.*;
import java.applet.Applet;
public class Ej5 extends Applet {
Checkbox Relleno;
public void init(){
Relleno=new Checkbox("Relleno");
add(Relleno);


}
public boolean action(Event evt,Object obj)
{
if(evt.target instanceof Checkbox)
System.out.println("CheckBox:"+ evt.arg.toString());
return true;
}

}

JEMPLO 6
package proyectos1;
import java.awt.*;
import java.applet.Applet;
public class Ej6 extends Applet {
Checkbox Relleno;
TextField txtEdo1;
TextField txtEdo2;
public void init(){
txtEdo1=new TextField(" ");
add(txtEdo1);
txtEdo2=new TextField(" ");
add(txtEdo2);
Relleno=new Checkbox("selecciona");
add(Relleno);


}
public boolean action(Event evt,Object obj)
{
if(evt.target instanceof Checkbox)
{
txtEdo1.setText("hola bienvenido");
String tmp="Checkbox:" + evt.arg.toString();
txtEdo2.setText(tmp);

}
return true;

}


}
JEMPLO 7

package proyectos1;
import java.awt.*;
import java.applet.Applet;
public class Ej7 extends Applet {
Choice selector;
TextField txtEdo1;
TextField txtEdo2;
@Override
public void init(){
txtEdo1=new TextField(" ");
add(txtEdo1);
selector=new Choice();
selector.addItem("Rojo");
selector.addItem("verde");
selector.addItem("Azul");
add(selector);
}
public boolean action(Event evt, Object obj)
{
if(evt.target instanceof Choice)
{
if(selector.getSelectedIndex()==0)
txtEdo1.setText("Color rojo");
if(selector.getSelectedIndex()==1)
txtEdo1.setText("Color verde");
if(selector.getSelectedIndex()==2)
txtEdo1.setText("Color azul");
}
return true;
}


}

JEMPLO 8
package proyectos1;
import java.awt.*;
import java.applet.Applet;
public class Ej8 extends Applet {
@Override
public void init(){

}

public void paint(Graphics g)
{
g.setColor(Color.blue);
g.drawLine(11,10,30,30);
g.drawRect(50,50,50,20);
g.setColor(Color.pink);
g.fillRect(50,150,50,20);
g.setColor(Color.CYAN);
g.drawOval(100,25,25,50);
g.setColor(Color.ORANGE);
g.fillOval(200,40,25,50);
}
public boolean action(Event evt,Object obj)
{
return true;

}
}
JEMPLO 9
package proyectos1;
import java.awt.*;
import java.applet.Applet;

public class Ej9 extends Applet {
int xInic,yinic, ancho,alto;
Color colorCuad;
@Override
public void init(){
xInic=10;
yinic=20;
ancho=100;
alto=200;
colorCuad=Color.blue;


}
public void paint(Graphics g)
{
g.setColor(colorCuad);
g.fillRect(xInic,yinic,ancho,alto);

}

}
JEMPLO 10
package proyectos1;
import java.awt.*;
import java.applet.Applet;
public class Ej10 extends Applet {
int xInic,yinic,ancho,alto;
Color colorCuad;
Button btnAumenta,btnDisminuye;
@Override
public void init() {
btnDisminuye=new Button("Disminuye ancho");
add(btnDisminuye);
btnAumenta=new Button("Aumenta ancho");
add(btnAumenta);
xInic=10;
yinic=20;
ancho=100;
alto=200;
colorCuad=Color.blue;
}
public void paint(Graphics g)
{
g.setColor(colorCuad);
g.fillRect(xInic,yinic,ancho,alto);
}
public boolean action(Event evt,Object obj)
{
if(evt.target instanceof Button)
{
if(obj.toString().equals("Aumenta ancho"))
{
ancho=ancho+10;
repaint();
}
if(obj.toString().equals("Disminuye ancho"))
{
ancho=ancho-10;
repaint();

}
}
return true;

}

}
JEMPLO 11
package proyectos1;
import java.awt.*;
import java.applet.Applet;
public class Ej11 extends Applet {
int xInic,yinic,ancho,alto;
Color colorCuad;
Button btnAumenta,btnDisminuye;
@Override
public void init() {
btnDisminuye=new Button("Disminuye ancho");
add(btnDisminuye);
btnAumenta=new Button("Aumenta ancho");
add(btnAumenta);
xInic=10; yinic=20;
ancho=100; alto=200; colorCuad=Color.blue;
}
public void paint(Graphics g)
{
g.setColor(colorCuad); g.fillRect(xInic,yinic,ancho,alto);
}
public boolean action(Event evt,Object obj)
{
if(evt.target instanceof Button)
{
if(obj.toString().equals("Aumenta ancho"))
{
ancho=ancho+10; repaint();
}
if(obj.toString().equals("Disminuye ancho"))
{
ancho=ancho-10; repaint();

}
}
return true;

}

}

NOTA: ESTOS EJEMPLOS SON EJECUATOS EN NETBEANS 6.8

lunes, 26 de abril de 2010

Act 220310_2-SIMULACION DE UNA RED NEURONAL


FIG.1

FIG.2

FIG.3

GENERACION DE LAS ITERACIONES.


CODIGO FUENTE.
mport javax.swing.*;
public class neuron{
public static void main (String args[])
{

double p[]={2,0,-2,0};
double pp[] ={1,-1,1,2};

double b,c,a,w11,w12,p1,p2,t,e;
for (int i=0;i<=3;i++){ w11= 3.3; w12= -1.8; b=0.5; p1= (p[i]* w11); p2=(pp[i] *w12); c=(p1+p2+b); if(c>0){
a=1;
t=1;
e=b-b;
JOptionPane.showMessageDialog(null," Jhon Charly,kirycorp y Megan"+"\n"+" iteracion numero "+i+"\n"+" n= "+c+"\n"+
" a= "+a+"\n"+" t= "+t+"\n"+" e= "+e+"\n"+" w11= "+w11+"\n"+" w12= "+w12) ;
System.out.println("iteracion #="+i);
System.out.println("n="+c);
System.out.println("a="+a);
System.out.println("t="+t);
System.out.println("e="+e);
System.out.println("w11="+w11);
System.out.println("w12="+w12);
}else if(c<0){

a=-1;
t=-1;
e=b-b;
JOptionPane.showMessageDialog(null," Jhon Charly,kirycorp y Megan"+"\n"+" iteracion numero "+i+"\n"+" n= "+c+"\n"+
" a= "+a+"\n"+" t= "+t+"\n"+" e= "+e+"\n"+" w11= "+w11+"\n"+" w12= "+w12) ;
System.out.println("iteracion #="+i);
System.out.println("n="+c);
System.out.println("a="+a);
System.out.println("t="+t);
System.out.println("e="+e);
System.out.println("w11="+w11);
System.out.println("w12="+w12);
}
}
}
}

miércoles, 21 de abril de 2010

SIMULACION DE UNA NEURONA










CODIGO FUENTE
import javax.swing.*;
public class neurona{
public static void main (String args[])
{
int arreglo[];
arreglo=new int[10];
int entrada[];
entrada=new int[10];
int peso[];
peso=new int[10];
int total[];
total=new int[10];

int b,c,m,x,en,pe,f1,z,g,a,y;

String p, a1,k,f,t;
a1= JOptionPane.showInputDialog("introduce el numero de entradas");
b= Integer.parseInt(a1);

for (int i=1;i<=b;i++){
p= JOptionPane.showInputDialog("introduce la entrada numero"+i);
x= Integer.parseInt(p);
en=x;
entrada[i]=en;


k= JOptionPane.showInputDialog("INTRODUCE EL PESO #"+i);
m= Integer.parseInt(k);

pe=m;
peso[i]=pe;

z=(en*pe);
total[i]=z;
}
for (int i=1;i<=b;i++){
g=(total[i--]+total[i++]);
g=g+(i+1);
//System.out.println("n="+g);
if(g<0){
a=0;
System.out.println("n="+g+"a="+a);
}
else if(g>=0){
a=1;
System.out.println("n="+g+"a="+a);
}
}

String salida="contador\tentrada\tpeso\tmultiplicacion";
for (int contador=0;contadorsalida+=contador+"\t"+entrada[contador]+"\t"
+peso[contador]+"\t"+total[contador]+"\n";

JTextArea areaSalida=new JTextArea();
areaSalida.setText(salida);

JOptionPane.showMessageDialog(null,areaSalida,"formula de hardlim",
JOptionPane.INFORMATION_MESSAGE);

}
}

martes, 6 de abril de 2010

ACT250310-2-ESTRUCTURAAGENTECONARREGLOS-ADAYA MORALES ERIC-MARTINEZ HERNANDEZ JUAN CARLOS-ERIKA MAGAILI MORALES TINIDAD










CODIGO FUENTE
import javax.swing.JOptionPane;

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

/*
* JFrame_LIMAGENTE.java
*
* Created on 5/04/2010, 05:23:57 PM
*/

/**
*
* @author Administrador
*/
public class JFrame_LIMAGENTE extends javax.swing.JFrame {

/** Creates new form JFrame_LIMAGENTE */

public JFrame_LIMAGENTE() {
initComponents();

}

/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
//
private void initComponents() {

jButton1 = new javax.swing.JButton();
jPanel1 = new javax.swing.JPanel();
jSeparator1 = new javax.swing.JSeparator();
jTextField1 = new javax.swing.JTextField();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jButton2 = new javax.swing.JButton();
jLabel4 = new javax.swing.JLabel();
jTextField2 = new javax.swing.JTextField();
jSeparator2 = new javax.swing.JSeparator();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
jLabel10 = new javax.swing.JLabel();
jTextField3 = new javax.swing.JTextField();
jLabel11 = new javax.swing.JLabel();
jLabel12 = new javax.swing.JLabel();
jLabel13 = new javax.swing.JLabel();
jLabel14 = new javax.swing.JLabel();
jLabel15 = new javax.swing.JLabel();
jLabel16 = new javax.swing.JLabel();
jPanel2 = new javax.swing.JPanel();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setBackground(new java.awt.Color(204, 204, 204));

jButton1.setText("Iniciar");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});

jPanel1.setBackground(new java.awt.Color(0, 255, 51));
jPanel1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(66, 66, 66)
.addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(85, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 103, Short.MAX_VALUE)
);

jLabel1.setFont(new java.awt.Font("Arial Black", 1, 18));
jLabel1.setText("Super Agente limpiador con un arreglo ");

jLabel2.setFont(new java.awt.Font("Arial Black", 1, 18));
jLabel2.setText("Area De Simulacion");

jLabel3.setFont(new java.awt.Font("Arial Black", 1, 18));
jLabel3.setText("Persepcion");

jButton2.setText("Limpiar valor");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});

jLabel4.setFont(new java.awt.Font("Tahoma", 0, 8));
jLabel4.setText("Todos los derechos reservados por sk!");

jLabel5.setText("Datos de Simulacion");

jLabel6.setText("0=Sucio");

jLabel7.setText("1=limpia");

jLabel8.setText(".");

jLabel9.setText("Lado \"b\"");

jLabel10.setText("Resultado");

jLabel11.setText("Estado inicial del AGENTE");

jLabel12.setText("Apagado");

jLabel13.setText("3=basura");

jLabel14.setText("4=escombro");

jLabel15.setText("2=polvo");

jLabel16.setText("5=agua");

jPanel2.setBackground(new java.awt.Color(255, 0, 255));
jPanel2.setBorder(javax.swing.BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(255, 255, 0)));
jPanel2.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));

javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 42, Short.MAX_VALUE)
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 40, Short.MAX_VALUE)
);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(48, 48, 48)
.addComponent(jLabel11)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 295, Short.MAX_VALUE)
.addComponent(jLabel2)
.addGap(275, 275, 275))
.addGroup(layout.createSequentialGroup()
.addGap(83, 83, 83)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jButton1)
.addGroup(layout.createSequentialGroup()
.addGap(29, 29, 29)
.addComponent(jLabel12)
.addGap(18, 18, 18)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel7)
.addComponent(jLabel6)
.addComponent(jLabel15))
.addGroup(layout.createSequentialGroup()
.addGap(6, 6, 6)
.addComponent(jLabel5)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel14)
.addComponent(jLabel16)
.addComponent(jLabel13))
.addGap(193, 193, 193)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(183, 183, 183)
.addComponent(jLabel8))
.addGroup(layout.createSequentialGroup()
.addGap(84, 84, 84)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(190, 190, 190)
.addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(10, 10, 10)
.addComponent(jLabel3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addGroup(layout.createSequentialGroup()
.addComponent(jButton2)
.addGap(181, 181, 181)
.addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, 270, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(44, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(507, Short.MAX_VALUE)
.addComponent(jLabel10)
.addGap(394, 394, 394))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(308, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel1))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jLabel9)
.addGap(18, 18, 18)
.addComponent(jLabel4)
.addGap(13, 13, 13))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel9)
.addComponent(jLabel4))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel1)
.addGap(10, 10, 10)
.addComponent(jLabel11)
.addGap(1, 1, 1)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel12, javax.swing.GroupLayout.Alignment.TRAILING))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(101, 101, 101)
.addComponent(jLabel15))
.addGroup(layout.createSequentialGroup()
.addGap(22, 22, 22)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(63, 63, 63)
.addComponent(jLabel8)
.addGap(20, 20, 20))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(28, 28, 28)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel10)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton1)
.addComponent(jButton2)
.addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))))
.addGroup(layout.createSequentialGroup()
.addGap(44, 44, 44)
.addComponent(jLabel2)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(59, 59, 59)
.addComponent(jLabel5)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel6)
.addComponent(jLabel13))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel7)
.addComponent(jLabel14))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jLabel16))
.addGroup(layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))))
.addGap(50, 50, 50)
.addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap())
);

pack();
}//


private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:


int x,pas,i,j,pas2;
String persepcion,resul =" ";
//extrallendo valos del tex
persepcion=jTextField1.getText();
x=Integer.parseInt(persepcion);
pas=resEstado(x);


if(pas==00){
jPanel2.setLocation(630,120);
jTextField3.setText("La zona ya esta Limpia");
JOptionPane.showMessageDialog(null,"La zona ya esta Limpia","Ejemplo de agente simple primer parcial",JOptionPane.PLAIN_MESSAGE);

pas2=mejorsolucion(pas);
}

if(pas==11){
jPanel2.setLocation(670,90);
jTextField3.setText("No hay que hacer nada por que esta limpio");
JOptionPane.showMessageDialog(null,"No hay que hacer nada","Ejemplo de agente simple primer parcial",JOptionPane.PLAIN_MESSAGE);

}
if(pas==12){
jPanel2.setLocation(630,130);
jTextField3.setText("Zona ya ha sido limpiadoa de polvo ");
JOptionPane.showMessageDialog(null,"solo hay que limpiar el polvo","Ejemplo de agente simple primer parcial",JOptionPane.PLAIN_MESSAGE);

}
if(pas==13){
jPanel2.setLocation(670,130);
jTextField3.setText("Hay que recoger la basura conforme su tipo");
JOptionPane.showMessageDialog(null,"la zona 4 esta libre de basura","Ejemplo de agente simple primer parcial",JOptionPane.PLAIN_MESSAGE);

}
if(pas==14){
jPanel2.setLocation(680,130);
jTextField3.setText("El esconbro es un desecho muy contaminate");
JOptionPane.showMessageDialog(null,"Escombro retirado","Ejemplo de agente simple primer parcial",JOptionPane.PLAIN_MESSAGE);

}
if(pas==15){
jPanel2.setLocation(650,120);
jTextField3.setText("No hay que hacer nada");
JOptionPane.showMessageDialog(null,"no puedo hacer nada","Ejemplo de agente simple primer parcial",JOptionPane.PLAIN_MESSAGE);

}




}

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
jTextField1.setText(" ");
jTextField2.setText(" ");
jPanel2.setLocation(69,59);
JOptionPane.showMessageDialog(null,"Valores Borrados","Ejemplo de agente simple primer parcial",JOptionPane.PLAIN_MESSAGE);
// TODO add your handling code here:
}

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new JFrame_LIMAGENTE().setVisible(true);
}
});
}

// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel14;
private javax.swing.JLabel jLabel15;
private javax.swing.JLabel jLabel16;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JSeparator jSeparator1;
private javax.swing.JSeparator jSeparator2;
private javax.swing.JTextField jTextField1;
private javax.swing.JTextField jTextField2;
private javax.swing.JTextField jTextField3;
// End of variables declaration
public static int resEstado(int res1){
int resFx;
resFx=0;
if(res1==0){
resFx=00;
}
if(res1==1){
resFx=11;
}
if(res1==2){
resFx=12;
}
if(res1==3){
resFx=13;
}
if(res1==4){
resFx=14;
}
if(res1==5){
resFx=15;
}

return resFx;

}

public static int mejorsolucion(int res1){
String Msolucion[]={"Nohacernada","Limpiar","Liampiaragua","recogerbasura","detectectopolvo","sacudo"};
int accion=0,j;
String resf=" ";
for(j=0;j<=1;j++){

resf+=Msolucion[j]+" ";
}
return accion;

}

}

ACT250310-1-ESTRUCTURAAGENTE-ADAYA MORALES ERIC-ERIKA MAGALI MORALES TRINIDAD- JUAN CARLOS MARTINEZ HERNANDEZ






CODIGO FUENTE
import javax.swing.JOptionPane;

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

/*
* JFrame_LIMAGENTE.java
*
* Created on 5/04/2010, 05:23:57 PM
*/

/**
*
* @author Administrador
*/
public class JFrame_LIMAGENTE extends javax.swing.JFrame {

/** Creates new form JFrame_LIMAGENTE */
public String Msolucion[]={"Nohacernada","Limpiar"};
public JFrame_LIMAGENTE() {
initComponents();

}

/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
//
private void initComponents() {

jButton1 = new javax.swing.JButton();
jPanel1 = new javax.swing.JPanel();
jSeparator1 = new javax.swing.JSeparator();
jTextField1 = new javax.swing.JTextField();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jButton2 = new javax.swing.JButton();
jLabel4 = new javax.swing.JLabel();
jTextField2 = new javax.swing.JTextField();
jSeparator2 = new javax.swing.JSeparator();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
jPanel2 = new javax.swing.JPanel();
jLabel10 = new javax.swing.JLabel();
jTextField3 = new javax.swing.JTextField();
jLabel11 = new javax.swing.JLabel();
jLabel12 = new javax.swing.JLabel();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setBackground(new java.awt.Color(204, 204, 204));

jButton1.setText("Iniciar");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});

jPanel1.setBackground(new java.awt.Color(51, 153, 255));
jPanel1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(66, 66, 66)
.addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(80, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 64, Short.MAX_VALUE)
);

jLabel1.setFont(new java.awt.Font("Arial Black", 1, 18));
jLabel1.setText("Super Agente limpiador!! ");

jLabel2.setFont(new java.awt.Font("Arial Black", 1, 18));
jLabel2.setText("Area De Simulacion");

jLabel3.setFont(new java.awt.Font("Arial Black", 1, 18));
jLabel3.setText("Persepcion");

jButton2.setText("Limpiar valor");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});

jLabel4.setFont(new java.awt.Font("Tahoma", 0, 8));
jLabel4.setText("Todos los derechos reservados por sk!");

jLabel5.setText("Datos de Simulacion");

jLabel6.setText("0=Sucio");

jLabel7.setText("1=limpia");

jLabel8.setText(".");

jLabel9.setText("Lado \"b\"");

jPanel2.setBackground(new java.awt.Color(255, 102, 51));
jPanel2.setBorder(javax.swing.BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(255, 255, 0)));
jPanel2.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));

javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 42, Short.MAX_VALUE)
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 40, Short.MAX_VALUE)
);

jLabel10.setText("Resultado");

jLabel11.setText("Estado inicial del AGENTE");

jLabel12.setText("Apagado");

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(77, 77, 77)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(8, 8, 8)
.addComponent(jButton1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButton2)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(415, 415, 415)
.addComponent(jLabel10))
.addGroup(layout.createSequentialGroup()
.addGap(325, 325, 325)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, 172, javax.swing.GroupLayout.PREFERRED_SIZE)))))
.addGroup(layout.createSequentialGroup()
.addGap(19, 19, 19)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel7)
.addComponent(jLabel6)))
.addGroup(layout.createSequentialGroup()
.addGap(25, 25, 25)
.addComponent(jLabel5)))
.addContainerGap(20, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(425, Short.MAX_VALUE)
.addComponent(jLabel3)
.addGap(221, 221, 221))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(532, Short.MAX_VALUE)
.addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel9)
.addGap(18, 18, 18)
.addComponent(jLabel4)
.addContainerGap())
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(29, 29, 29)
.addComponent(jLabel12)
.addGap(27, 27, 27)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(265, 265, 265)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel8))
.addGap(72, 72, 72)
.addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(136, 136, 136))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel2)
.addGap(180, 180, 180))))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(274, Short.MAX_VALUE)
.addComponent(jLabel1)
.addGap(218, 218, 218))
.addGroup(layout.createSequentialGroup()
.addGap(48, 48, 48)
.addComponent(jLabel11)
.addContainerGap(598, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel1)
.addGap(10, 10, 10)
.addComponent(jLabel11)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addGap(18, 18, 18)
.addComponent(jLabel8))
.addGroup(layout.createSequentialGroup()
.addGap(85, 85, 85)
.addComponent(jLabel5)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel6)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel7)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton1)
.addComponent(jButton2))))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 74, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(152, 152, 152)
.addComponent(jLabel10)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(68, 68, 68)))
.addComponent(jLabel4))
.addGroup(layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel9))))
.addGroup(layout.createSequentialGroup()
.addGap(29, 29, 29)
.addComponent(jLabel12)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 260, Short.MAX_VALUE)
.addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
);

pack();
}//


private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:


int x,pas,i,j;
String persepcion,resul =" ";
//extrallendo valos del tex
persepcion=jTextField1.getText();
x=Integer.parseInt(persepcion);
pas=resEstado(x);


if(pas==00){
jPanel2.setLocation(430,120);
jTextField3.setText("La zona ya esta Limpia");
JOptionPane.showMessageDialog(null,"La zona ya esta Limpia","Ejemplo de agente simple primer parcial",JOptionPane.PLAIN_MESSAGE);


}

if(pas==11){
jPanel2.setLocation(520,120);
jTextField3.setText("No hay que hacer nada");
JOptionPane.showMessageDialog(null,"No hay que hacer nada","Ejemplo de agente simple primer parcial",JOptionPane.PLAIN_MESSAGE);

}




}

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
jTextField1.setText(" ");
jTextField2.setText(" ");
jPanel2.setLocation(69,59);
JOptionPane.showMessageDialog(null,"Valores Borrados","Ejemplo de agente simple primer parcial",JOptionPane.PLAIN_MESSAGE);
// TODO add your handling code here:
}

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new JFrame_LIMAGENTE().setVisible(true);
}
});
}

// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JSeparator jSeparator1;
private javax.swing.JSeparator jSeparator2;
private javax.swing.JTextField jTextField1;
private javax.swing.JTextField jTextField2;
private javax.swing.JTextField jTextField3;
// End of variables declaration
public static int resEstado(int res1){
int resFx;
resFx=0;
if(res1==0){
resFx=00;
}
if(res1==1){
resFx=11;
}

return resFx;

}











}