code
stringlengths
1
2.01M
repo_name
stringlengths
3
62
path
stringlengths
1
267
language
stringclasses
231 values
license
stringclasses
13 values
size
int64
1
2.01M
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ /* * NewJFrame.java * * Created on 2009-12-17, 16:20:22 */ /** * * @author Stan */ public class NewJFrame extends javax.swing.JFrame { /** Creates new form NewJFrame */ public NewJFrame() { 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") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jPanel1 = new javax.swing.JPanel(); jButton1 = new javax.swing.JButton(); jButton2 = new javax.swing.JButton(); jButton3 = new javax.swing.JButton(); jButton4 = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jButton1.setText("Products"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); jButton2.setText("Inventories"); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); } }); jButton3.setText("InventProduct"); jButton3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton3ActionPerformed(evt); } }); jButton4.setText("Exit"); jButton4.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton4ActionPerformed(evt); } }); 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(36, 36, 36) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(jButton4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jButton1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jButton2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jButton3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap()) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() .addComponent(jButton1) .addGap(18, 18, 18) .addComponent(jButton2) .addGap(18, 18, 18) .addComponent(jButton3) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jButton4) .addContainerGap(24, 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(24, 24, 24) .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(49, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(73, 73, 73)) ); pack(); }// </editor-fold>//GEN-END:initComponents private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed new Products().setVisible(true); }//GEN-LAST:event_jButton1ActionPerformed private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed this.setVisible(false); }//GEN-LAST:event_jButton4ActionPerformed private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed new Inventories().setVisible(true); }//GEN-LAST:event_jButton2ActionPerformed private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed new InventProducts().setVisible(true); }//GEN-LAST:event_jButton3ActionPerformed /** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new NewJFrame().setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JButton jButton3; private javax.swing.JButton jButton4; private javax.swing.JPanel jPanel1; // End of variables declaration//GEN-END:variables }
11839806-cp2004-assignment2
trunk/cp2004/src/NewJFrame.java
Java
asf20
6,466
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ /* * Inventories.java * * Created on 2009-12-18, 15:45:12 */ /** * * @author Stan */ public class Inventories extends javax.swing.JFrame { /** Creates new form Inventories */ public Inventories() { 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") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jPanel1 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); jScrollPane1 = new javax.swing.JScrollPane(); jTextArea1 = new javax.swing.JTextArea(); jButton1 = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jLabel1.setFont(new java.awt.Font("宋体", 1, 18)); // NOI18N jLabel1.setText("Inventories"); jTextArea1.setColumns(20); jTextArea1.setRows(5); jTextArea1.setText("No:1 Name:Valve Num:10600 Describe:a Item of car\nNo:2 Name:Over Head Camshaft Num:20100 Describe:a Item of car\nNo:3 Name:Cylinder Block Num:14590 Describe:a Item of car\nNo:4 Name:Crank Shaft Num:7500 Describe:a Item of car\nNo:5 Name:Intake Valve Num:9800 Describe:a Item of car\nNo:6 Name:Camshaft Num:28900 Describe:a Item of car\nNo:7 Name:Fuel Pump Num:34200 Describe:a Item of car"); jScrollPane1.setViewportView(jTextArea1); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jLabel1) .addContainerGap(406, Short.MAX_VALUE)) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 516, Short.MAX_VALUE) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jLabel1) .addGap(18, 18, 18) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 237, Short.MAX_VALUE)) ); jButton1.setText("Back"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(layout.createSequentialGroup() .addComponent(jButton1) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .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, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jButton1)) ); pack(); }// </editor-fold>//GEN-END:initComponents private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed this.setVisible(false); }//GEN-LAST:event_jButton1ActionPerformed /** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new Inventories().setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton jButton1; private javax.swing.JLabel jLabel1; private javax.swing.JPanel jPanel1; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JTextArea jTextArea1; // End of variables declaration//GEN-END:variables }
11839806-cp2004-assignment2
trunk/cp2004/src/Inventories.java
Java
asf20
4,779
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ /* * Products.java * * Created on 2009-12-18, 15:29:09 */ /** * * @author Stan */ public class Products extends javax.swing.JFrame { /** Creates new form Products */ public Products() { 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") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jPanel1 = new javax.swing.JPanel(); jScrollPane1 = new javax.swing.JScrollPane(); jTextArea1 = new javax.swing.JTextArea(); jLabel1 = new javax.swing.JLabel(); jButton1 = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jTextArea1.setColumns(20); jTextArea1.setRows(5); jTextArea1.setText("No:1 Name:Chery-S16 Describe:Chery Auto plans to start produce this new mini car in April or May 2009\nNo:2 Name:Chery-A5 Describe:Chinese carmaker Chery Automobile announced that chery's two car\nNo:3 Name:Chery-QQ6 Describe:Chery Auto car new mini car"); jScrollPane1.setViewportView(jTextArea1); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() .addContainerGap(22, Short.MAX_VALUE) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 515, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap()) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(105, 105, 105)) ); jLabel1.setText("Products"); jButton1.setText("Back"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel1) .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup() .addGap(25, 25, 25) .addComponent(jButton1) .addContainerGap(475, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 20, Short.MAX_VALUE) .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 152, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(jButton1) .addGap(64, 64, 64)) ); pack(); }// </editor-fold>//GEN-END:initComponents private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed this.setVisible(false); }//GEN-LAST:event_jButton1ActionPerformed /** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new Products().setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton jButton1; private javax.swing.JLabel jLabel1; private javax.swing.JPanel jPanel1; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JTextArea jTextArea1; // End of variables declaration//GEN-END:variables }
11839806-cp2004-assignment2
trunk/cp2004/src/Products.java
Java
asf20
5,159
package { import flash.display.MovieClip; public class Gameover extends MovieClip { public function Gameover() { // constructor codeddd } } }
1205dsdsh
trunk/Gameover.as
ActionScript
mit
184
package { import flash.display.MovieClip; public class Tiao extends MovieClip { public function Tiao() { // constructor codenddd } } }
1205dsdsh
trunk/Tiao.as
ActionScript
mit
177
package { import flash.display.MovieClip; import flash.utils.Timer; import flash.events.TimerEvent; import flash.text.TextField; import flash.text.TextFormat; import flash.events.Event; //ssss public class Main extends MovieClip { private var arr:Array = []; private var timer:Timer = new Timer(1000,61); private var timeText:TextField=new TextField(); private var timeTextFormat:TextFormat=new TextFormat(); private var tiao:Tiao; public function Main() { for (var i:int=0; i<10; i++) { var star:Star=new Star(); star.x = Math.random() * 550; star.y = Math.random() * 400; arr.push(star); this.addChild(star); } this.addEventListener(Event.ENTER_FRAME,onFrame); timeTextFormat.size = 30; timeTextFormat.color = 0x0000ff; timeText.defaultTextFormat = timeTextFormat; timeText.text = '00' + timer.repeatCount + ''; timer.addEventListener(TimerEvent.TIMER,onTimer); timer.start(); } private function onFrame(e:Event):void { for (var i in arr) { arr[i].moves(); } } private function onTimer(e:TimerEvent):void { timeText.text='00:'+(timer.repeatCount-timer.currentCount); timeText.x = 456; timeText.y = 368; this.addChild(timeText); if (timer.repeatCount - timer.currentCount == 55) { timeTextFormat.color = 0xff0000; timeText.defaultTextFormat = timeTextFormat; tiao=new Tiao(); this.addChild(tiao); } else if (timer.repeatCount - timer.currentCount <= 50) { timer.stop(); for(var i:int=0;i<numChildren+22;i++ ) { removeChildAt(0) } var gameover:Gameover=new Gameover(); this.addChild(gameover); trace(numChildren) } } } }
1205dsdsh
trunk/Main.as
ActionScript
mit
1,786
package { import flash.display.MovieClip; import flash.events.Event; //sss public class Star extends MovieClip { private var speed:Number=Math.random()*2+4; public function Star() { } public function moves():void { this.rotation+=10; this.y+=speed; if(this.y>550) { this.x=Math.random()*550; this.y=0; } } } }
1205dsdsh
trunk/Star.as
ActionScript
mit
402
!function ($) { $(function(){ $('.dropdown-toggle').dropdown() $('.navbar').scrollspy() $(".collapse").collapse() // make code pretty window.prettyPrint && prettyPrint() }) }(window.jQuery)
1234qwerasdfzxcv
trunk/init.js
JavaScript
asf20
215
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Language" content="zh-CN" /> <meta name="roots" content="" /> <meta name="Keywords" content="" /> <meta name="Description" content="" /> <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" /> <link rel="start" href="" title="Home" /> <title>经销商后台管理系统</title> <link href="../css3/global.css" type="text/css" rel="stylesheet" media="screen" /> <link href="../css3/jxs.css" type="text/css" rel="stylesheet" media="screen" /> </head> <body> <div id="Header"> <dl> <dt><a href="http://www.91bi.com" title="易比网首页"><img src="../img3/jxs/12.gif" alt="易比网"/></a></dt> <dd><strong>您好!XXX</strong> <a href="login.htm" title="退出" class="quite">退出</a> | <a href="login.htm" title="我的易比">用户登录</a> | <a href="#" title="易比首页">易比首页</a></dd> </dl> <span class="con R"></span> </div><!--$Header END--> <div id="Wrapper"> <div class="left"> <h3><img src="../img3/jxs/15.gif" alt="系统首页" /></h3> <ul class="main_nav"> <li><a href="#" title="产品报价管理">产品报价管理</a> <ul class="main_nav_drop"> <li><a href="jxs_baojia.htm" title="新产品报价">新产品报价</a></li> <li><a href="jxs_yibaojia.htm" title="已报价产品">已报价产品</a></li> </ul> </li> <li><a href="jxs_zixun.htm" title="用户咨询">用户咨询</a></li> <li><a href="jxs_ziliao.htm" title="修改资料">修改资料</a></li> <li><a href="jxs_mima.htm" title="修改密码">修改密码</a></li> </ul> <p><a href="jxs_gonggao.htm" title="易比公告">易比公告</a><br /><a href="jxs_jianyi.htm" title="给易比建议">给易比建议</a></p> <span class="con B"></span> </div><!--left END--> <div class="right yibaojia"> <img src="../img3/jxs/1.jpg" alt="经销商后台管理系统" /> <div class="con_tt"> <h3>易比公告</h3> </div><!--con_tt END--> <div class="con_txt baojiasearch_con_txt"> <table width="100%" border="0" cellspacing="0" cellpadding="0" class="baojia_table zixun_table" id="right_con_table"> <tr> <th width="79%">&nbsp;公告标题</th> <th width="21%" align="center">2008-11-11</th> </tr> <tr> <td colspan="2" style="text-align:left; padding:5px;border:solid #7e9db9 1px;height:100px; vertical-align:top;">洗先生洗先生洗先生洗先生洗先生洗先生洗先生洗先生洗先生洗先生洗先生洗先生</td> </tr> </table> </div> <!--con_txt END--> <!--con_tt END--> <!--con_txt END--> </div> <!--right END--> </div><!--$Main END--> <div id="Footer"> <img src="../img3/jxs/26.gif" /> </div><!--$Footer END--> </body> </html>
08codework
trunk/91bi/htm/jxs_gonggao.htm
HTML
mpl11
2,990
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Language" content="zh-CN" /> <meta name="roots" content="" /> <meta name="Keywords" content="" /> <meta name="Description" content="" /> <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" /> <link rel="start" href="" title="Home" /> <title>找回密码</title> <link href="../css3/global.css" type="text/css" rel="stylesheet" media="screen" /> <link href="../css3/login_reg.css" type="text/css" rel="stylesheet" media="screen" /> <script language="javascript" type="text/jscript"> function chaCss(o,bg,bor){ o.style.borderColor = bg; o.style.backgroundColor = bor; } var caiying2007; var bg_out="#d2d2d2",border_out="#FFFFFF";//指向时样式颜色 var bg_over="#FF9900",border_over="#FFFFEC";//离开时样式颜色 function changbg(obj){ if (!obj.cssColor)obj.cssColor=0 if (obj.cssColor!=1){chaCss(obj,bg_over,border_over);} obj.onmouseout = function(){ if (this.cssColor==0) chaCss(this,bg_out,border_out); } obj.onblur= function(){ this.cssColor=0; chaCss(this,bg_out,border_out); } obj.onfocus= function(){ if (caiying2007 && caiying2007!=this){caiying2007.cssColor=0;caiying2007=this} this.cssColor=1; } } </script> </head> <body> <div id="Header"> <dl> <dt><a href="http://www.91bi.com" title="易比网首页"><img src="../img3/jxs/logo.gif" alt="易比网"/></a></dt> <dd><a href="login.htm" title="用户登录">用户登录</a> | <a href="#" title="帮助">帮助</a></dd> </dl> </div><!--$Header END--> <div id="Wrapper"> <div class="findpassword"> <h3>您的新登录密码已生效!</h3> <p>您可以在登录后对密码进行修改,<a href="login.htm" title="登录易比网">点击这里</a>登录易比网</p> </div><!--$findpassword END--> </div><!--$Main END--> <div id="Footer"> <img src="../img3/jxs/26.gif" /> </div><!--$Footer END--> </body> </html>
08codework
trunk/91bi/htm/findpassword_2.htm
HTML
mpl11
2,163
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Language" content="zh-CN" /> <meta name="roots" content="" /> <meta name="Keywords" content="" /> <meta name="Description" content="" /> <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" /> <link rel="start" href="" title="Home" /> <title>经销商后台管理系统</title> <link href="../css3/global.css" type="text/css" rel="stylesheet" media="screen" /> <link href="../css3/jxs.css" type="text/css" rel="stylesheet" media="screen" /> </head> <body> <div id="Header"> <dl> <dt><a href="http://www.91bi.com" title="易比网首页"><img src="../img3/jxs/12.gif" alt="易比网"/></a></dt> <dd><strong>您好!XXX</strong> <a href="login.htm" title="退出" class="quite">退出</a> | <a href="login.htm" title="我的易比">用户登录</a> | <a href="#" title="易比首页">易比首页</a></dd> </dl> <span class="con R"></span> </div><!--$Header END--> <div id="Wrapper"> <div class="left"> <h3><img src="../img3/jxs/15.gif" alt="系统首页" /></h3> <ul class="main_nav"> <li><a href="#" title="产品报价管理">产品报价管理</a> <ul class="main_nav_drop"> <li><a href="jxs_baojia.htm" title="新产品报价">新产品报价</a></li> <li><a href="jxs_yibaojia.htm" title="已报价产品">已报价产品</a></li> </ul> </li> <li><a href="jxs_zixun.htm" title="用户咨询">用户咨询</a></li> <li><a href="jxs_ziliao.htm" title="修改资料" class="on">修改资料</a></li> <li><a href="jxs_mima.htm" title="修改密码">修改密码</a></li> </ul> <p><a href="jxs_gonggao.htm" title="易比公告">易比公告</a><br /><a href="jxs_jianyi.htm" title="给易比建议">给易比建议</a></p> <span class="con B"></span> </div><!--left END--> <div class="right yibaojia"> <img src="../img3/jxs/1.jpg" alt="经销商后台管理系统" /> <div class="con_tt"> <h3>修改资料</h3> </div><!--con_tt END--> <div class="con_txt baojiasearch_con_txt"> <p class="tips" style="color:#fe0000;font-size:12px;">温馨提示:<br /> 1.带*号为必填项<br /> 2.如果您的经营方式是实体或者实体和网络结合,请务必填写您的营业执照号,并将营业执照复印件传真给我们,待我们审核通过后,您才能进行产品报价。</p> <table width="90%" border="0" cellspacing="0" cellpadding="0" class="ziliao_con"> <tr> <td align="right"><span>*</span>企业名称:</td> <td><input type="text" /></td> </tr> <tr> <td align="right"><span>*</span>企业类型:</td> <td><select><option>--请选择--</option></select></td> </tr> <tr> <td align="right"><span>*</span>经营方式:</td> <td><select><option>--请选择--</option></select></td> </tr> <tr> <td align="right"><span>*</span>营业执照号:</td> <td><input type="text" /></td> </tr> <tr> <td align="right">公司网址:</td> <td><input type="text" /></td> </tr> <tr> <td align="right">法人代表:</td> <td><input type="text" /></td> </tr> <tr> <td align="right" valign="top"><span>*</span>公司简介:</td> <td valign="top"><textarea cols="50" rows="8"></textarea></td> </tr> <tr> <td align="right"><span>*</span>所在地区:</td> <td><select><option>--请选择--</option></select> <select><option>--请选择--</option></select></td> </tr> <tr> <td align="right"><span>*</span>详细地址:</td> <td><input type="text" /></td> </tr> <tr> <td align="right">邮编:</td> <td><input type="text" /></td> </tr> <tr> <td align="right"><span>*</span>联系人:</td> <td><input type="text" /></td> </tr> <tr> <td align="right"><span>*</span>联系电话:</td> <td><input type="text" /></td> </tr> <tr> <td align="right">邮箱:</td> <td><input type="text" /></td> </tr> <tr> <td align="right">手机:</td> <td><input type="text" /></td> </tr> <tr> <td align="right">QQ号码:</td> <td><input type="text" /> 多个QQ号码请用";"隔开</td> </tr> <tr> <td align="right">&nbsp;</td> <td style="height:50px;"><input type="submit" value="提 交" class="ziliao_button" />&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" value="重 置" class="ziliao_button"/></td> </tr> </table> </div> <!--con_txt END--> <!--con_tt END--> <!--con_txt END--> </div> <!--right END--> </div><!--$Main END--> <div id="Footer"> <img src="../img3/jxs/26.gif" /> </div><!--$Footer END--> </body> </html>
08codework
trunk/91bi/htm/jxs_ziliao.htm
HTML
mpl11
4,959
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Language" content="zh-CN" /> <meta name="roots" content="" /> <meta name="Keywords" content="" /> <meta name="Description" content="" /> <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" /> <link rel="start" href="" title="Home" /> <title>经销商注册 - 填写信息</title> <link href="../css3/global.css" type="text/css" rel="stylesheet" media="screen" /> <link href="../css3/login_reg.css" type="text/css" rel="stylesheet" media="screen" /> <script language="javascript" type="text/jscript"> function chaCss(o,bg,bor){ o.style.borderColor = bg; o.style.backgroundColor = bor; } var caiying2007; var bg_out="#d2d2d2",border_out="#FFFFFF";//指向时样式颜色 var bg_over="#FF9900",border_over="#FFFFEC";//离开时样式颜色 function changbg(obj){ if (!obj.cssColor)obj.cssColor=0 if (obj.cssColor!=1){chaCss(obj,bg_over,border_over);} obj.onmouseout = function(){ if (this.cssColor==0) chaCss(this,bg_out,border_out); } obj.onblur= function(){ this.cssColor=0; chaCss(this,bg_out,border_out); } obj.onfocus= function(){ if (caiying2007 && caiying2007!=this){caiying2007.cssColor=0;caiying2007=this} this.cssColor=1; } } </script> </head> <body> <div id="Header"> <dl> <dt><a href="http://www.91bi.com" title="易比网首页"><img src="../img3/jxs/logo.gif" alt="易比网"/></a></dt> <dd><a href="login.htm" title="用户登录">用户登录</a> | <a href="#" title="帮助">帮助</a></dd> </dl> </div><!--$Header END--> <ul id="Step"> <li class="on"><h2>1.填写信息</h2></li> <li>2.验证邮箱</li> <li>3.注册成功</li> </ul> <div id="Wrapper"> <p class="tpis">*以下均为必填项</p> <fieldset> <div><label>Email地址:</label><input type="text" onmouseover="changbg(this)" class="inputout" id="username"/><p>请填写有效的Email地址,在下一步中您将用此邮箱接收验证邮件</p></div> <div><label>经销商名称:</label><input type="text" onmouseover="changbg(this)" class="inputout" id="password"/></div> <div><label>设置密码:</label><input type="password" onmouseover="changbg(this)" class="inputout" id="repassword"/><p>您的密码可以由大小写英文字母、数字组成,长度6-20位。</p></div> <div><label>确认密码:</label><input type="password" onmouseover="changbg(this)" class="inputout"/><p>请输入一遍您上面输入的密码</p></div> <div><label>验证码:</label><input type="text" onmouseover="changbg(this)" class="inputout"/></div> <div><label></label><label class="checkbox_div" style=" width:20px; text-align:left;"><input type="checkbox" /> </label><a href="#" title="" class="read">阅读经销商会员加盟协议</a></div> <div><label></label><input value="" type="submit" class="btn1" onmouseover="this.className='btn2'" onmouseout="this.className='btn1'" /></div> </fieldset> </div><!--$Main END--> <div id="Footer"> <img src="../img3/jxs/26.gif" /> </div><!--$Footer END--> </body> </html>
08codework
trunk/91bi/htm/jxs_zhuce_1.htm
HTML
mpl11
3,345
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Language" content="zh-CN" /> <meta name="roots" content="" /> <meta name="Keywords" content="" /> <meta name="Description" content="" /> <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" /> <link rel="start" href="" title="Home" /> <title>经销商后台管理系统</title> <link href="../css3/global.css" type="text/css" rel="stylesheet" media="screen" /> <link href="../css3/jxs.css" type="text/css" rel="stylesheet" media="screen" /> </head> <body> <div id="Header"> <dl> <dt><a href="http://www.91bi.com" title="易比网首页"><img src="../img3/jxs/12.gif" alt="易比网"/></a></dt> <dd><strong>您好!XXX</strong> <a href="login.htm" title="退出" class="quite">退出</a> | <a href="login.htm" title="我的易比">用户登录</a> | <a href="#" title="易比首页">易比首页</a></dd> </dl> <span class="con R"></span> </div><!--$Header END--> <div id="Wrapper"> <div class="left"> <h3><img src="../img3/jxs/15.gif" alt="系统首页" /></h3> <ul class="main_nav"> <li><a href="#" title="产品报价管理">产品报价管理</a> <ul class="main_nav_drop"> <li><a href="jxs_baojia.htm" title="新产品报价">新产品报价</a></li> <li><a href="jxs_yibaojia.htm" title="已报价产品">已报价产品</a></li> </ul> </li> <li><a href="jxs_zixun.htm" title="用户咨询" class="on">用户咨询</a></li> <li><a href="jxs_ziliao.htm" title="修改资料">修改资料</a></li> <li><a href="jxs_mima.htm" title="修改密码">修改密码</a></li> </ul> <p><a href="jxs_gonggao.htm" title="易比公告">易比公告</a><br /><a href="jxs_jianyi.htm" title="给易比建议">给易比建议</a></p> <span class="con B"></span> </div><!--left END--> <div class="right yibaojia"> <img src="../img3/jxs/1.jpg" alt="经销商后台管理系统" /> <div class="con_tt"> <h3>用户咨询</h3> </div><!--con_tt END--> <div class="con_txt baojiasearch_con_txt"> <table width="100%" border="0" cellspacing="0" cellpadding="0" class="baojia_table zixun_table" id="right_con_table"> <tr> <th width="9%" align="center">咨询人</th> <th width="55%" align="center">内容</th> <th width="13%" align="center">时间</th> <th width="11%" align="center"> 状态</th> <th align="center">操作</th> </tr> <tr> <td>洗先生</td> <td style="text-align:left;">洗先生洗先生洗先生洗先生洗先生洗先生洗先生洗先生洗先生洗先生洗先生</td> <td>2008-11-23</td> <td><span class="weihuifu">[未回复]</span></td> <td width="12%"><a href="#">回复</a> <a href="#">删除</a></td> </tr> <tr class="gray"> <td>洗先生</td> <td style="text-align:left;">洗先生洗先生洗先生洗先生洗先生洗先生洗先生洗先生洗先生洗先生洗先生</td> <td>2008-11-23</td> <td><span class="yihuifu">[已回复]</span></td> <td><a href="#">回复</a> <a href="#">删除</a></td> </tr> <tr> <td>洗先生</td> <td style="text-align:left;">洗先生洗先生洗先生洗先生洗先生洗先生洗先生洗先生洗先生洗先生洗先生</td> <td>2008-11-23</td> <td><span class="weihuifu">[未回复]</span></td> <td width="12%"><a href="#">回复</a> <a href="#">删除</a></td> </tr> <tr class="huifu_tr"> <td colspan="5"> <table width="90%" border="0" cellpadding="0" cellspacing="0" class="huifu_con"> <tr> <td>洗先生洗先生洗先生洗先生洗先生洗先生洗先生洗先生洗先生洗先生</span><span style="text-align:left;">洗先生洗先生洗先生洗先生洗先生洗先生洗先生洗先生洗先生洗先生</td> </tr> <tr> <td><a href="#">回复</a></td> </tr> </table> </td> </tr> <tr class="gray"> <td>洗先生</td> <td style="text-align:left;">洗先生洗先生洗先生洗先生洗先生洗先生洗先生洗先生洗先生洗先生洗先生</td> <td>2008-11-23</td> <td><span class="weihuifu">[未回复]</span></td> <td width="12%"><a href="#">回复</a> <a href="#">删除</a></td> </tr> </table> <p class="pagelist">共2222跳 第1页/共222页 1 <a href="#">2</a><a href="#">3</a><a href="#">&gt;</a><a href="#">&gt;|</a></p> </div><!--con_txt END--> <!--con_tt END--> <!--con_txt END--> </div> <!--right END--> </div><!--$Main END--> <div id="Footer"> <img src="../img3/jxs/26.gif" /> </div><!--$Footer END--> </body> </html>
08codework
trunk/91bi/htm/jxs_zixun.htm
HTML
mpl11
4,910
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Language" content="zh-CN" /> <meta name="roots" content="" /> <meta name="Keywords" content="" /> <meta name="Description" content="" /> <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" /> <link rel="start" href="" title="Home" /> <title>登录</title> <link href="../css3/global.css" type="text/css" rel="stylesheet" media="screen" /> <link href="../css3/login_reg.css" type="text/css" rel="stylesheet" media="screen" /> </head> <body> <div id="Header"> <dl> <dt><a href="http://www.91bi.com" title="易比网首页"><img src="../img3/jxs/logo.gif" alt="易比网"/></a></dt> <dd><a href="login.htm" title="用户登录">用户登录</a> | <a href="#" title="帮助">帮助</a></dd> </dl> </div><!--$Header END--> <div id="Wrapper"> <a href="#" title="普通会员登录" class="login">普通会员登录</a><a href="jxs_login.htm" title="经销商登录" class="login login_2">经销商登录</a> </div><!--$Main END--> <div id="Footer"> <img src="../img3/jxs/26.gif" /> </div><!--$Footer END--> </body> </html>
08codework
trunk/91bi/htm/login.htm
HTML
mpl11
1,331
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Language" content="zh-CN" /> <meta name="roots" content="" /> <meta name="Keywords" content="" /> <meta name="Description" content="" /> <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" /> <link rel="start" href="" title="Home" /> <title>经销商后台管理系统</title> <link href="../css3/global.css" type="text/css" rel="stylesheet" media="screen" /> <link href="../css3/jxs.css" type="text/css" rel="stylesheet" media="screen" /> </head> <body> <div id="Header"> <dl> <dt><a href="http://www.91bi.com" title="易比网首页"><img src="../img3/jxs/12.gif" alt="易比网"/></a></dt> <dd><strong>您好!XXX</strong> <a href="login.htm" title="退出" class="quite">退出</a> | <a href="login.htm" title="我的易比">用户登录</a> | <a href="#" title="易比首页">易比首页</a></dd> </dl> <span class="con R"></span> </div><!--$Header END--> <div id="Wrapper"> <div class="left"> <h3><img src="../img3/jxs/15.gif" alt="系统首页" /></h3> <ul class="main_nav"> <li><a href="#" title="" class="on">产品报价管理</a> <ul class="main_nav_drop"> <li><a href="jxs_baojia.htm" title="新产品报价">新产品报价</a></li> <li><a href="jxs_yibaojia.htm" title="已报价产品" class="on_on">已报价产品</a></li> </ul> </li> <li><a href="jxs_zixun.htm" title="用户咨询">用户咨询</a></li> <li><a href="jxs_ziliao.htm" title="修改资料">修改资料</a></li> <li><a href="jxs_mima.htm" title="修改密码">修改密码</a></li> </ul> <p><a href="jxs_gonggao.htm" title="易比公告">易比公告</a><br /><a href="jxs_jianyi.htm" title="给易比建议">给易比建议</a></p> <span class="con B"></span> </div><!--left END--> <div class="right yibaojia"> <img src="../img3/jxs/1.jpg" alt="经销商后台管理系统" /> <p class="tips">* 您已对<span>4</span>个类别,<span>11</span>个产品进行了报价(您可以搜索相关产品进行报价,或者删除不再报价产品)</p> <div class="con_tt"> <h3>已产品报价</h3> </div><!--con_tt END--> <div class="con_txt baojiasearch_con_txt"> <table width="100%" border="0" cellspacing="0" cellpadding="0" > <tr align="left"> <td width="9%">产品类别:</td> <td width="15%"><select><option>--请选择--</option></select></td> <td width="5%">品牌:</td> <td width="14%"><select name="select"> <option>--请选择--</option> </select> </td> <td width="23%"><input type="text" /></td> <td width="34%"><input type="submit" value="搜 索" class="search_button" /></td> </tr> </table> <table width="100%" border="0" cellspacing="0" cellpadding="0" class="baojia_table" id="right_con_table"> <tr> <th width="9%" align="center">类型</th> <th width="19%" align="center">品牌/型号</th> <th width="12%" align="center">本次报价</th> <th width="12%" align="center">本次报价</th> <th width="13%" align="center">上次报价时间</th> <th width="9%"><input type="checkbox" />含税</th> <th width="7%"><input type="checkbox" />促销</th> <th width="7%"><input type="checkbox" />邮购</th> <th width="8%"><input type="checkbox" />行货</th> <th></th> </tr> <tr> <td>洗衣机</td> <td>&nbsp;</td> <td><input type="text" style="width:70px;" /></td> <td>3200</td> <td>2008-11-23</td> <td><input type="checkbox" /></td> <td><input type="checkbox" /></td> <td><input type="checkbox" /></td> <td><input type="checkbox" /></td> <td width="4%"><a href=""><img src="../img3/jxs/30.gif" /></a></td> </tr> <tr class="gray"> <td>&nbsp;</td> <td>&nbsp;</td> <td><input type="text" style="width:70px;" /></td> <td>3200</td> <td>&nbsp;</td> <td><input type="checkbox" /></td> <td><input type="checkbox" /></td> <td><input type="checkbox" /></td> <td><input type="checkbox" /></td> <td><a href=""><img src="../img3/jxs/30.gif" /></a></td> </tr> <tfoot> <td colspan="8" style="text-align:left;">注:以上报价均为人民币"元"为报价,默认为含税和行货正品</td> <td colspan="2"><input type="submit" class="baojia_botton" value="提交报价" /></td> </table> <p class="pagelist">共2222跳 第1页/共222页 1 <a href="#">2</a><a href="#">3</a><a href="#">&gt;</a><a href="#">&gt;|</a></p> </div><!--con_txt END--> <!--con_tt END--> <!--con_txt END--> </div> <!--right END--> </div><!--$Main END--> <div id="Footer"> <img src="../img3/jxs/26.gif" /> </div><!--$Footer END--> </body> </html>
08codework
trunk/91bi/htm/jxs_yibaojia.htm
HTML
mpl11
4,972
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Language" content="zh-CN" /> <meta name="roots" content="" /> <meta name="Keywords" content="" /> <meta name="Description" content="" /> <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" /> <link rel="start" href="" title="Home" /> <title>经销商后台管理系统</title> <link href="../css3/global.css" type="text/css" rel="stylesheet" media="screen" /> <link href="../css3/jxs.css" type="text/css" rel="stylesheet" media="screen" /> </head> <body> <div id="Header"> <dl> <dt><a href="http://www.91bi.com" title="易比网首页"><img src="../img3/jxs/12.gif" alt="易比网"/></a></dt> <dd><strong>您好!XXX</strong> <a href="login.htm" title="退出" class="quite">退出</a> | <a href="login.htm" title="我的易比">用户登录</a> | <a href="#" title="易比首页">易比首页</a></dd> </dl> <span class="con R"></span> </div><!--$Header END--> <div id="Wrapper"> <div class="left"> <h3><img src="../img3/jxs/15.gif" alt="系统首页" /></h3> <ul class="main_nav"> <li><a href="#" title="产品报价管理">产品报价管理</a> <ul class="main_nav_drop"> <li><a href="jxs_baojia.htm" title="新产品报价">新产品报价</a></li> <li><a href="jxs_yibaojia.htm" title="已报价产品">已报价产品</a></li> </ul> </li> <li><a href="jxs_zixun.htm" title="用户咨询">用户咨询</a></li> <li><a href="jxs_ziliao.htm" title="修改资料">修改资料</a></li> <li><a href="jxs_mima.htm" title="修改密码">修改密码</a></li> </ul> <p><a href="jxs_gonggao.htm" title="易比公告">易比公告</a><br /><a href="jxs_jianyi.htm" title="给易比建议">给易比建议</a></p> <span class="con B"></span> </div><!--left END--> <div class="right"> <img src="../img3/jxs/1.jpg" alt="经销商后台管理系统" /> <p class="tips">* 温馨提示: 首次登陆,请<a href="#" title="">完善资料</a></p> <div class="con_tt"> <h3>产品报价</h3> </div><!--con_tt END--> <div class="con_txt index_con_txt"> <a href="#" title=""><img src="../img3/jxs/24.gif" alt="" /></a><a href="#" title=""><img src="../img3/jxs/25.gif" alt="" /></a> </div><!--con_txt END--> <div class="con_tt"> <h3>易比公告</h3> </div><!--con_tt END--> <div class="con_txt gonggao_con_txt"> <p>暂无公告</p> </div><!--con_txt END--> </div><!--right END--> </div><!--$Main END--> <div id="Footer"> <img src="../img3/jxs/26.gif" /> </div><!--$Footer END--> </body> </html>
08codework
trunk/91bi/htm/jxs_index.htm
HTML
mpl11
2,819
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Language" content="zh-CN" /> <meta name="roots" content="" /> <meta name="Keywords" content="" /> <meta name="Description" content="" /> <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" /> <link rel="start" href="" title="Home" /> <title>经销商登录</title> <link href="../css3/global.css" type="text/css" rel="stylesheet" media="screen" /> <link href="../css3/login_reg.css" type="text/css" rel="stylesheet" media="screen" /> <script language="javascript" type="text/jscript"> function chaCss(o,bg,bor){ o.style.borderColor = bg; o.style.backgroundColor = bor; } var caiying2007; var bg_out="#d2d2d2",border_out="#FFFFFF";//指向时样式颜色 var bg_over="#FF9900",border_over="#FFFFEC";//离开时样式颜色 function changbg(obj){ if (!obj.cssColor)obj.cssColor=0 if (obj.cssColor!=1){chaCss(obj,bg_over,border_over);} obj.onmouseout = function(){ if (this.cssColor==0) chaCss(this,bg_out,border_out); } obj.onblur= function(){ this.cssColor=0; chaCss(this,bg_out,border_out); } obj.onfocus= function(){ if (caiying2007 && caiying2007!=this){caiying2007.cssColor=0;caiying2007=this} this.cssColor=1; } } </script> </head> <body> <div id="Header"> <dl> <dt><a href="http://www.91bi.com" title="易比网首页"><img src="../img3/jxs/logo.gif" alt="易比网"/></a></dt> <dd><a href="login.htm" title="用户登录">用户登录</a> | <a href="#" title="帮助">帮助</a></dd> </dl> </div><!--$Header END--> <div id="Wrapper"> <div class="login_con"> <fieldset> <div><label>Email:</label><input type="text" onmouseover="changbg(this)" class="inputout"/></div> <div><label>密码:</label><input type="password" onmouseover="changbg(this)" class="inputout" /><p><a href="findpassword_1.htm" title="忘记密码?">忘记密码?</a></p></div> <div><label>验证码:</label><input type="password" onmouseover="changbg(this)" class="inputout" style="width:68px;" /><p><img src="../img3/jxs/yanzheng.gif" alt="" title="" /></p></div> <div><label></label><input value="" type="submit" class="btn1" onmouseover="this.className='btn2'" onmouseout="this.className='btn1'" /></div> </fieldset> <p class="tips" style=" visibility:hidden;">邮箱错误</p> <a href="jxs_zhuce_1.htm" title="创建一个经销商帐号" class="reg_link">创建一个经销商帐号</a> </div><!--. END--> </div><!--$Main END--> <div id="Footer"> <img src="../img3/jxs/26.gif" /> </div><!--$Footer END--> </body> </html>
08codework
trunk/91bi/htm/jxs_login.htm
HTML
mpl11
2,812
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Language" content="zh-CN" /> <meta name="roots" content="" /> <meta name="Keywords" content="" /> <meta name="Description" content="" /> <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" /> <link rel="start" href="" title="Home" /> <title>经销商注册 - 注册成功</title> <link href="../css3/global.css" type="text/css" rel="stylesheet" media="screen" /> <link href="../css3/login_reg.css" type="text/css" rel="stylesheet" media="screen" /> </head> <body> <div id="Header"> <dl> <dt><a href="http://www.91bi.com" title="易比网首页"><img src="../img3/jxs/logo.gif" alt="易比网"/></a></dt> <dd><a href="login.htm" title="用户登录">用户登录</a> | <a href="#" title="帮助">帮助</a></dd> </dl> </div><!--$Header END--> <ul id="Step"> <li><h2>1.填写信息</h2></li> <li>2.验证邮箱</li> <li class="on">3.注册成功</li> </ul> <div id="Wrapper"> <div class="step_3"> <h3>注册成功</h3> <p><strong>sdasd,欢迎加入易比网</strong><br />请牢记您的登录邮件地址:adsa@163.com<br />您现在可以:<br /><a href="#" title="">修改资料</a></p> </div> </div><!--$Main END--> <div id="Footer"> <img src="../img3/jxs/26.gif" /> </div><!--$Footer END--> </body> </html>
08codework
trunk/91bi/htm/jxs_zhuce_3.htm
HTML
mpl11
1,548
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Language" content="zh-CN" /> <meta name="roots" content="" /> <meta name="Keywords" content="" /> <meta name="Description" content="" /> <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" /> <link rel="start" href="" title="Home" /> <title>注册</title> <link href="../css3/global.css" type="text/css" rel="stylesheet" media="screen" /> <link href="../css3/login_reg.css" type="text/css" rel="stylesheet" media="screen" /> </head> <body> <div id="Header"> <dl> <dt><a href="http://www.91bi.com" title="易比网首页"><img src="../img3/jxs/logo.gif" alt="易比网"/></a></dt> <dd><a href="login.htm" title="用户登录">用户登录</a> | <a href="#" title="帮助">帮助</a></dd> </dl> </div><!--$Header END--> <div id="Wrapper" class="reg"> <a href="#" title="普通会员注册" class="login">普通会员注册</a><a href="jxs_zhuce_1.htm" title="经销商注册" class="login login_2">经销商注册</a> </div><!--$Main END--> <div id="Footer"> <img src="../img3/jxs/26.gif" /> </div><!--$Footer END--> </body> </html>
08codework
trunk/91bi/htm/reg.htm
HTML
mpl11
1,345
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Language" content="zh-CN" /> <meta name="roots" content="" /> <meta name="Keywords" content="" /> <meta name="Description" content="" /> <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" /> <link rel="start" href="" title="Home" /> <title>经销商注册 - 验证邮箱</title> <link href="../css3/global.css" type="text/css" rel="stylesheet" media="screen" /> <link href="../css3/login_reg.css" type="text/css" rel="stylesheet" media="screen" /> <script language="javascript" type="text/jscript"> function chaCss(o,bg,bor){ o.style.borderColor = bg; o.style.backgroundColor = bor; } var caiying2007; var bg_out="#d2d2d2",border_out="#FFFFFF";//指向时样式颜色 var bg_over="#FF9900",border_over="#FFFFEC";//离开时样式颜色 function changbg(obj){ if (!obj.cssColor)obj.cssColor=0 if (obj.cssColor!=1){chaCss(obj,bg_over,border_over);} obj.onmouseout = function(){ if (this.cssColor==0) chaCss(this,bg_out,border_out); } obj.onblur= function(){ this.cssColor=0; chaCss(this,bg_out,border_out); } obj.onfocus= function(){ if (caiying2007 && caiying2007!=this){caiying2007.cssColor=0;caiying2007=this} this.cssColor=1; } } </script> </head> <body> <div id="Header"> <dl> <dt><a href="http://www.91bi.com" title="易比网首页"><img src="../img3/jxs/logo.gif" alt="易比网"/></a></dt> <dd><a href="login.htm" title="用户登录">用户登录</a> | <a href="#" title="帮助">帮助</a></dd> </dl> </div><!--$Header END--> <ul id="Step"> <li><h2>1.填写信息</h2></li> <li class="on">2.验证邮箱</li> <li>3.注册成功</li> </ul> <div id="Wrapper"> <div class="step_2"> <h3>感谢您注册易比网,现在请按以下步骤完成您的注册!</h3> <ul> <li><strong>第一步:查看您的电子邮箱</strong><br />我们给您发送了验证邮件,邮件地址为:<span>asd@163.com</span>,请登录您的邮箱收信。<br />注:验证邮件可能被您的邮箱提供商认定为垃圾邮件或广告邮件,如果找不到邮件,请查看您的垃圾邮件箱和广告邮件箱。<br />若十分钟内没有收到确认信让易比<a href="#" title="">重发一封</a></li> <li><strong>第二步:激活链接</strong><br />您可以点击邮件中的链接,即可完成您的注册!</li> </ul> </div> </div><!--$Footer END--> <div id="Footer"> <img src="../img3/jxs/26.gif" /> </div><!--$Footer END--> </body> </html>
08codework
trunk/91bi/htm/jxs_zhuce_2.htm
HTML
mpl11
2,759
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Language" content="zh-CN" /> <meta name="roots" content="" /> <meta name="Keywords" content="" /> <meta name="Description" content="" /> <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" /> <link rel="start" href="" title="Home" /> <title>找回密码</title> <link href="../css3/global.css" type="text/css" rel="stylesheet" media="screen" /> <link href="../css3/login_reg.css" type="text/css" rel="stylesheet" media="screen" /> <script language="javascript" type="text/jscript"> function chaCss(o,bg,bor){ o.style.borderColor = bg; o.style.backgroundColor = bor; } var caiying2007; var bg_out="#d2d2d2",border_out="#FFFFFF";//指向时样式颜色 var bg_over="#FF9900",border_over="#FFFFEC";//离开时样式颜色 function changbg(obj){ if (!obj.cssColor)obj.cssColor=0 if (obj.cssColor!=1){chaCss(obj,bg_over,border_over);} obj.onmouseout = function(){ if (this.cssColor==0) chaCss(this,bg_out,border_out); } obj.onblur= function(){ this.cssColor=0; chaCss(this,bg_out,border_out); } obj.onfocus= function(){ if (caiying2007 && caiying2007!=this){caiying2007.cssColor=0;caiying2007=this} this.cssColor=1; } } </script> </head> <body> <div id="Header"> <dl> <dt><a href="http://www.91bi.com" title="易比网首页"><img src="../img3/jxs/logo.gif" alt="易比网"/></a></dt> <dd><a href="login.htm" title="用户登录">用户登录</a> | <a href="#" title="帮助">帮助</a></dd> </dl> </div><!--$Header END--> <div id="Wrapper"> <div class="findpassword"> <h3>如果您忘记了登录密码,您可以在这里找回来!</h3> <p>请输入您登录当当网所使用的Email地址,系统将为您随机生成一个新的登录密码,并发送到您的邮箱里(只有在您确认后,新密码才会生效)。</p> <fieldset> <div><label>请输入您登录易比网的Email地址:</label><input type="text" onmouseover="changbg(this)" class="inputout" /></div> <div><label>设置密码:</label><input type="password" onmouseover="changbg(this)" class="inputout inputout2"/></div> <p><img src="../img3/jxs/yanzheng.gif" alt="" /> 请输入图片中的四个字母。<a href="#" title="">看不清楚?换个图片</a></p> <div><label></label><input value="确 定" type="submit" width="100" /></div> </fieldset> <p class="tips">请输入您的Email地址!</p> <p class="tips">您输入的验证码不正确,请重新输入。</p> <p class="tips success">系统已经重新为您生成了一个密码并发送到了您的邮箱<span>163@163.com</span>。请登录您的邮箱收信,并激活新密码使其生效,您就可以重新登陆易比网。<br />注:重置密码的邮件可能被您的邮箱提供商认定为垃圾或广告邮件,如果找不到邮件,请查看您的垃圾邮件箱和广告邮件箱。</p> </div><!--. END--> </div><!--$Main END--> <div id="Footer"> <img src="../img3/jxs/26.gif" /> </div><!--$Footer END--> </body> </html>
08codework
trunk/91bi/htm/findpassword_1.htm
HTML
mpl11
3,302
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Language" content="zh-CN" /> <meta name="roots" content="" /> <meta name="Keywords" content="" /> <meta name="Description" content="" /> <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" /> <link rel="start" href="" title="Home" /> <title>经销商后台管理系统</title> <link href="../css3/global.css" type="text/css" rel="stylesheet" media="screen" /> <link href="../css3/jxs.css" type="text/css" rel="stylesheet" media="screen" /> </head> <body> <div id="Header"> <dl> <dt><a href="http://www.91bi.com" title="易比网首页"><img src="../img3/jxs/12.gif" alt="易比网"/></a></dt> <dd><strong>您好!XXX</strong> <a href="login.htm" title="退出" class="quite">退出</a> | <a href="login.htm" title="我的易比">用户登录</a> | <a href="#" title="易比首页">易比首页</a></dd> </dl> <span class="con R"></span> </div><!--$Header END--> <div id="Wrapper"> <div class="left"> <h3><img src="../img3/jxs/15.gif" alt="系统首页" /></h3> <ul class="main_nav"> <li><a href="#" title="产品报价管理">产品报价管理</a> <ul class="main_nav_drop"> <li><a href="jxs_baojia.htm" title="新产品报价">新产品报价</a></li> <li><a href="jxs_yibaojia.htm" title="已报价产品">已报价产品</a></li> </ul> </li> <li><a href="jxs_zixun.htm" title="用户咨询">用户咨询</a></li> <li><a href="jxs_ziliao.htm" title="修改资料">修改资料</a></li> <li><a href="jxs_mima.htm" title="修改密码">修改密码</a></li> </ul> <p><a href="jxs_gonggao.htm" title="易比公告">易比公告</a><br /><a href="jxs_jianyi.htm" title="给易比建议">给易比建议</a></p> <span class="con B"></span> </div><!--left END--> <div class="right yibaojia"> <img src="../img3/jxs/1.jpg" alt="经销商后台管理系统" /> <div class="con_tt"> <h3>给易比建议</h3> </div><!--con_tt END--> <div class="con_txt baojiasearch_con_txt"> <table width="100%" border="0" cellspacing="0" cellpadding="0" class="baojia_table zixun_table" id="right_con_table"> <tr> <th width="79%" >&nbsp;建议内容</th> <th width="21%" align="center">2008-11-11</th> </tr> <tr> <td colspan="2" style="text-align:left; padding:5px;border:solid #7e9db9 1px; height:100px; vertical-align:top;">洗先生洗先生洗先生洗先生洗先生洗先生洗先生洗先生洗先生洗先生洗先生洗先生</td> </tr> <tr> <td colspan="2" style="padding:10px;"><input type="image" src="../img3/jxs/33.gif" /></td> </tr> </table> </div> <!--con_txt END--> <!--con_tt END--> <!--con_txt END--> </div> <!--right END--> </div><!--$Main END--> <div id="Footer"> <img src="../img3/jxs/26.gif" /> </div><!--$Footer END--> </body> </html>
08codework
trunk/91bi/htm/jxs_jianyi.htm
HTML
mpl11
3,108
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Language" content="zh-CN" /> <meta name="roots" content="" /> <meta name="Keywords" content="" /> <meta name="Description" content="" /> <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" /> <link rel="start" href="" title="Home" /> <title>经销商后台管理系统</title> <link href="../css3/global.css" type="text/css" rel="stylesheet" media="screen" /> <link href="../css3/jxs.css" type="text/css" rel="stylesheet" media="screen" /> </head> <body> <div id="Header"> <dl> <dt><a href="http://www.91bi.com" title="易比网首页"><img src="../img3/jxs/12.gif" alt="易比网"/></a></dt> <dd><strong>您好!XXX</strong> <a href="login.htm" title="退出" class="quite">退出</a> | <a href="login.htm" title="我的易比">用户登录</a> | <a href="#" title="易比首页">易比首页</a></dd> </dl> <span class="con R"></span> </div><!--$Header END--> <div id="Wrapper"> <div class="left"> <h3><img src="../img3/jxs/15.gif" alt="系统首页" /></h3> <ul class="main_nav"> <li><a href="#" title="产品报价管理">产品报价管理</a> <ul class="main_nav_drop"> <li><a href="jxs_baojia.htm" title="新产品报价">新产品报价</a></li> <li><a href="jxs_yibaojia.htm" title="已报价产品">已报价产品</a></li> </ul> </li> <li><a href="jxs_zixun.htm" title="用户咨询">用户咨询</a></li> <li><a href="jxs_ziliao.htm" title="修改资料">修改资料</a></li> <li><a href="jxs_mima.htm" title="修改密码" class="on">修改密码</a></li> </ul> <p><a href="jxs_gonggao.htm" title="易比公告">易比公告</a><br /><a href="jxs_jianyi.htm" title="给易比建议">给易比建议</a></p> <span class="con B"></span> </div><!--left END--> <div class="right yibaojia"> <img src="../img3/jxs/1.jpg" alt="经销商后台管理系统" /> <div class="con_tt"> <h3>修改密码</h3> </div><!--con_tt END--> <div class="con_txt baojiasearch_con_txt"> <table width="300" border="0" cellspacing="0" cellpadding="0" class="mima_con"> <tr> <td width="125" align="right">请输入原密码:</td> <td width="175"><input type="password" /></td> </tr> <tr> <td align="right">请输入新密码:</td> <td><input type="password" /></td> </tr> <tr> <td align="right">请再次输入新密码:</td> <td><input type="password" /></td> </tr> <tr> <td>&nbsp;</td> <td><input type="submit" value="提 交" class="mima_button" /></td> </tr> </table> </div> <!--con_txt END--> <!--con_tt END--> <!--con_txt END--> </div> <!--right END--> </div><!--$Main END--> <div id="Footer"> <img src="../img3/jxs/26.gif" /> </div><!--$Footer END--> </body> </html>
08codework
trunk/91bi/htm/jxs_mima.htm
HTML
mpl11
3,071
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Language" content="zh-CN" /> <meta name="roots" content="" /> <meta name="Keywords" content="" /> <meta name="Description" content="" /> <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" /> <link rel="start" href="" title="Home" /> <title>经销商后台管理系统</title> <link href="../css3/global.css" type="text/css" rel="stylesheet" media="screen" /> <link href="../css3/jxs.css" type="text/css" rel="stylesheet" media="screen" /> </head> <body> <div id="Header"> <dl> <dt><a href="http://www.91bi.com" title="易比网首页"><img src="../img3/jxs/12.gif" alt="易比网"/></a></dt> <dd><strong>您好!XXX</strong> <a href="login.htm" title="退出" class="quite">退出</a> | <a href="login.htm" title="我的易比">用户登录</a> | <a href="#" title="易比首页">易比首页</a></dd> </dl> <span class="con R"></span> </div><!--$Header END--> <div id="Wrapper"> <div class="left"> <h3><img src="../img3/jxs/15.gif" alt="系统首页" /></h3> <ul class="main_nav"> <li><a href="#" title="产品报价管理" class="on">产品报价管理</a> <ul class="main_nav_drop"> <li><a href="jxs_baojia.htm" title="新产品报价" class="on_on">新产品报价</a></li> <li><a href="jxs_yibaojia.htm" title="已报价产品">已报价产品</a></li> </ul> </li> <li><a href="jxs_zixun.htm" title="用户咨询">用户咨询</a></li> <li><a href="jxs_ziliao.htm" title="修改资料">修改资料</a></li> <li><a href="jxs_mima.htm" title="修改密码">修改密码</a></li> </ul> <p><a href="jxs_gonggao.htm" title="易比公告">易比公告</a><br /><a href="jxs_jianyi.htm" title="给易比建议">给易比建议</a></p> <span class="con B"></span> </div><!--left END--> <div class="right"> <img src="../img3/jxs/1.jpg" alt="经销商后台管理系统" /> <p class="tips">* 温馨提示: 首次登陆,请<a href="#" title="">完善资料</a></p> <div class="con_tt"> <h3>新产品报价</h3> </div><!--con_tt END--> <div class="con_txt baojiasearch_con_txt"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr align="left"> <td width="9%">产品类别:</td> <td width="15%"><select><option>--请选择--</option></select></td> <td width="5%">品牌:</td> <td width="14%"><select name="select"> <option>--请选择--</option> </select> </td> <td width="23%"><input type="text" /></td> <td width="34%"><input type="submit" value="搜 索" class="search_button" /></td> </tr> </table> <table width="100%" border="0" cellspacing="0" cellpadding="0" class="baojia_table" id="right_con_table"> <tr> <th width="13%" align="center">类型</th> <th width="27%" align="center">品牌/型号</th> <th width="24%" align="center">本次报价</th> <th width="8%"><input type="checkbox" />含税</th> <th width="8%"><input type="checkbox" />促销</th> <th width="8%"><input type="checkbox" />邮购</th> <th width="8%"><input type="checkbox" />行货</th> <th width="3%">&nbsp;</th> </tr> <tr> <td>&nbsp;</td> <td>&nbsp;</td> <td><input type="text" style="width:70px;" /></td> <td><input type="checkbox" /></td> <td><input type="checkbox" /></td> <td><input type="checkbox" /></td> <td><input type="checkbox" /></td> <td><a href=""><img src="../img3/jxs/30.gif" /></a></td> </tr> <tr class="gray"> <td>&nbsp;</td> <td>&nbsp;</td> <td><input type="text" style="width:70px;" /></td> <td><input type="checkbox" /></td> <td><input type="checkbox" /></td> <td><input type="checkbox" /></td> <td><input type="checkbox" /></td> <td><a href=""><img src="../img3/jxs/30.gif" /></a></td> </tr> <tfoot> <td colspan="6">&nbsp;</td> <td colspan="2"><input type="submit" class="baojia_botton" value="提交报价" /></td> </tfoot> </table> <p class="pagelist">共2222跳 第1页/共222页 1 <a href="#">2</a><a href="#">3</a><a href="#">&gt;</a><a href="#">&gt;|</a></p> </div><!--con_txt END--> <!--con_tt END--> <!--con_txt END--> </div> <!--right END--> </div><!--$Main END--> <div id="Footer"> <img src="../img3/jxs/26.gif" /> </div><!--$Footer END--> </body> </html>
08codework
trunk/91bi/htm/jxs_baojia.htm
HTML
mpl11
4,622
#Header { height:125px;background:url(../img3/jxs/1.gif) repeat-x left bottom;} #Header dl {width:920px;margin:0 auto;padding:15px 20px 0 20px;} #Header dt {float:left;} #Header dd {float:right;margin:30px 0 0 0;} #Step {width:360px;height:33px;margin:-33px auto 0 auto;} #Step li {width:120px; height:28px;float:left;padding-top:5px;font-size:14px;color:#8e8e8e;font-weight:bold;} #Step li.on {background:#b4dc83;color:#333;} #Step li h2 {font-size:14px;} #Wrapper {width:800px;margin:20px auto 0 auto;} #Wrapper .tpis {font-weight:bold;color:#f00;} fieldset { margin:30px 0 0 20px;} fieldset label { float:left; margin:7px 5px 0 0 ; text-align:right; width:100px; color:#333;} fieldset label.checkbox_div { width:50px; color:#666;} fieldset input.inputout { width:260px; float:left; height:22px; border:#d2d2d2 1px solid; padding:5px 0 0 6px;font-size:14px;font-weight:bold;background:#fff;} fieldset textarea { float:left;border:#d2d2d2 1px solid; padding:3px; width:240px;} fieldset p { width:350px; float:left; margin:0 0 0 10px; background:#f3f3f3; padding:7px 5px 5px 5px; color:#666;} fieldset div { clear:both; padding:6px 10px 12px 20px;} fieldset select { float:left; margin:3px 5px 0 0;} fieldset div input.btn1 { float:left; display:block; width:161px; height:40px; background:url(../img3/jxs/2.gif) left top; border:0;cursor:pointer;margin:10px 0 0 30px;} fieldset div input.btn2 { float:left; display:block; width:161px; height:40px; background:url(../img3/jxs/2.gif) 0 -40px; border:0; cursor:pointer;margin:10px 0 0 30px;} fieldset div a.read { float:left; margin:8px 0 0 0; text-decoration:underline;color: #1A7CBC;} .login_con {width:340px;height:450px;background:url(../img3/jxs/3.gif) no-repeat;float:right;} .login_con fieldset {float:left;;margin:65px 0 0 0;} .login_con fieldset label {width:50px;} .login_con fieldset input.inputout {width:170px;} .login_con fieldset p {width:60px;background:none;padding:7px 0 0 0;} .login_con fieldset p a {text-decoration: underline;color: #1A7CBC;} .login_con fieldset div input.btn1 { float:left; display:block; width:118px; height:34px; background:url(../img3/jxs/2.gif) 0 -80px; border:0;cursor:pointer;margin:5px 0 0 0;} .login_con fieldset div input.btn2 { float:left; display:block; width:118px; height:34px; background:url(../img3/jxs/2.gif) 0 -114px; border:0; cursor:pointer;margin:5px 0 0 0;} .login_con .reg_link {float:right;text-decoration: underline;color: #1A7CBC;margin:60px 20px 0 0;} .login {display:block;width:303px;height:155px;background:url(../img3/jxs/4.gif);text-indent:-9999px; float:left;margin:10px 0 0 50px;_margin:10px 0 0 25px;} .login_2 { background:url(../img3/jxs/5.gif);float:right;margin:10px 50px 0 0;_argin:10px 25px 0 0;} .reg .login {background:url(../img3/jxs/6.gif);} .reg .login_2 { background:url(../img3/jxs/7.gif);} .login_con p.tips {width:200px;background:#ffede3;border:solid #ff5700 1px;clear:both;margin:8px 0 0 30px;padding:3px;} .findpassword {width:600px;margin:30px auto 0 auto;} .findpassword h3 {font-size:14px;} .findpassword p {font-size:14px;line-height:24px;padding-top:10px;} .findpassword fieldset { margin:30px 0 0 -25px;} .findpassword fieldset label {width:190px;} .findpassword fieldset input.inputout {width:200px;} .findpassword fieldset input.inputout2 {width:100px;} .findpassword fieldset p {width:400px;background:none;font-size:12px;text-align:right;margin-left:156px;_margin-left:78px;} .findpassword fieldset p a, .findpassword p a, .step_2 ul li a, .step_3 p a {text-decoration: underline;color: #1A7CBC;} .findpassword p.tips {font-size:12px;background:#ffede3 url(../img3/jxs/8.gif) no-repeat 5px 2px;border:solid #ff5700 1px;padding:0 0 0 30px;color:#fa0404;margin-top:5px;} .findpassword p.success {background:#e7ffe7 url(../img3/jxs/9.gif) no-repeat 5px 4px;color:#333;border:solid #00be00 1px;} .findpassword p.success span {color:#f00;} .step_2 {width:750px;margin:30px auto 0 auto;background:url(../img3/jxs/10.gif) no-repeat left center;} .step_2 h3 {font-size:14px;border-bottom:solid #ccc 1px;color:#666;} .step_2 ul {padding:20px 0 0 150px;} .step_2 ul li {font-size:14px;line-height:26px;padding-top:10px;} .step_2 ul li span {color:#f00;} .step_3 {width:500px;margin:30px auto 0 auto;background:#e7ffe7;border:solid #00be00 1px;padding:10px;} .step_3 h3 {background:url(../img3/jxs/11.gif) no-repeat 5px 3px;font-size:18px;padding:20px 0 20px 60px;} .step_3 p {line-height:24px; padding-left:60px;} .step_3 p strong {font-size:14px;} #Footer {margin:0 auto;text-align:center;clear:both; padding:60px 0;background:url(../img3/jxs/27.gif) repeat-x 0 40px;} #Footer img {float:right;margin:0 40px 0 0;}
08codework
trunk/91bi/css3/login_reg.css
CSS
mpl11
4,730
.con {display:block;position:absolute;} .R {width:12px;height:54px;background:url(../img3/jxs/13.gif);right:0;bottom:0;_bottom:1px;} .B {width:228px;height:26px;background:url(../img3/jxs/16.gif) 0 -66px; left:0;bottom:-1px;} #Header {position:relative;width:970px;margin:0 auto;} #Header dl {width:970px;height:57px;margin:0 auto;background:url(../img3/jxs/14.gif) repeat-x left bottom;_background:url(../img3/jxs/14.gif) repeat-x 0 41px;} #Header dt {float:left;} #Header dd {float:right;margin:18px 0 0 0;color:#39873b;padding-right:30px;} #Header dd strong {padding-right:30px;color:#333;} #Header dd a {color:#39873b;} #Header dd a.quite {color:#fe0000;} #Wrapper {width:970px;margin:10px auto 0 auto;} .left {float:left;width:228px;height:515px;background:url(../img3/jxs/17.gif);position:relative;} .main_nav li {float:left;margin:5px 0 0 20px;display:inline;} .main_nav li a {display:block;width:155px;height:25px;background:url(../img3/jxs/16.gif) 0 -33px;color:#7d5c3d;font-size:14px;font-weight:bold;padding:8px 0 0 30px;} .main_nav li a.on {background:url(../img3/jxs/16.gif) 0 0;} .main_nav li a.on_on {color:#f18200;} .main_nav li .main_nav_drop li {background:url(../img3/jxs/19.gif) no-repeat 15px center;margin:5px 0 0 25px;} .main_nav li .main_nav_drop li a {width:130px;height:24px;font-size:12px;background:url(../img3/jxs/18.gif) repeat-x left bottom;padding-top:4px;font-weight:normal;} .left p {clear:both;width:185px;background:url(../img3/jxs/20.gif) repeat-x 0 20px;margin:0 auto;padding-top:40px;line-height:26px;} .left p a {font-size:14px;font-weight:bold;color:#978958;background:url(../img3/jxs/21.gif) no-repeat left center;padding-left:15px;} .right {float:right;width:730px;} .right .tips {font-size:14px;color:#727272;padding:10px;} .right .tips a {color:#fe0000;text-decoration:underline;} .right .tips span {color:#fe0000;} .right .con_tt {width:668px;height:30px;margin:0 auto;clear:both;background:url(../img3/jxs/22.gif) no-repeat left bottom;} .right .con_tt h3 {font-size:14px;color:#343434;float:left;background:url(../img3/jxs/23.gif) no-repeat left center; padding:0 10px 0 16px;border-right:solid #cd0100 1px;margin:5px 0 0 0;} .right .con_txt {width:668px;margin:20px auto;} .right .index_con_txt {text-align:center;} .right .index_con_txt a {padding:10px;} .right .gonggao_con_txt p {font-size:14px;} .baojiasearch_con_txt {color:#666;} .baojiasearch_con_txt input.search_button {width:55px;height:21px;background:url(../img3/jxs/28.gif);border:0;} .baojia_table {margin-top:10px;} .baojia_table .gray {background:#ededed;} .baojia_table tr th {height:30px;background:url(../img3/jxs/29.gif);} .baojia_table td {height:30px;text-align:center} .baojia_table tfoot {background:url(../img3/jxs/32.gif) repeat-x left top;} .baojia_table tfoot td {height:50px;color:#fe0000;} .baojia_table tfoot .baojia_botton {width:87px;height:28px;background:url(../img3/jxs/31.gif);border:0;font-size:14px;color:#333;font-weight:bold;} .zixun_table td a {color:#ff6c04;} .zixun_table td span.weihuifu {color:#fe0000;} .zixun_table td span.yihuifu {color:#558a3c;} tr.huifu_tr {padding:10px 0;} .huifu_con {border:solid #7e9db9 1px;background:#fff;} .huifu_con a {float:right;font-size:14px;padding-right:10px;} .huifu_con td {text-align:left;} .pagelist {padding:20px 0;text-align:right;clear:both;} .pagelist a {padding:3px 5px;border:solid #ccc 1px;margin-right:5px;} .mima_con {margin:0 auto;} .mima_con td {height:40px;color:#333;font-weight:bold;} .mima_con .mima_button, .ziliao_con .ziliao_button {width:71px;height:28px;border:0;background:url(../img3/jxs/34.gif);} .ziliao_con td {height:30px;} .ziliao_con td span {color:#fe0000;} #Footer {width:960px;margin:0 auto;text-align:center;clear:both; padding:30px 0;background:url(../img3/jxs/27.gif) repeat-x 0 10px;} #Footer img {float:right;margin:0 40px 0 0;}
08codework
trunk/91bi/css3/jxs.css
CSS
mpl11
3,909
html, body, div, span,applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, dd, dl, dt, li, ol, ul, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td {margin:0;padding:0;} html,body{background:#FFFFFF;} body{font:normal normal normal 12px/1.5em Simsun,Arial, "Arial Unicode MS", Mingliu, Helvetica;text-align: center;height:100%;word-break : break-all;} div {text-align:left;} a{text-decoration: none;color: #444444;} a:hover{text-decoration: underline;color: #1A7CBC;} a:active{outline:none;} selection {color:#FFFFFF;background-color:#209EEB;} code::selection{background-color:#209EEB} ::-moz-selection {color:#FFFFFF;background-color:#209EEB;} code::-moz-selection{background-color:#209EEB} li{list-style-type:none;} img{border-style: none;} fieldset{border-style: none } label,button{cursor: pointer;} select,input,textarea{font-size:12px;line-height:1.2em;} table{border-collapse: collapse;border-style: none;} td{padding: 0;border:0;font-size:12px;line-height:1.5em;} .clearfix:after {content: ".";display: block;height: 0;clear: both;visibility: hidden;} .clearfix {display: inline-block;} * html .clearfix {height: 1%;} *+html .clearfix {height: 1%;} .clearfix {display: block;} .fix{word-break:keep-all;overflow:hidden;text-overflow:ellipsis;} .clear{font-size:0;line-height:0;height:0;clear:both;overflow: hidden;display: block;} .b {font-weight:bold;} .none{display:none;} .block{display:block;}
08codework
trunk/91bi/css3/global.css
CSS
mpl11
1,607
package lobster.games.studios; import levels.Level1; import lobster.games.studios.R; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; public class Main extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button play = (Button)findViewById(R.id.PlayButton); Button levelSelect = (Button)findViewById(R.id.LevelSelectButton); play.setOnClickListener(new OnClickListener() { //@Override public void onClick(View v) { Intent intent = new Intent(getApplicationContext(), Level1.class); startActivity(intent); } }); levelSelect.setOnClickListener(new OnClickListener() { //@Override public void onClick(View v) { Intent intent = new Intent(getApplicationContext(), LevelSelect.class); startActivity(intent); } }); } }
100windows
100 Windows/src/lobster/games/studios/Main.java
Java
epl
1,102
package lobster.games.studios; import lobster.games.studios.ImageAdapter; import android.app.Activity; import android.content.res.Resources; import android.os.Bundle; import android.widget.GridView; public class LevelSelect extends Activity{ GridView gridView; static int[] levels; @Override public void onCreate(Bundle savedInstanceState) { Resources res = getResources(); levels = new int[res.getInteger(R.integer.numberoflevels)]; for(int i = 0; i < levels.length; i++){ levels[i] = i + 1; } super.onCreate(savedInstanceState); setContentView(R.layout.levelselect); gridView = (GridView) findViewById(R.id.gridview); gridView.setAdapter(new ImageAdapter(this, levels)); } }
100windows
100 Windows/src/lobster/games/studios/LevelSelect.java
Java
epl
739
package lobster.games.studios; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.view.View.OnClickListener; import android.view.View.OnTouchListener; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.Button; import android.widget.Toast; import lobster.games.studios.R; public class ImageAdapter extends BaseAdapter { /*int mGalleryItemBackground; private Context mContext; private final int[] values;*/ private Context context; private final int[] values; public ImageAdapter(Context context, int[] values) { this.context = context; this.values = values; } public View getView(int position, View convertView, ViewGroup parent) { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View gridView; final Button button; if (convertView == null) { gridView = new View(context); // get layout from mobile.xml gridView = inflater.inflate(R.layout.mobile, null); } else { gridView = (View) convertView; } button = (Button) gridView.findViewById(R.id.grid_item_image); button.setText("" + values[position]); button.setOnTouchListener(new OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { String aux = "levels.Level" + button.getText().toString(); Class<?> clazz; try { clazz = Class.forName(aux); Intent intent = new Intent(context, clazz); ((Activity)context).startActivity(intent); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } return false; } }); button.setOnClickListener(new OnClickListener() { public void onClick(View v) { String aux = "Level" + button.getText().toString(); Toast.makeText(context, "ola", 5); Class<?> clazz; try { clazz = Class.forName(aux); Intent intent = new Intent(context, clazz); ((Activity)context).startActivity(intent); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); return gridView; } public int getCount() { return values.length; } public Object getItem(int position) { return null; } public long getItemId(int position) { return 0; } /*public ImageAdapter(Context c, int[] values) { mContext = c; this.values = values; mGalleryItemBackground = R.drawable.windowssssicon; /*TypedArray a = c.obtainStyledAttributes(R.styleable.HelloGallery); mGalleryItemBackground = a.getResourceId(R.drawable.windowssssicon, 0); a.recycle(); } public int getCount() { //return mImageIds.length; return values.length; } public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } public View getView(int position, View convertView, ViewGroup parent) { final Button button = new Button(mContext); final int pos = position; button.setLayoutParams(new Gallery.LayoutParams(100,100)); button.setBackgroundResource(mGalleryItemBackground); button.setText("" + values[position]); button.setOnTouchListener(new OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { String aux = "levels.Level" + button.getText().toString(); Toast.makeText(mContext, "ola" + values[pos], Toast.LENGTH_SHORT).show(); Class<?> clazz = null; if(aux != null){ try { clazz = Class.forName(aux); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } Intent intent = new Intent(mContext, clazz); ((Activity)mContext).startActivity(intent); } return false; } }); return button; }*/ }
100windows
100 Windows/src/lobster/games/studios/ImageAdapter.java
Java
epl
4,029
package lobster.games.studios; import lobster.games.studios.R; import android.app.Activity; import android.content.Intent; import android.content.pm.ActivityInfo; import android.os.Bundle; import android.view.MotionEvent; public class Splash extends Activity { //how long until we go to the next activity protected int _splashTime = 1500; protected int ACTIVITY_MAIN = 100; private Thread splashTread; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.splash); this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); final Splash sPlashScreen = this; // thread for displaying the SplashScreen splashTread = new Thread() { @Override public void run() { try { synchronized(this){ //wait 1,5 sec wait(_splashTime); } } catch(InterruptedException e) {} finally { //start a new activity Intent i = new Intent(); i.setClass(sPlashScreen, Main.class); startActivityForResult(i,ACTIVITY_MAIN); // stop(); } } }; splashTread.start(); } @Override public void onActivityResult (int requestCode, int resultCode, Intent data){ if (requestCode == ACTIVITY_MAIN) { if (resultCode == 0) { finish(); } } } //Function that will handle the touch @Override public boolean onTouchEvent(MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { synchronized(splashTread){ splashTread.notifyAll(); } } return true; } }
100windows
100 Windows/src/lobster/games/studios/Splash.java
Java
epl
1,663
package levels; import lobster.games.studios.R; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.WindowManager.LayoutParams; public class Level7 extends Activity{ private View selected_item = null; private int offset_x = 0; private int offset_y = 0; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.level); getWindow().addFlags(LayoutParams.FLAG_KEEP_SCREEN_ON); /*ImageView img = (ImageView)findViewById(R.id.windowView1); img.setOnTouchListener(new View.OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { switch(event.getAction()) { case MotionEvent.ACTION_DOWN: offset_x = (int)event.getX(); offset_y = (int)event.getY(); selected_item = v; break; default: break; } return false; } });*/ } }
100windows
100 Windows/src/levels/Level7.java
Java
epl
1,161
package levels; import lobster.games.studios.R; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.WindowManager.LayoutParams; public class Level10 extends Activity{ private View selected_item = null; private int offset_x = 0; private int offset_y = 0; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.level); getWindow().addFlags(LayoutParams.FLAG_KEEP_SCREEN_ON); /*ImageView img = (ImageView)findViewById(R.id.windowView1); img.setOnTouchListener(new View.OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { switch(event.getAction()) { case MotionEvent.ACTION_DOWN: offset_x = (int)event.getX(); offset_y = (int)event.getY(); selected_item = v; break; default: break; } return false; } });*/ } }
100windows
100 Windows/src/levels/Level10.java
Java
epl
1,162
package levels; import lobster.games.studios.R; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.WindowManager.LayoutParams; public class Level8 extends Activity{ private View selected_item = null; private int offset_x = 0; private int offset_y = 0; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.level); getWindow().addFlags(LayoutParams.FLAG_KEEP_SCREEN_ON); /*ImageView img = (ImageView)findViewById(R.id.windowView1); img.setOnTouchListener(new View.OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { switch(event.getAction()) { case MotionEvent.ACTION_DOWN: offset_x = (int)event.getX(); offset_y = (int)event.getY(); selected_item = v; break; default: break; } return false; } });*/ } }
100windows
100 Windows/src/levels/Level8.java
Java
epl
1,161
package levels; import lobster.games.studios.R; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.WindowManager.LayoutParams; public class Level9 extends Activity{ private View selected_item = null; private int offset_x = 0; private int offset_y = 0; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.level); getWindow().addFlags(LayoutParams.FLAG_KEEP_SCREEN_ON); /*ImageView img = (ImageView)findViewById(R.id.windowView1); img.setOnTouchListener(new View.OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { switch(event.getAction()) { case MotionEvent.ACTION_DOWN: offset_x = (int)event.getX(); offset_y = (int)event.getY(); selected_item = v; break; default: break; } return false; } });*/ } }
100windows
100 Windows/src/levels/Level9.java
Java
epl
1,161
package levels; import lobster.games.studios.R; import android.app.Activity; import android.os.Bundle; import android.view.WindowManager.LayoutParams; public class Level4 extends Activity{ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.level); getWindow().addFlags(LayoutParams.FLAG_KEEP_SCREEN_ON); /*final ImageView img = (ImageView)findViewById(R.id.windowView1); img.setOnClickListener(new OnClickListener() { //@Override public void onClick(View v) { img.setImageResource(R.drawable.openwindow); //img.setImageDrawable(drawable) /* Intent intent = new Intent(getApplicationContext(), Level1.class); startActivity(intent); } });*/ } }
100windows
100 Windows/src/levels/Level4.java
Java
epl
784
package levels; import lobster.games.studios.R; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.WindowManager.LayoutParams; public class Level6 extends Activity{ private View selected_item = null; private int offset_x = 0; private int offset_y = 0; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.level); getWindow().addFlags(LayoutParams.FLAG_KEEP_SCREEN_ON); /*ImageView img = (ImageView)findViewById(R.id.windowView1); img.setOnTouchListener(new View.OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { switch(event.getAction()) { case MotionEvent.ACTION_DOWN: offset_x = (int)event.getX(); offset_y = (int)event.getY(); selected_item = v; break; default: break; } return false; } });*/ } }
100windows
100 Windows/src/levels/Level6.java
Java
epl
1,161
package levels; import lobster.games.studios.R; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.WindowManager.LayoutParams; public class Level3 extends Activity{ private View selected_item = null; private int offset_x = 0; private int offset_y = 0; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.level); getWindow().addFlags(LayoutParams.FLAG_KEEP_SCREEN_ON); /*ImageView img = (ImageView)findViewById(R.id.windowView1); img.setOnTouchListener(new View.OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { switch(event.getAction()) { case MotionEvent.ACTION_DOWN: offset_x = (int)event.getX(); offset_y = (int)event.getY(); selected_item = v; break; default: break; } return false; } });*/ } }
100windows
100 Windows/src/levels/Level3.java
Java
epl
1,163
package levels; import lobster.games.studios.R; import android.app.Activity; import android.content.Intent; import android.hardware.Sensor; import android.hardware.SensorEvent; import android.hardware.SensorEventListener; import android.hardware.SensorManager; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.view.WindowManager.LayoutParams; import android.widget.ImageView; import android.widget.RelativeLayout; import android.widget.TextView; public class Level2 extends Activity implements SensorEventListener{ private SensorManager sensorManager = null; private float axisX; private ImageView img; private TextView levelText; private RelativeLayout windowLayout; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE); setContentView(R.layout.level); getWindow().addFlags(LayoutParams.FLAG_KEEP_SCREEN_ON); levelText = new TextView(this); levelText = (TextView)findViewById(R.id.leveltext); levelText.setText("Level 2"); windowLayout = (RelativeLayout)findViewById(R.id.windowlayout); img = new ImageView(this); img.setImageResource(R.drawable.window); windowLayout.addView(img); img.setOnClickListener(new OnClickListener() { //@Override public void onClick(View v) { if(img.getId() == R.drawable.openwindow){ Intent intent = new Intent(getApplicationContext(), Level3.class); startActivity(intent); } } }); } @Override protected void onResume() { super.onResume(); sensorManager.registerListener(this, sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_NORMAL); sensorManager.registerListener(this, sensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION), SensorManager.SENSOR_DELAY_NORMAL); } @Override protected void onStop() { super.onStop(); sensorManager.unregisterListener(this, sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER)); sensorManager.unregisterListener(this, sensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION)); } public void onSensorChanged(SensorEvent event) { // TODO Auto-generated method stub synchronized (this) { switch (event.sensor.getType()){ case Sensor.TYPE_ACCELEROMETER: axisX = event.values[0]; if(axisX < 0){ img.setImageResource(R.drawable.openwindow); } else if(axisX > 0){ img.setImageResource(R.drawable.window); } break; } } } public void onAccuracyChanged(Sensor arg0, int arg1) { // TODO Auto-generated method stub } }
100windows
100 Windows/src/levels/Level2.java
Java
epl
2,725
package levels; import lobster.games.studios.R; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.view.WindowManager.LayoutParams; import android.widget.Button; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.RelativeLayout; import android.widget.TextView; public class Level1 extends Activity{ private Thread splashTread; private ImageView windowImage; private TextView levelText; private Button icon2; private RelativeLayout screenLayout, windowLayout; private LinearLayout itemsLayout; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.level); getWindow().addFlags(LayoutParams.FLAG_KEEP_SCREEN_ON); screenLayout = (RelativeLayout)findViewById(R.id.gamelayout); windowLayout = (RelativeLayout)findViewById(R.id.windowlayout); itemsLayout = (LinearLayout)findViewById(R.id.linearlayout); windowImage = new ImageView(this); icon2 = new Button(this); windowImage.setImageResource(R.drawable.window); windowLayout.addView(windowImage); icon2 = (Button)findViewById(R.id.button2); icon2.setBackgroundResource(R.drawable.ic_launcher); levelText = new TextView(this); levelText = (TextView)findViewById(R.id.leveltext); levelText.setText("Level 1"); windowImage.setOnClickListener(new OnClickListener() { //@Override public void onClick(View v) { windowImage.invalidate(); windowImage.setImageResource(R.drawable.openwindow); splashTread = new Thread() { @Override public void run() { try { synchronized(this){ //wait 1 sec wait(1000); } } catch(InterruptedException e) {} finally { //start a new activity Intent intent = new Intent(getApplicationContext(), Level2.class); startActivity(intent); // stop(); } } }; splashTread.start(); } }); } }
100windows
100 Windows/src/levels/Level1.java
Java
epl
2,144
package lobster.games.studios; import levels.Level1; import lobster.games.studios.R; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; public class Main extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button play = (Button) findViewById(R.id.PlayButton); Button levelSelect = (Button) findViewById(R.id.LevelSelectButton); play.setOnClickListener(new OnClickListener() { // @Override public void onClick(View v) { Intent intent = new Intent(getApplicationContext(), Level1.class); startActivity(intent); } }); levelSelect.setOnClickListener(new OnClickListener() { // @Override public void onClick(View v) { Intent intent = new Intent(getApplicationContext(), LevelSelect.class); startActivity(intent); } }); } }
100windows
100 Puzzles/src/lobster/games/studios/Main.java
Java
epl
1,067
package lobster.games.studios; import lobster.games.studios.ImageAdapter; import android.app.Activity; import android.content.res.Resources; import android.os.Bundle; import android.widget.GridView; public class LevelSelect extends Activity { GridView gridView; static int[] levels; @Override public void onCreate(Bundle savedInstanceState) { Resources res = getResources(); levels = new int[res.getInteger(R.integer.numberoflevels)]; for (int i = 0; i < levels.length; i++) { levels[i] = i + 1; } super.onCreate(savedInstanceState); setContentView(R.layout.levelselect); gridView = (GridView) findViewById(R.id.gridview); gridView.setAdapter(new ImageAdapter(this, levels)); } }
100windows
100 Puzzles/src/lobster/games/studios/LevelSelect.java
Java
epl
742
package lobster.games.studios; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.view.View.OnClickListener; import android.view.View.OnTouchListener; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.Button; import android.widget.Toast; import lobster.games.studios.R; public class ImageAdapter extends BaseAdapter { /* * int mGalleryItemBackground; private Context mContext; private final int[] * values; */ private Context context; private final int[] values; public ImageAdapter(Context context, int[] values) { this.context = context; this.values = values; } public View getView(int position, View convertView, ViewGroup parent) { LayoutInflater inflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View gridView; final Button button; if (convertView == null) { gridView = new View(context); // get layout from mobile.xml gridView = inflater.inflate(R.layout.mobile, null); } else { gridView = (View) convertView; } button = (Button) gridView.findViewById(R.id.grid_item_image); button.setText("" + values[position]); button.setOnClickListener(new OnClickListener() { public void onClick(View v) { String aux = "levels.Level" + button.getText().toString(); Class<?> clazz; try { clazz = Class.forName(aux); Intent intent = new Intent(context, clazz); ((Activity) context).startActivity(intent); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } //return false; } }); return gridView; } public int getCount() { return values.length; } public Object getItem(int position) { return null; } public long getItemId(int position) { return 0; } /* * public ImageAdapter(Context c, int[] values) { mContext = c; this.values * = values; mGalleryItemBackground = R.drawable.windowssssicon; * /*TypedArray a = c.obtainStyledAttributes(R.styleable.HelloGallery); * mGalleryItemBackground = a.getResourceId(R.drawable.windowssssicon, 0); * a.recycle(); } * * public int getCount() { //return mImageIds.length; return values.length; * } * * public Object getItem(int position) { return position; } * * public long getItemId(int position) { return position; } * * public View getView(int position, View convertView, ViewGroup parent) { * final Button button = new Button(mContext); final int pos = position; * * button.setLayoutParams(new Gallery.LayoutParams(100,100)); * button.setBackgroundResource(mGalleryItemBackground); button.setText("" + * values[position]); * * button.setOnTouchListener(new OnTouchListener() { * * public boolean onTouch(View v, MotionEvent event) { String aux = * "levels.Level" + button.getText().toString(); Toast.makeText(mContext, * "ola" + values[pos], Toast.LENGTH_SHORT).show(); * * Class<?> clazz = null; if(aux != null){ try { clazz = Class.forName(aux); * * } catch (ClassNotFoundException e) { // TODO Auto-generated catch block * e.printStackTrace(); } Intent intent = new Intent(mContext, clazz); * ((Activity)mContext).startActivity(intent); } return false; } }); * * return button; } */ }
100windows
100 Puzzles/src/lobster/games/studios/ImageAdapter.java
Java
epl
3,525
package lobster.games.studios; import lobster.games.studios.R; import android.app.Activity; import android.content.Intent; import android.content.pm.ActivityInfo; import android.os.Bundle; import android.view.MotionEvent; public class Splash extends Activity { // how long until we go to the next activity protected int _splashTime = 1500; protected int ACTIVITY_MAIN = 100; private Thread splashTread; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.splash); this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); final Splash sPlashScreen = this; // thread for displaying the SplashScreen splashTread = new Thread() { @Override public void run() { try { synchronized (this) { // wait 1,5 sec wait(_splashTime); } } catch (InterruptedException e) { } finally { // start a new activity Intent i = new Intent(); i.setClass(sPlashScreen, Main.class); startActivityForResult(i, ACTIVITY_MAIN); // stop(); } } }; splashTread.start(); } @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == ACTIVITY_MAIN) { if (resultCode == 0) { finish(); } } } // Function that will handle the touch @Override public boolean onTouchEvent(MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { synchronized (splashTread) { splashTread.notifyAll(); } } return true; } }
100windows
100 Puzzles/src/lobster/games/studios/Splash.java
Java
epl
1,672
package levels; import java.util.ArrayList; import lobster.games.studios.R; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.WindowManager.LayoutParams; import android.widget.Button; import android.widget.ImageView; public class Level7 extends Activity { private Button buttonTop, buttonLeftMid, buttonMid, buttonRightMid, buttonRightRightMid, buttonBot; private int aux; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.level7); getWindow().addFlags(LayoutParams.FLAG_KEEP_SCREEN_ON); buttonTop = new Button(this); buttonLeftMid = new Button(this); buttonMid = new Button(this); buttonRightMid = new Button(this); buttonRightRightMid = new Button(this); buttonBot = new Button(this); buttonTop = (Button) findViewById(R.id.buttonTop); buttonLeftMid = (Button) findViewById(R.id.buttonLeftMid); buttonMid = (Button) findViewById(R.id.buttonMid); buttonRightMid = (Button) findViewById(R.id.buttonRightMid); buttonRightRightMid = (Button) findViewById(R.id.buttonRightRightMid); buttonBot = (Button) findViewById(R.id.buttonTop); buttonTop.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { changeValue((Button) v); } }); buttonLeftMid.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { changeValue((Button) v); } }); buttonMid.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { changeValue((Button) v); } }); buttonRightMid.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { changeValue((Button) v); } }); buttonRightRightMid.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { changeValue((Button) v); } }); buttonBot.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { changeValue((Button) v); } }); } public void changeValue(Button v) { aux = Integer.parseInt(v.getText().toString()); if (aux == 6) aux = 1; else aux++; v.setText(aux); } }
100windows
100 Puzzles/src/levels/Level7.java
Java
epl
2,238
package levels; import lobster.games.studios.R; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.WindowManager.LayoutParams; public class Level10 extends Activity { private View selected_item = null; private int offset_x = 0; private int offset_y = 0; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.level); getWindow().addFlags(LayoutParams.FLAG_KEEP_SCREEN_ON); /* * ImageView img = (ImageView)findViewById(R.id.windowView1); * img.setOnTouchListener(new View.OnTouchListener() { * * public boolean onTouch(View v, MotionEvent event) { * switch(event.getAction()) { case MotionEvent.ACTION_DOWN: offset_x = * (int)event.getX(); offset_y = (int)event.getY(); selected_item = v; * break; default: break; } return false; } }); */ } }
100windows
100 Puzzles/src/levels/Level10.java
Java
epl
920
package levels; import lobster.games.studios.R; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.WindowManager.LayoutParams; public class Level8 extends Activity { private View selected_item = null; private int offset_x = 0; private int offset_y = 0; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.level); getWindow().addFlags(LayoutParams.FLAG_KEEP_SCREEN_ON); /* * ImageView img = (ImageView)findViewById(R.id.windowView1); * img.setOnTouchListener(new View.OnTouchListener() { * * public boolean onTouch(View v, MotionEvent event) { * switch(event.getAction()) { case MotionEvent.ACTION_DOWN: offset_x = * (int)event.getX(); offset_y = (int)event.getY(); selected_item = v; * break; default: break; } return false; } }); */ } }
100windows
100 Puzzles/src/levels/Level8.java
Java
epl
919
package levels; import lobster.games.studios.R; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.WindowManager.LayoutParams; public class Level9 extends Activity { private View selected_item = null; private int offset_x = 0; private int offset_y = 0; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.level); getWindow().addFlags(LayoutParams.FLAG_KEEP_SCREEN_ON); /* * ImageView img = (ImageView)findViewById(R.id.windowView1); * img.setOnTouchListener(new View.OnTouchListener() { * * public boolean onTouch(View v, MotionEvent event) { * switch(event.getAction()) { case MotionEvent.ACTION_DOWN: offset_x = * (int)event.getX(); offset_y = (int)event.getY(); selected_item = v; * break; default: break; } return false; } }); */ } }
100windows
100 Puzzles/src/levels/Level9.java
Java
epl
919
package levels; import lobster.games.studios.R; import android.app.Activity; import android.os.Bundle; import android.view.WindowManager.LayoutParams; public class Level4 extends Activity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.level); getWindow().addFlags(LayoutParams.FLAG_KEEP_SCREEN_ON); /* * final ImageView img = (ImageView)findViewById(R.id.windowView1); * img.setOnClickListener(new OnClickListener() { * * //@Override public void onClick(View v) { * img.setImageResource(R.drawable.openwindow); * //img.setImageDrawable(drawable) * * * /* Intent intent = new Intent(getApplicationContext(), Level1.class); * startActivity(intent); } }); */ } }
100windows
100 Puzzles/src/levels/Level4.java
Java
epl
803
package levels; import java.util.ArrayList; import lobster.games.studios.R; import android.app.Activity; import android.content.Intent; import android.graphics.Color; import android.graphics.drawable.Drawable; import android.os.Bundle; import android.view.View; import android.view.WindowManager.LayoutParams; import android.widget.Button; import android.widget.ImageView; import android.widget.TextView; public class Level6 extends Activity { private Button[] buttonsPlus; private Button[] buttonsLess; private TextView[] textValues; private TextView[] textFlushs; private ImageView cardOne, cardTwo, cardThree; private ArrayList<String> flush = new ArrayList<String>();// = {"\u2660", // "\u2663", // "\u2666", // "\u2665"}; private ArrayList<String> value = new ArrayList<String>(); // = {"2", "3", // "4", "5", // "6", "7", // "8", "9", // "10", "J", // "Q", "K", // "A"}; private int i, aux; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.level6); getWindow().addFlags(LayoutParams.FLAG_KEEP_SCREEN_ON); cardOne = new ImageView(this); cardTwo = new ImageView(this); cardThree = new ImageView(this); cardOne = (ImageView) findViewById(R.id.cardOne); cardTwo = (ImageView) findViewById(R.id.cardTwo); cardThree = (ImageView) findViewById(R.id.cardThree); // cardOne.setImageResource(R.drawable.espadas5); flush.add("\u2660"); flush.add("\u2663"); flush.add("\u2666"); flush.add("\u2665"); value.add("2"); value.add("3"); value.add("4"); value.add("5"); value.add("6"); value.add("7"); value.add("8"); value.add("9"); value.add("10"); value.add("J"); value.add("Q"); value.add("K"); value.add("A"); buttonsPlus = findPlusButtons(); buttonsLess = findLessButtons(); textValues = findTextValueViews(); textFlushs = findTextFlushViews(); textFlushs[0].setText("\u2660"); textFlushs[0].setTextColor(Color.BLACK); textFlushs[0].setTextSize(30.0f); textFlushs[1].setText("\u2665"); textFlushs[1].setTextColor(Color.RED); textFlushs[1].setTextSize(30.0f); textFlushs[2].setText("\u2663"); textFlushs[2].setTextColor(Color.BLACK); textFlushs[2].setTextSize(30.0f); textValues[0].setText("2"); textValues[0].setTextSize(30.0f); textValues[0].setTextColor(Color.BLACK); textValues[1].setText("K"); textValues[1].setTextSize(30.0f); textValues[1].setTextColor(Color.BLACK); textValues[2].setText("7"); textValues[2].setTextSize(30.0f); textValues[2].setTextColor(Color.BLACK); for (i = 0; i < 6; i++) { buttonsPlus[i].setOnClickListener(new View.OnClickListener() { public void onClick(View v) { changeValue(((Button) v).getId()); } }); } for (i = 0; i < 6; i++) { buttonsLess[i].setOnClickListener(new View.OnClickListener() { public void onClick(View v) { changeValue(((Button) v).getId()); } }); } } public Button[] findPlusButtons() { Button[] b = new Button[6]; for (int a = 0; a < b.length; a++) { b[a] = new Button(this); } b[0] = (Button) findViewById(R.id.buttonPlus11); b[1] = (Button) findViewById(R.id.buttonPlus12); b[2] = (Button) findViewById(R.id.buttonPlus21); b[3] = (Button) findViewById(R.id.buttonPlus22); b[4] = (Button) findViewById(R.id.buttonPlus31); b[5] = (Button) findViewById(R.id.buttonPlus32); return b; } public Button[] findLessButtons() { Button[] b = new Button[6]; for (int a = 0; a < b.length; a++) { b[a] = new Button(this); } b[0] = (Button) findViewById(R.id.buttonLess11); b[1] = (Button) findViewById(R.id.buttonLess12); b[2] = (Button) findViewById(R.id.buttonLess21); b[3] = (Button) findViewById(R.id.buttonLess22); b[4] = (Button) findViewById(R.id.buttonLess31); b[5] = (Button) findViewById(R.id.buttonLess32); return b; } public TextView[] findTextFlushViews() { TextView[] b = new TextView[3]; for (int a = 0; a < b.length; a++) { b[a] = new TextView(this); } b[0] = (TextView) findViewById(R.id.text12); b[1] = (TextView) findViewById(R.id.text22); b[2] = (TextView) findViewById(R.id.text32); return b; } public TextView[] findTextValueViews() { TextView[] b = new TextView[3]; for (int a = 0; a < b.length; a++) { b[a] = new TextView(this); } b[0] = (TextView) findViewById(R.id.text11); b[1] = (TextView) findViewById(R.id.text21); b[2] = (TextView) findViewById(R.id.text31); return b; } public void changeValue(int id) { switch (id) { case (R.id.buttonPlus11): aux = value.indexOf(textValues[0].getText().toString()) + 1; if (aux == value.size()) aux = 0; textValues[0].setText(value.get(aux)); break; case (R.id.buttonPlus12): aux = flush.indexOf(textFlushs[0].getText().toString()) + 1; if (aux == flush.size()) aux = 0; if (aux > 1) { textFlushs[0].setTextColor(Color.RED); } else { textFlushs[0].setTextColor(Color.BLACK); } textFlushs[0].setText(flush.get(aux)); break; case (R.id.buttonPlus21): aux = value.indexOf(textValues[1].getText().toString()) + 1; if (aux == value.size()) aux = 0; System.out.println("" + value.get(aux)); textValues[1].setText(value.get(aux)); break; case (R.id.buttonPlus22): aux = flush.indexOf(textFlushs[1].getText().toString()) + 1; if (aux == flush.size()) aux = 0; if (aux > 1) { textFlushs[1].setTextColor(Color.RED); } else { textFlushs[1].setTextColor(Color.BLACK); } textFlushs[1].setText(flush.get(aux)); break; case (R.id.buttonPlus31): aux = value.indexOf(textValues[2].getText().toString()) + 1; if (aux == value.size()) aux = 0; textValues[2].setText(value.get(aux)); break; case (R.id.buttonPlus32): aux = flush.indexOf(textFlushs[2].getText().toString()) + 1; if (aux == flush.size()) aux = 0; if (aux > 1) { textFlushs[2].setTextColor(Color.RED); } else { textFlushs[2].setTextColor(Color.BLACK); } textFlushs[2].setText(flush.get(aux)); break; case (R.id.buttonLess11): aux = value.indexOf(textValues[0].getText().toString()) - 1; if (aux == -1) aux = value.size() - 1; textValues[0].setText(value.get(aux)); break; case (R.id.buttonLess12): aux = flush.indexOf(textFlushs[0].getText().toString()) - 1; if (aux == -1) aux = flush.size() - 1; if (aux > 1) { textFlushs[0].setTextColor(Color.RED); } else { textFlushs[0].setTextColor(Color.BLACK); } textFlushs[0].setText(flush.get(aux)); break; case (R.id.buttonLess21): aux = value.indexOf(textValues[1].getText().toString()) - 1; if (aux == -1) aux = value.size() - 1; textValues[1].setText(value.get(aux)); break; case (R.id.buttonLess22): aux = flush.indexOf(textFlushs[1].getText().toString()) - 1; if (aux == -1) aux = flush.size() - 1; if (aux > 1) { textFlushs[1].setTextColor(Color.RED); } else { textFlushs[1].setTextColor(Color.BLACK); } textFlushs[1].setText(flush.get(aux)); break; case (R.id.buttonLess31): aux = value.indexOf(textValues[2].getText().toString()) - 1; if (aux == -1) aux = value.size() - 1; textValues[2].setText(value.get(aux)); ; break; case (R.id.buttonLess32): aux = flush.indexOf(textFlushs[2].getText().toString()) - 1; if (aux == -1) aux = flush.size() - 1; if (aux > 1) { textFlushs[2].setTextColor(Color.RED); } else { textFlushs[2].setTextColor(Color.BLACK); } textFlushs[2].setText(flush.get(aux)); break; } checkValue(); } public void checkValue() { if (textValues[0].getText().toString().equals("5") && textFlushs[0].getText().toString().equals("\u2660")) { cardOne.setImageResource(R.drawable.espadas5); } if (textValues[1].getText().toString().equals("2") && textFlushs[1].getText().toString().equals("\u2660")) { cardTwo.setImageResource(R.drawable.espadas2); } if (textValues[2].getText().toString().equals("5") && textFlushs[2].getText().toString().equals("\u2663")) { cardThree.setImageResource(R.drawable.paus5); } if (cardOne.getId() == R.drawable.espadas5 && cardTwo.getId() == R.drawable.espadas2 && cardThree.getId() == R.drawable.paus5) { Intent intent = new Intent(getApplicationContext(), Level7.class); startActivity(intent); } } }
100windows
100 Puzzles/src/levels/Level6.java
Java
epl
8,675
package levels; import lobster.games.studios.R; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.WindowManager.LayoutParams; public class Level3 extends Activity { private View selected_item = null; private int offset_x = 0; private int offset_y = 0; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.level); getWindow().addFlags(LayoutParams.FLAG_KEEP_SCREEN_ON); /* * ImageView img = (ImageView)findViewById(R.id.windowView1); * img.setOnTouchListener(new View.OnTouchListener() { * * public boolean onTouch(View v, MotionEvent event) { * switch(event.getAction()) { case MotionEvent.ACTION_DOWN: offset_x = * (int)event.getX(); offset_y = (int)event.getY(); selected_item = v; * break; default: break; } return false; } }); */ } }
100windows
100 Puzzles/src/levels/Level3.java
Java
epl
919
package levels; import lobster.games.studios.R; import android.app.Activity; import android.content.Intent; import android.hardware.Sensor; import android.hardware.SensorEvent; import android.hardware.SensorEventListener; import android.hardware.SensorManager; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.view.WindowManager.LayoutParams; import android.widget.ImageView; import android.widget.RelativeLayout; import android.widget.TextView; public class Level2 extends Activity implements SensorEventListener { private SensorManager sensorManager = null; private float axisX; private ImageView img; private TextView levelText; private RelativeLayout windowLayout; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE); setContentView(R.layout.level); getWindow().addFlags(LayoutParams.FLAG_KEEP_SCREEN_ON); levelText = new TextView(this); levelText = (TextView) findViewById(R.id.leveltext); levelText.setText("Level 2"); windowLayout = (RelativeLayout) findViewById(R.id.windowlayout); img = new ImageView(this); img.setImageResource(R.drawable.window); windowLayout.addView(img); img.setOnClickListener(new OnClickListener() { // @Override public void onClick(View v) { if (img.getId() == R.drawable.openwindow) { Intent intent = new Intent(getApplicationContext(), Level3.class); startActivity(intent); } } }); } @Override protected void onResume() { super.onResume(); sensorManager.registerListener(this, sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_NORMAL); sensorManager.registerListener(this, sensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION), SensorManager.SENSOR_DELAY_NORMAL); } @Override protected void onStop() { super.onStop(); sensorManager.unregisterListener(this, sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER)); sensorManager.unregisterListener(this, sensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION)); } public void onSensorChanged(SensorEvent event) { // TODO Auto-generated method stub synchronized (this) { switch (event.sensor.getType()) { case Sensor.TYPE_ACCELEROMETER: axisX = event.values[0]; if (axisX < 0) { img.setImageResource(R.drawable.openwindow); } else if (axisX > 0) { img.setImageResource(R.drawable.window); } break; } } } public void onAccuracyChanged(Sensor arg0, int arg1) { // TODO Auto-generated method stub } }
100windows
100 Puzzles/src/levels/Level2.java
Java
epl
2,754
package levels; import lobster.games.studios.R; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.view.WindowManager.LayoutParams; import android.widget.Button; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.RelativeLayout; import android.widget.TextView; public class Level1 extends Activity { private Thread splashTread; private ImageView windowImage; private TextView levelText; private Button icon2; private RelativeLayout screenLayout, windowLayout; private LinearLayout itemsLayout; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.level); getWindow().addFlags(LayoutParams.FLAG_KEEP_SCREEN_ON); screenLayout = (RelativeLayout) findViewById(R.id.gamelayout); windowLayout = (RelativeLayout) findViewById(R.id.windowlayout); itemsLayout = (LinearLayout) findViewById(R.id.linearlayout); windowImage = new ImageView(this); icon2 = new Button(this); windowImage.setImageResource(R.drawable.window); windowLayout.addView(windowImage); icon2 = (Button) findViewById(R.id.button2); icon2.setBackgroundResource(R.drawable.ic_launcher); levelText = new TextView(this); levelText = (TextView) findViewById(R.id.leveltext); levelText.setText("Level 1"); windowImage.setOnClickListener(new OnClickListener() { // @Override public void onClick(View v) { windowImage.invalidate(); windowImage.setImageResource(R.drawable.openwindow); splashTread = new Thread() { @Override public void run() { try { synchronized (this) { // wait 1 sec wait(1000); } } catch (InterruptedException e) { } finally { // start a new activity Intent intent = new Intent(getApplicationContext(), Level2.class); startActivity(intent); // stop(); } } }; splashTread.start(); } }); } }
100windows
100 Puzzles/src/levels/Level1.java
Java
epl
2,153
package som.util; import org.hibernate.HibernateException; import org.hibernate.Session; import org.hibernate.cfg.Configuration; /** * fdfg * Configures and provides access to Hibernate sessions, tied to the * current thread of execution. Follows the Thread Local Session * pattern, see {@link http://hibernate.org/42.html }. */ public class HibernateSessionFactory { /** * Location of hibernate.cfg.xml file. * Location should be on the classpath as Hibernate uses * #resourceAsStream style lookup for its configuration file. * The default classpath location of the hibernate config file is * in the default package. Use #setConfigFile() to update * the location of the configuration file for the current session. */ private static String CONFIG_FILE_LOCATION = "/hibernate.cfg.xml"; private static final ThreadLocal<Session> threadLocal = new ThreadLocal<Session>(); private static Configuration configuration = new Configuration(); private static org.hibernate.SessionFactory sessionFactory; private static String configFile = CONFIG_FILE_LOCATION; static { try { configuration.configure(configFile); sessionFactory = configuration.buildSessionFactory(); } catch (Exception e) { System.err .println("%%%% Error Creating SessionFactory %%%%"); e.printStackTrace(); } } private HibernateSessionFactory() { } /** * Returns the ThreadLocal Session instance. Lazy initialize * the <code>SessionFactory</code> if needed. * * @return Session * @throws HibernateException */ public static Session getSession() throws HibernateException { Session session = (Session) threadLocal.get(); if (session == null || !session.isOpen()) { if (sessionFactory == null) { rebuildSessionFactory(); } session = (sessionFactory != null) ? sessionFactory.openSession() : null; threadLocal.set(session); } return session; } /** * Rebuild hibernate session factory * */ public static void rebuildSessionFactory() { try { configuration.configure(configFile); sessionFactory = configuration.buildSessionFactory(); } catch (Exception e) { System.err .println("%%%% Error Creating SessionFactory %%%%"); e.printStackTrace(); } } /** * Close the single hibernate session instance. * * @throws HibernateException */ public static void closeSession() throws HibernateException { Session session = (Session) threadLocal.get(); threadLocal.set(null); if (session != null) { session.close(); } } /** * return session factory * */ public static org.hibernate.SessionFactory getSessionFactory() { return sessionFactory; } /** * return session factory * * session factory will be rebuilded in the next call */ public static void setConfigFile(String configFile) { HibernateSessionFactory.configFile = configFile; sessionFactory = null; } /** * return hibernate configuration * */ public static Configuration getConfiguration() { return configuration; } }
123ja
trunk/123ja--usernamesatandaice@gmail.com/aa/src/som/util/HibernateSessionFactory.java
Java
mit
3,217
package com.jboa.model; import java.util.HashSet; import java.util.Set; /** * Department entity. @author MyEclipse Persistence Tools */ public class Department implements java.io.Serializable { // Fields private String id; private String name; private Set profiles = new HashSet(0); private Set tusers = new HashSet(0); // Constructors /** default constructor */ public Department() { } /** minimal constructor */ public Department(String id, String name) { this.id = id; this.name = name; } /** full constructor */ public Department(String id, String name, Set profiles, Set tusers) { this.id = id; this.name = name; this.profiles = profiles; this.tusers = tusers; } // Property accessors public String getId() { return this.id; } public void setId(String id) { this.id = id; } public String getName() { return this.name; } public void setName(String name) { this.name = name; } public Set getProfiles() { return this.profiles; } public void setProfiles(Set profiles) { this.profiles = profiles; } public Set getTusers() { return this.tusers; } public void setTusers(Set tusers) { this.tusers = tusers; } }
123ja
trunk/123ja--usernamesatandaice@gmail.com/aa/src/com/jboa/model/Department.java
Java
mit
1,188
package com.jboa.model; import java.util.HashSet; import java.util.Set; /** * Job entity. @author MyEclipse Persistence Tools */ public class Job implements java.io.Serializable { // Fields private String id; private String name; private String tdesc; private Set profiles = new HashSet(0); private Set tusers = new HashSet(0); // Constructors /** default constructor */ public Job() { } /** minimal constructor */ public Job(String id, String name) { this.id = id; this.name = name; } /** full constructor */ public Job(String id, String name, String tdesc, Set profiles, Set tusers) { this.id = id; this.name = name; this.tdesc = tdesc; this.profiles = profiles; this.tusers = tusers; } // Property accessors public String getId() { return this.id; } public void setId(String id) { this.id = id; } public String getName() { return this.name; } public void setName(String name) { this.name = name; } public String getTdesc() { return this.tdesc; } public void setTdesc(String tdesc) { this.tdesc = tdesc; } public Set getProfiles() { return this.profiles; } public void setProfiles(Set profiles) { this.profiles = profiles; } public Set getTusers() { return this.tusers; } public void setTusers(Set tusers) { this.tusers = tusers; } }
123ja
trunk/123ja--usernamesatandaice@gmail.com/aa/src/com/jboa/model/Job.java
Java
mit
1,329
package com.jboa.model; /** * Authority entity. @author MyEclipse Persistence Tools */ public class Authority implements java.io.Serializable { // Fields private String id; private Tmenu tmenu; private Trole trole; // Constructors /** default constructor */ public Authority() { } /** minimal constructor */ public Authority(String id, Trole trole) { this.id = id; this.trole = trole; } /** full constructor */ public Authority(String id, Tmenu tmenu, Trole trole) { this.id = id; this.tmenu = tmenu; this.trole = trole; } // Property accessors public String getId() { return this.id; } public void setId(String id) { this.id = id; } public Tmenu getTmenu() { return this.tmenu; } public void setTmenu(Tmenu tmenu) { this.tmenu = tmenu; } public Trole getTrole() { return this.trole; } public void setTrole(Trole trole) { this.trole = trole; } }
123ja
trunk/123ja--usernamesatandaice@gmail.com/aa/src/com/jboa/model/Authority.java
Java
mit
912
package com.jboa.model; import java.util.HashSet; import java.util.Set; /** * Tmenu entity. @author MyEclipse Persistence Tools */ public class Tmenu implements java.io.Serializable { // Fields private String id; private Tmenu tmenu; private String text; private String url; private String icon; private Set tmenus = new HashSet(0); private Set authorities = new HashSet(0); // Constructors /** default constructor */ public Tmenu() { } /** minimal constructor */ public Tmenu(String id, String text, String url) { this.id = id; this.text = text; this.url = url; } /** full constructor */ public Tmenu(String id, Tmenu tmenu, String text, String url, String icon, Set tmenus, Set authorities) { this.id = id; this.tmenu = tmenu; this.text = text; this.url = url; this.icon = icon; this.tmenus = tmenus; this.authorities = authorities; } // Property accessors public String getId() { return this.id; } public void setId(String id) { this.id = id; } public Tmenu getTmenu() { return this.tmenu; } public void setTmenu(Tmenu tmenu) { this.tmenu = tmenu; } public String getText() { return this.text; } public void setText(String text) { this.text = text; } public String getUrl() { return this.url; } public void setUrl(String url) { this.url = url; } public String getIcon() { return this.icon; } public void setIcon(String icon) { this.icon = icon; } public Set getTmenus() { return this.tmenus; } public void setTmenus(Set tmenus) { this.tmenus = tmenus; } public Set getAuthorities() { return this.authorities; } public void setAuthorities(Set authorities) { this.authorities = authorities; } }
123ja
trunk/123ja--usernamesatandaice@gmail.com/aa/src/com/jboa/model/Tmenu.java
Java
mit
1,720
package com.jboa.model; import java.util.HashSet; import java.util.Set; /** * Trole entity. @author MyEclipse Persistence Tools */ public class Trole implements java.io.Serializable { // Fields private String id; private String name; private String tdesc; private Set tusers = new HashSet(0); private Set authorities = new HashSet(0); // Constructors /** default constructor */ public Trole() { } /** minimal constructor */ public Trole(String id, String name) { this.id = id; this.name = name; } /** full constructor */ public Trole(String id, String name, String tdesc, Set tusers, Set authorities) { this.id = id; this.name = name; this.tdesc = tdesc; this.tusers = tusers; this.authorities = authorities; } // Property accessors public String getId() { return this.id; } public void setId(String id) { this.id = id; } public String getName() { return this.name; } public void setName(String name) { this.name = name; } public String getTdesc() { return this.tdesc; } public void setTdesc(String tdesc) { this.tdesc = tdesc; } public Set getTusers() { return this.tusers; } public void setTusers(Set tusers) { this.tusers = tusers; } public Set getAuthorities() { return this.authorities; } public void setAuthorities(Set authorities) { this.authorities = authorities; } }
123ja
trunk/123ja--usernamesatandaice@gmail.com/aa/src/com/jboa/model/Trole.java
Java
mit
1,372
package com.jboa.model; import java.util.HashSet; import java.util.Set; /** * Tuser entity. @author MyEclipse Persistence Tools */ public class Tuser implements java.io.Serializable { // Fields private String id; private Trole trole; private Department department; private Job job; private String username; private String password; private String phone; private String address; private String qq; private String email; private String status; private Set profiles = new HashSet(0); // Constructors /** default constructor */ public Tuser() { } /** minimal constructor */ public Tuser(String id, String username, String password, String status) { this.id = id; this.username = username; this.password = password; this.status = status; } /** full constructor */ public Tuser(String id, Trole trole, Department department, Job job, String username, String password, String phone, String address, String qq, String email, String status, Set profiles) { this.id = id; this.trole = trole; this.department = department; this.job = job; this.username = username; this.password = password; this.phone = phone; this.address = address; this.qq = qq; this.email = email; this.status = status; this.profiles = profiles; } // Property accessors public String getId() { return this.id; } public void setId(String id) { this.id = id; } public Trole getTrole() { return this.trole; } public void setTrole(Trole trole) { this.trole = trole; } public Department getDepartment() { return this.department; } public void setDepartment(Department department) { this.department = department; } public Job getJob() { return this.job; } public void setJob(Job job) { this.job = job; } public String getUsername() { return this.username; } public void setUsername(String username) { this.username = username; } public String getPassword() { return this.password; } public void setPassword(String password) { this.password = password; } public String getPhone() { return this.phone; } public void setPhone(String phone) { this.phone = phone; } public String getAddress() { return this.address; } public void setAddress(String address) { this.address = address; } public String getQq() { return this.qq; } public void setQq(String qq) { this.qq = qq; } public String getEmail() { return this.email; } public void setEmail(String email) { this.email = email; } public String getStatus() { return this.status; } public void setStatus(String status) { this.status = status; } public Set getProfiles() { return this.profiles; } public void setProfiles(Set profiles) { this.profiles = profiles; } }
123ja
trunk/123ja--usernamesatandaice@gmail.com/aa/src/com/jboa/model/Tuser.java
Java
mit
2,758
package com.jboa.model; import java.math.BigDecimal; import java.util.Date; /** * Profile entity. @author MyEclipse Persistence Tools */ public class Profile implements java.io.Serializable { // Fields private String profileid; private Department department; private Tuser tuser; private Job job; private String fullname; private String address; private Date birthday; private String homezip; private String sex; private String marriage; private String phone; private String mobile; private String openbank; private String bankno; private String qq; private String email; private String hobby; private String religion; private String party; private String nationality; private String race; private String birthplace; private String edudegree; private String edumajor; private String educollege; private Date startworkdate; private String educase; private String awardpunishcase; private String trainingcase; private String workcase; private String idcard; private String photo; private String standardmino; private Double standardmoney; private String standardname; private Long standardid; private String creator; private Date createtime; private String checkname; private Date checktime; private BigDecimal approvalstatus; private String memo; // Constructors /** default constructor */ public Profile() { } /** minimal constructor */ public Profile(String profileid, Tuser tuser, Job job, String fullname) { this.profileid = profileid; this.tuser = tuser; this.job = job; this.fullname = fullname; } /** full constructor */ public Profile(String profileid, Department department, Tuser tuser, Job job, String fullname, String address, Date birthday, String homezip, String sex, String marriage, String phone, String mobile, String openbank, String bankno, String qq, String email, String hobby, String religion, String party, String nationality, String race, String birthplace, String edudegree, String edumajor, String educollege, Date startworkdate, String educase, String awardpunishcase, String trainingcase, String workcase, String idcard, String photo, String standardmino, Double standardmoney, String standardname, Long standardid, String creator, Date createtime, String checkname, Date checktime, BigDecimal approvalstatus, String memo) { this.profileid = profileid; this.department = department; this.tuser = tuser; this.job = job; this.fullname = fullname; this.address = address; this.birthday = birthday; this.homezip = homezip; this.sex = sex; this.marriage = marriage; this.phone = phone; this.mobile = mobile; this.openbank = openbank; this.bankno = bankno; this.qq = qq; this.email = email; this.hobby = hobby; this.religion = religion; this.party = party; this.nationality = nationality; this.race = race; this.birthplace = birthplace; this.edudegree = edudegree; this.edumajor = edumajor; this.educollege = educollege; this.startworkdate = startworkdate; this.educase = educase; this.awardpunishcase = awardpunishcase; this.trainingcase = trainingcase; this.workcase = workcase; this.idcard = idcard; this.photo = photo; this.standardmino = standardmino; this.standardmoney = standardmoney; this.standardname = standardname; this.standardid = standardid; this.creator = creator; this.createtime = createtime; this.checkname = checkname; this.checktime = checktime; this.approvalstatus = approvalstatus; this.memo = memo; } // Property accessors public String getProfileid() { return this.profileid; } public void setProfileid(String profileid) { this.profileid = profileid; } public Department getDepartment() { return this.department; } public void setDepartment(Department department) { this.department = department; } public Tuser getTuser() { return this.tuser; } public void setTuser(Tuser tuser) { this.tuser = tuser; } public Job getJob() { return this.job; } public void setJob(Job job) { this.job = job; } public String getFullname() { return this.fullname; } public void setFullname(String fullname) { this.fullname = fullname; } public String getAddress() { return this.address; } public void setAddress(String address) { this.address = address; } public Date getBirthday() { return this.birthday; } public void setBirthday(Date birthday) { this.birthday = birthday; } public String getHomezip() { return this.homezip; } public void setHomezip(String homezip) { this.homezip = homezip; } public String getSex() { return this.sex; } public void setSex(String sex) { this.sex = sex; } public String getMarriage() { return this.marriage; } public void setMarriage(String marriage) { this.marriage = marriage; } public String getPhone() { return this.phone; } public void setPhone(String phone) { this.phone = phone; } public String getMobile() { return this.mobile; } public void setMobile(String mobile) { this.mobile = mobile; } public String getOpenbank() { return this.openbank; } public void setOpenbank(String openbank) { this.openbank = openbank; } public String getBankno() { return this.bankno; } public void setBankno(String bankno) { this.bankno = bankno; } public String getQq() { return this.qq; } public void setQq(String qq) { this.qq = qq; } public String getEmail() { return this.email; } public void setEmail(String email) { this.email = email; } public String getHobby() { return this.hobby; } public void setHobby(String hobby) { this.hobby = hobby; } public String getReligion() { return this.religion; } public void setReligion(String religion) { this.religion = religion; } public String getParty() { return this.party; } public void setParty(String party) { this.party = party; } public String getNationality() { return this.nationality; } public void setNationality(String nationality) { this.nationality = nationality; } public String getRace() { return this.race; } public void setRace(String race) { this.race = race; } public String getBirthplace() { return this.birthplace; } public void setBirthplace(String birthplace) { this.birthplace = birthplace; } public String getEdudegree() { return this.edudegree; } public void setEdudegree(String edudegree) { this.edudegree = edudegree; } public String getEdumajor() { return this.edumajor; } public void setEdumajor(String edumajor) { this.edumajor = edumajor; } public String getEducollege() { return this.educollege; } public void setEducollege(String educollege) { this.educollege = educollege; } public Date getStartworkdate() { return this.startworkdate; } public void setStartworkdate(Date startworkdate) { this.startworkdate = startworkdate; } public String getEducase() { return this.educase; } public void setEducase(String educase) { this.educase = educase; } public String getAwardpunishcase() { return this.awardpunishcase; } public void setAwardpunishcase(String awardpunishcase) { this.awardpunishcase = awardpunishcase; } public String getTrainingcase() { return this.trainingcase; } public void setTrainingcase(String trainingcase) { this.trainingcase = trainingcase; } public String getWorkcase() { return this.workcase; } public void setWorkcase(String workcase) { this.workcase = workcase; } public String getIdcard() { return this.idcard; } public void setIdcard(String idcard) { this.idcard = idcard; } public String getPhoto() { return this.photo; } public void setPhoto(String photo) { this.photo = photo; } public String getStandardmino() { return this.standardmino; } public void setStandardmino(String standardmino) { this.standardmino = standardmino; } public Double getStandardmoney() { return this.standardmoney; } public void setStandardmoney(Double standardmoney) { this.standardmoney = standardmoney; } public String getStandardname() { return this.standardname; } public void setStandardname(String standardname) { this.standardname = standardname; } public Long getStandardid() { return this.standardid; } public void setStandardid(Long standardid) { this.standardid = standardid; } public String getCreator() { return this.creator; } public void setCreator(String creator) { this.creator = creator; } public Date getCreatetime() { return this.createtime; } public void setCreatetime(Date createtime) { this.createtime = createtime; } public String getCheckname() { return this.checkname; } public void setCheckname(String checkname) { this.checkname = checkname; } public Date getChecktime() { return this.checktime; } public void setChecktime(Date checktime) { this.checktime = checktime; } public BigDecimal getApprovalstatus() { return this.approvalstatus; } public void setApprovalstatus(BigDecimal approvalstatus) { this.approvalstatus = approvalstatus; } public String getMemo() { return this.memo; } public void setMemo(String memo) { this.memo = memo; } }
123ja
trunk/123ja--usernamesatandaice@gmail.com/aa/src/com/jboa/model/Profile.java
Java
mit
9,219
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <title>My JSP 'index.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> </head> <body> This is my JSP page. <br> </body> </html>
123ja
trunk/123ja--usernamesatandaice@gmail.com/aa/WebRoot/index.jsp
Java Server Pages
mit
829
package constants; import client.Command; public class Constants { public static enum Color{ blue, red, green, cyan, magenta, orange, pink, yellow } // Order of enum important for determining opposites public static enum dir { N, W, E, S }; public static dir oppositeDir(dir d){ if(d== dir.N) return dir.S; else if(d == dir.E) return dir.W; else if(d == dir.W) return dir.E; else return dir.N; } public static Command NOOP = new Command("NoOp"); public static String NOOP_str = "NoOp"; public static String MOVE_str = "Move"; public static String PUSH_str = "Push"; public static String PULL_str = "Pull"; }
02285-ai-final
trunk/AI project/src/constants/Constants.java
Java
oos
663
package client; import java.util.LinkedList; import constants.Constants.*; public class Command { static { LinkedList< Command > cmds = new LinkedList< Command >(); for ( dir d : dir.values() ) { cmds.add( new Command( d ) ); } for ( dir d1 : dir.values() ) { for ( dir d2 : dir.values() ) { if ( !Command.isOpposite( d1, d2 ) ) { cmds.add( new Command( "Push", d1, d2 ) ); } } } for ( dir d1 : dir.values() ) { for ( dir d2 : dir.values() ) { if ( d1 != d2 ) { cmds.add( new Command( "Pull", d1, d2 ) ); } } } every = cmds.toArray( new Command[0] ); } public final static Command[] every; private static boolean isOpposite( dir d1, dir d2 ) { return d1.ordinal() + d2.ordinal() == 3; } public String cmd; public dir dir1; public dir dir2; public Command( dir d ) { cmd = "Move"; dir1 = d; } public Command(String s) { if (s.toLowerCase().equals("noop")) cmd = "NoOp"; cmd = "NoOp"; // Are there others? } public Command( String s, dir d1, dir d2 ) { cmd = s; dir1 = d1; dir2 = d2; } public String toString() { if ( dir1 == null ) return cmd; else if ( dir2 == null) return cmd + "(" + dir1 + ")"; return cmd + "(" + dir1 + "," + dir2 + ")"; } }
02285-ai-final
trunk/AI project/src/client/Command.java
Java
oos
1,265
package client; public enum Action { MoveEast, MoveWest, MoveNorth, MoveSouth, PushNW, PushW, PushSW, PushS, PushSE, PushE, PushNE, PushN, PullNW, PullW, PullSW, PullS, PullSE, PullE, PullNE, PullN, NoOp }
02285-ai-final
trunk/AI project/src/client/Action.java
Java
oos
252
package client.planners; import java.util.ArrayList; import java.util.Collection; import java.util.Random; import agent.objectives.DockABox; import agent.objectives.GoalABox; import agent.objectives.Objective; import agent.planners.AgentPlanner; import agent.planners.AgentProgressionPlanner; import utils.GoalPriority; import utils.Utils; import LevelObjects.Agent; import LevelObjects.Box; import LevelObjects.Field; import LevelObjects.Goal; import LevelObjects.Level; public class ClientPlanner implements Planner { Level level; Random rand; public boolean firstRun = true; private static final String name = "ClientPlanner"; @Override public String getName() { return name; } public ClientPlanner(Level l) { this.level = l; rand = new Random(); } public void makePlan() { // System.err.println("Make plan!"); AgentPlanner planner = new AgentProgressionPlanner(level); int agentsNeedsPlans = 0; for (Agent agent : level.agents) { if(agent.objectives.isEmpty()) agentsNeedsPlans++; } if(agentsNeedsPlans == level.agents.size() && !Utils.allGoalsHasBoxes(level)) firstRun = true; if (firstRun) { GoalPriority.createGoalPrioritization(level, true); for (Agent a : level.agents) { a.priority = 99; a.planner = planner; a.possibleBoxesToGoals = Utils.findPossibleBoxes(level, a); } // Find goals in order and find an agent to goal it ArrayList<Goal> goals_assigned = new ArrayList<Goal>(); for (Goal g : level.goals) { for (Agent a : level.agents) { for (Box b : a.possibleBoxesToGoals.keySet()) { Goal goal = null; if (a.possibleBoxesToGoals.containsKey(b) && Utils.boxFitsGoal(b, g)){ //add goal with lowest priority goal = GoalPriority.FindGoalWithHighestPriority(a, b, level, goals_assigned); goals_assigned.add(goal); if(goal == null) continue; if(a.objectives == null || a.objectives.isEmpty()) a.objectives.addFirst(new GoalABox(b, goal)); else{ Objective o = a.objectives.peek(); if(o instanceof GoalABox && ((GoalABox) o).goal.getPriority() > goal.getPriority()){ a.objectives.addFirst(new GoalABox(b, goal)); } else{ a.objectives.addLast(new GoalABox(b, goal)); } } if(a.priority > goal.priority) a.priority = goal.priority; } } } } firstRun = false; } for (Agent a : level.agents) { if(a.objectives.isEmpty()){ Goal goal_highest_priority = Utils.allOfAgentGoalsHasBoxes(a, level); if(goal_highest_priority != null){ //Find route to goal Collection<Field> blockedFields = null; ArrayList<Box> boxesInTheWay = null; boxesInTheWay = Utils.findRouteCountBoxesInTheWay(level, a, a.getAtField(), new Field(goal_highest_priority.x, goal_highest_priority.y), blockedFields); //remove boxes in the way boxesInTheWayLoop : for (Box box : boxesInTheWay) { if(box.getId() == a.getId()){ //make DockABox thing Objective o = new DockABox(box.getAtField(), box, 15); a.objectives.addFirst(o); break boxesInTheWayLoop; } } } } a.planAndExecute(level); } } }
02285-ai-final
trunk/AI project/src/client/planners/ClientPlanner.java
Java
oos
3,461
package client.planners; public interface Planner { public String getName(); public void makePlan(); }
02285-ai-final
trunk/AI project/src/client/planners/Planner.java
Java
oos
119
package client; import LevelObjects.Agent; import LevelObjects.Box; import LevelObjects.Goal; public class Desire { public Agent agent; public Box box; public Goal goal; boolean completed; public Desire(Agent a, Box b) { this.agent = a; this.box = b; } public Desire(Agent a, Box b, Goal g) { this.agent = a; this.box = b; this.goal = g; } }
02285-ai-final
trunk/AI project/src/client/Desire.java
Java
oos
369
package client; import java.awt.Dimension; import java.awt.Font; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.HashMap; import java.util.Map.Entry; import java.util.concurrent.LinkedBlockingQueue; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JSeparator; import javax.swing.JTextArea; import javax.swing.JTextField; import javax.swing.UIManager; public class GuiClient extends JFrame { private static ActionListener listener = new ActionListener() { @Override public void actionPerformed( ActionEvent e ) { CommandButton c = ( (CommandButton) e.getSource() ); buttonSend( c.t, c.cmd ); } }; // Receiver and Transmitter are not needed for most planners, but may lead to (negligible) speed up as you do not synchronize each // action with the server private class ServerReceiver extends Thread { private GuiClient gui; public ServerReceiver( GuiClient g ) { gui = g; } public void run() { try { BufferedReader reader = new BufferedReader( new InputStreamReader( System.in ) ); while ( true ) { String msg = reader.readLine(); if ( msg == null ) throw new IOException( "End of server messages" ); gui.AddCommunication( "<IN> " + msg ); } } catch ( IOException e ) { gui.AddInformation( e.toString() ); } } } private class ServerTransmitter extends Thread { private GuiClient gui; private LinkedBlockingQueue< String > outbound = new LinkedBlockingQueue< String >(); public ServerTransmitter( GuiClient g ) { gui = g; } public void run() { try { while ( true ) { String msg = outbound.take(); System.out.println( msg ); gui.AddCommunication( "<OUT> " + msg ); } } catch ( InterruptedException e ) { gui.AddInformation( e.toString() ); } } } private class CommandButton extends JButton { public final String cmd; public final ServerTransmitter t; public CommandButton( ServerTransmitter t, String label, String cmd ) { super( label ); this.t = t; this.cmd = cmd; this.addActionListener( listener ); } } public static void buttonSend( ServerTransmitter st, String cmd ) { st.outbound.add( cmd ); } private final String nl = System.getProperty( "line.separator" ); private JTextArea communication = new JTextArea(); private JTextArea information = new JTextArea(); private JPanel fixed = new JPanel(); private JPanel custom = new JPanel(); private JPanel comm = new JPanel(); private JPanel info = new JPanel(); private int msgNo; private int agents; private ServerReceiver receiver; private ServerTransmitter transmitter; private class GBC extends GridBagConstraints { public GBC( int x, int y ) { this( x, y, 1 ); } public GBC( int x, int y, int spanx ) { this.insets = new Insets( 0, 3, 0, 3 ); this.gridx = x; this.gridy = y; this.gridwidth = spanx; this.fill = GridBagConstraints.NONE; } public GBC( int x, int y, int spanx, int sep ) { this.insets = new Insets( sep, 3, sep, 3 ); this.gridx = x; this.gridy = y; this.gridwidth = spanx; this.fill = GridBagConstraints.HORIZONTAL; this.weightx = 0; } } public GuiClient( String[] customs ) throws IOException { super( "02285 Toy Client" ); System.err.println("Hello from GuiClient"); readMap(); // Get agent count receiver = new ServerReceiver( this ); transmitter = new ServerTransmitter( this ); communication.setEditable( false ); communication.setFont( new Font( "Monospaced", Font.PLAIN, 11 ) ); information.setEditable( false ); information.setFont( new Font( "Monospaced", Font.PLAIN, 11 ) ); // Fixed Buttons panel JSeparator sep1 = new JSeparator( JSeparator.HORIZONTAL ); JSeparator sep2 = new JSeparator( JSeparator.HORIZONTAL ); HashMap< String, GBC > buts = new HashMap< String, GBC >(); fixed.setLayout( new GridBagLayout() ); buts.put( "Move(N)", new GBC( 3, 0 ) ); buts.put( "Move(W)", new GBC( 2, 1 ) ); buts.put( "Move(E)", new GBC( 4, 1 ) ); buts.put( "Move(S)", new GBC( 3, 2 ) ); fixed.add( new JLabel( "Navigation" ), new GBC( 2, 1, 3 ) ); fixed.add( sep1, new GBC( 0, 3, 7, 10 ) ); int yoff = 4; buts.put( "Push(N,N)", new GBC( 3, yoff + 1 ) ); buts.put( "Push(N,W)", new GBC( 2, yoff + 1 ) ); buts.put( "Push(W,N)", new GBC( 1, yoff + 2 ) ); buts.put( "Push(W,W)", new GBC( 1, yoff + 3 ) ); buts.put( "Push(W,S)", new GBC( 1, yoff + 4 ) ); buts.put( "Push(S,W)", new GBC( 2, yoff + 5 ) ); buts.put( "Push(N,E)", new GBC( 4, yoff + 1 ) ); buts.put( "Push(E,N)", new GBC( 5, yoff + 2 ) ); buts.put( "Push(E,E)", new GBC( 5, yoff + 3 ) ); buts.put( "Push(E,S)", new GBC( 5, yoff + 4 ) ); buts.put( "Push(S,E)", new GBC( 4, yoff + 5 ) ); buts.put( "Push(S,S)", new GBC( 3, yoff + 5 ) ); fixed.add( new JLabel( "Push" ), new GBC( 2, yoff + 3, 3 ) ); fixed.add( sep2, new GBC( 0, yoff + 7, 7, 10 ) ); yoff = 12; buts.put( "Pull(N,S)", new GBC( 3, yoff + 1 ) ); buts.put( "Pull(N,W)", new GBC( 2, yoff + 1 ) ); buts.put( "Pull(W,N)", new GBC( 1, yoff + 2 ) ); buts.put( "Pull(W,E)", new GBC( 1, yoff + 3 ) ); buts.put( "Pull(W,S)", new GBC( 1, yoff + 4 ) ); buts.put( "Pull(S,W)", new GBC( 2, yoff + 5 ) ); buts.put( "Pull(S,N)", new GBC( 3, yoff + 5 ) ); buts.put( "Pull(N,E)", new GBC( 4, yoff + 1 ) ); buts.put( "Pull(E,N)", new GBC( 5, yoff + 2 ) ); buts.put( "Pull(E,W)", new GBC( 5, yoff + 3 ) ); buts.put( "Pull(E,S)", new GBC( 5, yoff + 4 ) ); buts.put( "Pull(S,E)", new GBC( 4, yoff + 5 ) ); fixed.add( new JLabel( "Pull" ), new GBC( 2, yoff + 3, 3 ) ); for ( Entry< String, GBC > e : buts.entrySet() ) { fixed.add( new CommandButton( transmitter, e.getKey(), "[" + Multify( e.getKey() ) + "]" ), e.getValue() ); } // Custom Panel GridBagConstraints c = new GridBagConstraints(); c.gridy++; custom.setLayout( new GridBagLayout() ); if ( customs.length == 0 ) customs = new String[] { "", "" }; for ( int i = 0; i < customs.length; i++ ) { JButton but = new JButton( "Command " + i ); final JTextField input = new JTextField( customs[i] ); but.addActionListener( new ActionListener() { @Override public void actionPerformed( ActionEvent e ) { buttonSend( transmitter, input.getText() ); } } ); c = new GridBagConstraints(); c.gridy = i; c.fill = GridBagConstraints.HORIZONTAL; custom.add( but, c ); c.weightx = 0.80; c.gridx = 1; custom.add( input, c ); } // Communication panel comm.setLayout( new GridBagLayout() ); comm.setMinimumSize(new Dimension(200, 250)); c = new GridBagConstraints(); c.ipadx = 5; comm.add( new JLabel( "Communication Done" ), c ); c.gridy = 1; c.weightx = 1; c.weighty = 1; c.fill = GridBagConstraints.BOTH; comm.add( new JScrollPane( communication, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED ), c ); // Information panel info.setLayout( new GridBagLayout() ); comm.setMinimumSize(new Dimension(200, 100)); c = new GridBagConstraints(); c.ipadx = 5; info.add( new JLabel( "Client Information (e.g. Exceptions)" ), c ); c.gridy = 1; c.weightx = 1; c.weighty = 1; c.fill = GridBagConstraints.BOTH; info.add( new JScrollPane( information, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED ), c ); // Add components to main frame setLayout( new GridBagLayout() ); c = new GridBagConstraints(); c.weightx = 1; c.fill = GridBagConstraints.HORIZONTAL; c.insets = new Insets( 3, 3, 3, 3 ); add( fixed, c ); c.gridy = 1; add( custom, c ); c.gridy = 2; c.weighty = 0.8; c.fill = GridBagConstraints.BOTH; add( comm, c ); c.gridy = 3; c.weighty = 0.2; add( info, c ); setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); setMinimumSize( new Dimension( 525, 820 ) ); setLocation( 800, 120 ); receiver.start(); transmitter.start(); this.pack(); setVisible( true ); } public void AddCommunication( String m ) { // Append is thread safe.. communication.append( msgNo + ":\t" + m + nl ); synchronized ( this ) { communication.setCaretPosition( communication.getText().length() ); msgNo++; } } public void AddInformation( String m ) { // Append is thread safe.. information.append( m + nl ); synchronized ( this ) { information.setCaretPosition( information.getText().length() ); } } /** * Turns Cmd into Cmd,Cmd,Cmd (..) based on number of agents * * @param cmd * @return Multified cmd */ private String Multify( String cmd ) { String s = ""; for ( int i = 0; i < agents - 1; i++ ) { s += cmd + ","; } return s + cmd; } private void readMap() throws IOException { BufferedReader in = new BufferedReader( new InputStreamReader( System.in ) ); agents = 0; String line; // Read lines specifying colors while ( ( line = in.readLine() ).matches( "^[a-z]+:\\s*[0-9A-Z](,\\s*[0-9A-Z])*\\s*$" ) ) { // Skip } // Read lines specifying level layout // By convention levels are ended with an empty newline while ( !line.equals( "" ) ) { for ( int i = 0; i < line.length(); i++ ) { char id = line.charAt( i ); if ( '0' <= id && id <= '9' ) agents++; } line = in.readLine(); if ( line == null ) break; } } public static void main( String[] args ) { try { UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() ); new GuiClient( args ); } catch ( Exception e ) { e.printStackTrace(); } } }
02285-ai-final
trunk/AI project/src/client/GuiClient.java
Java
oos
9,836
package client; import java.util.Arrays; import java.util.Scanner; public class Output { private static Scanner scan = new Scanner(System.in); /*public Output() { scan = new Scanner(System.in); }*/ public static boolean[] Send(Command[] commands) { // System.err.println("Sending: [" + Arrays.toString(commands) + "]"); String sendString = Arrays.toString(commands); sendString = sendString.replaceAll("null", "NoOp"); System.out.println(sendString); System.out.flush(); String feedback = scan.nextLine(); // [false, false] String[] elements = feedback.substring(1, feedback.length()-1).split(", "); boolean[] result = new boolean[elements.length]; int i = 0; for (String s : elements) result[i++] = Boolean.parseBoolean(s); return result; } }
02285-ai-final
trunk/AI project/src/client/Output.java
Java
oos
821
package client; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.Map; import constants.Constants.Color; import constants.Constants.dir; import LevelObjects.Agent; import LevelObjects.Box; import LevelObjects.Field; import LevelObjects.Goal; import LevelObjects.Level; public class Parser { // Flaws in current implementation: // - fields outside walls are created. A simple search could easily remove them, but they don't seem to be in the way, yet. public static Level readLevel() throws IOException { Level l = new Level(); //FileReader fR = new FileReader("src/levels/FOMAbispebjerg.lvl"); //BufferedReader in = new BufferedReader(fR); BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); // Read lines specifying colors Map<Character,Color> colors = new HashMap<Character,Color>(); String line; Color color; while ((line = in.readLine()).matches("^[a-z]+:\\s*[0-9A-Z](,\\s*[0-9A-Z])*\\s*$")) { line = line.replaceAll("\\s", ""); color = Color.valueOf(line.split(":")[0]); for (String id : line.split(":")[1].split(",")) colors.put(id.charAt(0), color); } // Read level layout ArrayList<String> rawLevel = new ArrayList<String>(); while (!line.equals("")) { rawLevel.add(line); line = in.readLine(); } // Set size of field map int maxWidth = 0; for (int y=1; y<rawLevel.size()-1; y++) { if (rawLevel.get(y).length() > maxWidth) { maxWidth = rawLevel.get(y).length(); } } l.setFieldMap(new Field[maxWidth][rawLevel.size()]); // Read lines specifying level layout (skipping the border) for (int y=0; y<rawLevel.size(); y++) { for (int x=0; x<rawLevel.get(y).length(); x++) { char id = rawLevel.get(y).charAt(x); if ('+' == id) continue; // skip if wall Field f; if ('0' <= id && id <= '9') { f = new Field(x,y); Agent a = new Agent(id, colors.get(id), f); l.agents.add(a); f.setObject(a); } else if ('A' <= id && id <= 'Z') { f = new Field(x,y); Box b = new Box(id, colors.get(id), f); l.boxes.add(b); f.setObject(b); } else if ('a' <= id && id <= 'z') { f = new Goal(id,x,y); l.goals.add((Goal)f); } else { f = new Field(x,y); } l.fields.add(f); l.fieldMap[x][y] = f; // Field links if(x!=0 && l.fieldMap[x-1][y] != null){ if (rawLevel.get(y).charAt(x-1) != '+') LinkFieldsHorizontal(f, l.fieldMap[x-1][y]); // link left } if(y!=0 && l.fieldMap[x][y-1] != null){ if (rawLevel.get(y-1).charAt(x) != '+') LinkFieldsVertical(f, l.fieldMap[x][y-1]); // link up (negative y) } } } //THE AGENTS NEED TO BE SORTED Collections.sort(l.agents, new Comparator<Agent>() { @Override public int compare(Agent a1, Agent a2) { int a1Id = Integer.parseInt(""+a1.getId()); int a2Id = Integer.parseInt(""+a2.getId()); return a1Id-a2Id; } }); return l; } private static void LinkFieldsHorizontal(Field east, Field west) { east.neighbours[dir.W.ordinal()] = west; west.neighbours[dir.E.ordinal()] = east; } private static void LinkFieldsVertical(Field south, Field north) { south.neighbours[dir.N.ordinal()] = north; north.neighbours[dir.S.ordinal()] = south; } }
02285-ai-final
trunk/AI project/src/client/Parser.java
Java
oos
3,549
package client.clients; import java.io.IOException; import constants.Constants; import constants.Constants.dir; import utils.Communication; import utils.Timer; import LevelObjects.Agent; import LevelObjects.Box; import LevelObjects.Field; import LevelObjects.Level; import client.Command; import client.Output; import client.Parser; import client.planners.ClientPlanner; import client.planners.Planner; public class Client { private static Level level; private static Planner planner; private static boolean timer; public static int stepCount = 0; public static boolean[] agentsFailed; public Client(String plannerName) throws IOException { level = Parser.readLevel(); planner = getPlanner(plannerName, level); } public static void main(String[] args) { try { String plannerName = "simple"; // DEFAULT timer = true; if (args.length==1) plannerName = args[0]; else if (args.length==2 && args[1].toLowerCase().equals("notimer")) timer = false; Timer t1 = new Timer(); t1.takeTime(); Client client = new Client(plannerName); agentsFailed = new boolean[level.agents.size()]; t1.stop(); // System.err.println("Level parsed. Time taken: " + t1.toString()); System.err.println( "Hello from " + planner.getName()); while (client.update()) ; } catch (Exception e) { e.printStackTrace(); } } private static Planner getPlanner(String name, Level l) { return new ClientPlanner(l); } public boolean update() throws IOException { Command[] commands = new Command[level.agents.size()]; // Get commands from agents' commandQueue loadCommands(commands); // Check if all agents have no commands left. If true, plan new commands. boolean noOps = true; for (int i = 0; i < commands.length; i++) { if (commands[i] != null) noOps = false; } if (noOps) { // System.err.println("No ops !"); Timer t = new Timer(); planner.makePlan(); t.stop(); // System.err.println("Plan calculated. Time taken: " + t.toString()); loadCommands(commands); } // Send commands to server, receive results boolean[] result = Output.Send(commands); // Let all commands accepted by the server update the level state boolean failed = false; boolean conflictFound = false; Agent conflictingAgent = null; for (int i = 0; i < result.length; i++) { if(conflictingAgent != null){ if(conflictingAgent.getId() == level.agents.get(i).getId()){ //if the other agent wins, do what he says.. Command c = commands[i]; flushAgentCommands(level.agents.get(i), c); } } if (result[i]){ completeCommand(commands[i], level.agents.get(i)); } else { // System.err.println("Conflict!!!!! " + i); Agent a = level.agents.get(i); Command c = commands[i]; //if (c.cmd.toLowerCase().equals("move")) if (c.cmd.toLowerCase().equals("move") || c.cmd.toLowerCase().equals("pull"))// agent moves { Object o = a.getAtField().neighbours[c.dir1.ordinal()].object; if (o == null) { a.commandQueue.add(Constants.NOOP); } else if(o instanceof Box) { //A box is in the way. find which box Box otherBox = (Box)o; // System.err.println("Agent" + i + " at: [" + a.getAtField() + "]. Move box at: [" + otherBox.getAtField() +"]"); //Find an agent to move the box conflictingAgent = Communication.FindAgentToMoveBox(otherBox, level); a.obstacle = o; } else if(o instanceof Agent){ a.obstacle = o; } } else { //We are pushing and should look at the next field.. Object o = a.getAtField().neighbours[c.dir1.ordinal()].neighbours[c.dir1.ordinal()].object; if (o == null) { // Field agents_desired_field = a.getAtField().neighbours[c.dir2.ordinal()]; // if(!Utils.CheckIfAnAgentWasOnThisFieldLastTurn(level, agents_desired_field)){ // System.err.println("Blocked field! Field [" + agents_desired_field.x + "." + agents_desired_field.y + "]"); // removeField(agents_desired_field); a.commandQueue.clear(); // } } else if(o instanceof Agent || o instanceof Box) { a.obstacle = o; } } flushAgentCommands(level.agents.get(i), c); //TODO: if there is no box or agent on the desired place it is a hidden obstacle -> remove it from graph updateBeliefs(commands[i], level.agents.get(i)); failed = true; } } agentsFailed = result; stepCount++; return true; } /** * Removes a field from the graph * @param field the field to be dereferenced. */ private void removeField(Field field) { for (dir direction : dir.values()) { Field neighbour = field.neighbours[direction.ordinal()]; neighbour.neighbours[Constants.oppositeDir(direction).ordinal()] = null; } } /** * Restores the agents objective from last iteration and the command queue from the error * @param agent * @param failedCommand The command on which the program failed */ private void flushAgentCommands(Agent agent, Command failedCommand) { agent.commandsNotCompleted.add(Constants.NOOP); agent.commandsNotCompleted.add(Constants.NOOP); agent.commandsNotCompleted.add(failedCommand); Command c; while ((c = agent.commandQueue.poll()) != null) agent.commandsNotCompleted.add(c); agent.objectives.addFirst(agent.tempObjective); agent.tempObjective = null; } private static void loadCommands(Command[] commands) { for (int i = 0; i < level.agents.size(); i++) { level.agents.get(i).lastLocation = level.agents.get(i).getAtField(); commands[i] = level.agents.get(i).commandQueue.poll(); } } private static void updateBeliefs(Command c, Agent a) { // TODO } // updates level by completing an agent command private static void completeCommand(Command c, Agent a) { if (c != null && a != null) { if (c.cmd.equals("Move")) completeMove(c, a); else if (c.cmd.equals("Pull")) completePull(c,a, (Box) a.getAtField().neighbours[c.dir2.ordinal()].object); else if (c.cmd.equals("Push")) completePush(c,a, (Box) a.getAtField().neighbours[c.dir1.ordinal()].object); } } private static void completeMove(Command c, Agent a) { a.getAtField().object = null; a.getAtField().neighbours[c.dir1.ordinal()].object = a; a.setAtField(a.getAtField().neighbours[c.dir1.ordinal()]); } private static void completePull(Command c, Agent a, Box o) { // Box moves to Agents' previous field o.getAtField().setObject(null); o.setAtField(a.getAtField()); a.setAtField(a.getAtField().neighbours[c.dir1.ordinal()]); o.getAtField().setObject(o); a.getAtField().setObject(a); } private static void completePush(Command c, Agent a, Box o) { // Agent moves to Box's previous field a.getAtField().setObject(null); a.setAtField(o.getAtField()); o.setAtField(o.getAtField().neighbours[c.dir2.ordinal()]); o.getAtField().setObject(o); a.getAtField().setObject(a); } }
02285-ai-final
trunk/AI project/src/client/clients/Client.java
Java
oos
7,237
package client.clients; import java.io.*; import java.util.*; import client.Command; public class RandomWalkClient { private static Random rand = new Random(); public class Agent { // We don't actually use these for Randomly Walking Around private char id; private String color; Agent( char id, String color ) { this.id = id; this.color = color; } public String act() { return Command.every[rand.nextInt( Command.every.length )].toString(); } } private BufferedReader in = new BufferedReader( new InputStreamReader( System.in ) ); private List< Agent > agents = new ArrayList< Agent >(); public RandomWalkClient() throws IOException { readMap(); } private void readMap() throws IOException { Map< Character, String > colors = new HashMap< Character, String >(); String line, color; // Read lines specifying colors while ( ( line = in.readLine() ).matches( "^[a-z]+:\\s*[0-9A-Z](,\\s*[0-9A-Z])*\\s*$" ) ) { line = line.replaceAll( "\\s", "" ); color = line.split( ":" )[0]; for ( String id : line.split( ":" )[1].split( "," ) ) colors.put( id.charAt( 0 ), color ); } // Read lines specifying level layout while ( !line.equals( "" ) ) { for ( int i = 0; i < line.length(); i++ ) { char id = line.charAt( i ); if ( '0' <= id && id <= '9' ) agents.add( new Agent( id, colors.get( id ) ) ); } line = in.readLine(); } } public boolean update() throws IOException { String jointAction = "["; for ( int i = 0; i < agents.size() - 1; i++ ) jointAction += agents.get( i ).act() + ","; System.out.println( jointAction + agents.get( agents.size() - 1 ).act() + "]" ); System.out.flush(); // Disregard these for now, but read or the server stalls when outputbuffer gets filled! String percepts = in.readLine(); if ( percepts == null ) return false; return true; } public static void main( String[] args ) { // Use stderr to print to console System.err.println( "Hello from RandomWalkClient. I am sending this using the error outputstream" ); try { RandomWalkClient client = new RandomWalkClient(); while ( client.update() ) ; } catch ( IOException e ) { // Got nowhere to write to probably } } }
02285-ai-final
trunk/AI project/src/client/clients/RandomWalkClient.java
Java
oos
2,239
package datastructures; import java.util.ArrayList; import java.util.List; import client.Command; import LevelObjects.Box; import LevelObjects.Field; public class MoveActionSequence extends ActionSequence { private Field startField; private Field endField; public List<Box> boxesInTheWay; public MoveActionSequence(Field from, Field to, ArrayList<Command> commands) { startField = from; endField = to; super.commands = commands; } public Field getStartField() { return startField; } public void setStartField(Field startField) { this.startField = startField; } public Field getEndField() { return endField; } public void setEndField(Field endField) { this.endField = endField; } }
02285-ai-final
trunk/AI project/src/datastructures/MoveActionSequence.java
Java
oos
760
package datastructures; import LevelObjects.Field; public class MoveBoxActionSequence extends ActionSequence { private Field agentLocation; private Field boxLocation; private Field targetLocation; public Field getAgentLocation() { return agentLocation; } public void setAgentLocation(Field agentLocation) { this.agentLocation = agentLocation; } public Field getBoxLocation() { return boxLocation; } public void setBoxLocation(Field boxLocation) { this.boxLocation = boxLocation; } public Field getTargetLocation() { return targetLocation; } public void setTargetLocation(Field targetLocation) { this.targetLocation = targetLocation; } }
02285-ai-final
trunk/AI project/src/datastructures/MoveBoxActionSequence.java
Java
oos
701
package datastructures; import LevelObjects.Field; public class GoalActionSequence extends ActionSequence { private Field agentStartLocation; private Field agentEndField; private Field boxStartLocation; private Field boxEndLocation; public Field getBoxStartLocation() { return boxStartLocation; } public void setBoxStartLocation(Field boxStartLocation) { this.boxStartLocation = boxStartLocation; } public Field getBoxEndLocation() { return boxEndLocation; } public void setBoxEndLocation(Field boxEndLocation) { this.boxEndLocation = boxEndLocation; } public Field getAgentEndField() { return agentEndField; } public void setAgentEndField(Field agentEndField) { this.agentEndField = agentEndField; } public Field getAgentStartLocation() { return agentStartLocation; } public void setAgentStartLocation(Field agentStartLocation) { this.agentStartLocation = agentStartLocation; } }
02285-ai-final
trunk/AI project/src/datastructures/GoalActionSequence.java
Java
oos
965
package datastructures; public class FieldBlockedChange { public int time; public boolean changeToBlocked; public FieldBlockedChange(int time, boolean c){ this.time = time; this.changeToBlocked = c; } }
02285-ai-final
trunk/AI project/src/datastructures/FieldBlockedChange.java
Java
oos
217
package datastructures; import java.util.ArrayList; import LevelObjects.Field; public class FieldInState extends ObjectInState { public ArrayList<FieldBlockedChange> blockedTimeChangeIndexes; public FieldInState(Field f) { super(); this.f = f; blockedTimeChangeIndexes = new ArrayList<FieldBlockedChange>(); } public FieldInState(Field f, ArrayList<FieldBlockedChange> blockedTimeIndexes) { super(); this.f = f; this.blockedTimeChangeIndexes = blockedTimeIndexes; } public boolean changesStatusInFuture(int timeStep){ for (FieldBlockedChange blockedTime : blockedTimeChangeIndexes) { if (blockedTime.time >= timeStep && blockedTime.changeToBlocked == true) { return true; } } return false; } public boolean freeInInterval(int start, int end){ // System.err.println("Checking " + this.f.toString() + " intervals: " + start + "-" +end); // for (FieldBlockedChange fb : blockedTimeChangeIndexes) { // System.err.print(fb.time+ " "); // } boolean previous = false; for (FieldBlockedChange blockedTime : blockedTimeChangeIndexes) { if (blockedTime.time > start && blockedTime.time <= end) { // System.err.println("HEEER"); return false; } previous = blockedTime.changeToBlocked; if(blockedTime.time > end){ return !previous; } } return !previous; } }
02285-ai-final
trunk/AI project/src/datastructures/FieldInState.java
Java
oos
1,349
package datastructures; import java.util.ArrayList; import LevelObjects.Field; import client.Command; public abstract class ActionSequence { private ActionSequence parent; public ArrayList<Field> fields; public ActionSequence getParent() { return parent; } public void setParent(ActionSequence parent) { this.parent = parent; } protected ArrayList<Command> commands; public ArrayList<Command> getCommands() { return commands; } public void setCommands(ArrayList<Command> commands) { this.commands = commands; } }
02285-ai-final
trunk/AI project/src/datastructures/ActionSequence.java
Java
oos
574
package datastructures; import LevelObjects.Agent; import LevelObjects.Field; public class AgentInState extends ObjectInState { public Agent a; public AgentInState(Agent a, Field f) { super(); this.a = a; this.f = f; } }
02285-ai-final
trunk/AI project/src/datastructures/AgentInState.java
Java
oos
237
package datastructures; import java.util.ArrayList; import client.Command; public class State implements Comparable<State> { public int g; public int f; public ArrayList<AgentInState> agents; public ArrayList<BoxInState> boxes; public ArrayList<FieldInState> fields; public State parent; public ArrayList<Command> commandFromParent; public int heuristicValue; public StateGoal goal; //Used for merging states. We know which step we are in, and all commands from this step should be used for merging. public int indexOfCommands; //Should be FOMA compatible public ArrayList<ActionSequence> actionSequencesFromParent; public State() { agents = new ArrayList<AgentInState>(); boxes = new ArrayList<BoxInState>(); fields = new ArrayList<FieldInState>(); commandFromParent = new ArrayList<Command>(); actionSequencesFromParent = new ArrayList<ActionSequence>(); } @Override public int compareTo(State o) { return this.heuristicValue - o.heuristicValue; } // public void printFieldChanges(){ // // for (FieldInState f : fields) { // System.err.print(f.f.toString()); // for (FieldBlockedChange fb : f.blockedTimeChangeIndexes) { // System.err.print(" " + fb.time + " " + fb.changeToBlocked); // } // System.err.println(); // } // // } }
02285-ai-final
trunk/AI project/src/datastructures/State.java
Java
oos
1,298
package datastructures; import LevelObjects.Box; import LevelObjects.Field; public class BoxInState extends ObjectInState { public Box b; public BoxInState(Box b, Field f) { super(); this.b = b; this.f = f; } }
02285-ai-final
trunk/AI project/src/datastructures/BoxInState.java
Java
oos
233
package datastructures; import LevelObjects.Field; public abstract class ObjectInState implements Comparable<ObjectInState> { public Field f; @Override public int compareTo(ObjectInState o) { if (this.f.x != o.f.y) { return this.f.x-o.f.x; } else{ return this.f.y-o.f.y; } } }
02285-ai-final
trunk/AI project/src/datastructures/ObjectInState.java
Java
oos
307
package datastructures; import java.util.ArrayList; import LevelObjects.*; public class BoxCost { public Box box; public int cost; public ArrayList<GoalCost> goalCosts; public BoxCost() { goalCosts = new ArrayList<GoalCost>(); } }
02285-ai-final
trunk/AI project/src/datastructures/BoxCost.java
Java
oos
265
package datastructures; import LevelObjects.Field; public class StateGoal { public Field agentToPos; public Field boxToPos; public BoxInState box; public AgentInState agent; public boolean isMoveToBoxGoal; public boolean isClearPathGoal; public int nextGoalIndex; }
02285-ai-final
trunk/AI project/src/datastructures/StateGoal.java
Java
oos
278
package datastructures; import LevelObjects.Field; import client.Command; public class GoalSequenceNode implements Comparable<GoalSequenceNode> { public GoalSequenceNode parent; public Field boxLocation; public Field agentLocation; public Command action; public int timeStep; public int f; public int g; public GoalSequenceNode(Field boxLocation, Field agentLocation, Command action) { super(); this.boxLocation = boxLocation; this.agentLocation = agentLocation; this.action = action; } @Override public int compareTo(GoalSequenceNode arg0) { return this.f - arg0.f; } }
02285-ai-final
trunk/AI project/src/datastructures/GoalSequenceNode.java
Java
oos
603
package datastructures; import LevelObjects.*; public class GoalCost { public GoalCost(Goal goal, int cost) { this.cost = cost; this.goal = goal; } public Goal goal; public int cost; }
02285-ai-final
trunk/AI project/src/datastructures/GoalCost.java
Java
oos
212
package utils; public class Timer { private long _time; public volatile long time; public Timer() { time = 0; _time = System.currentTimeMillis(); } public void takeTime() { time = 0; _time = System.currentTimeMillis(); } public long stop() { time = System.currentTimeMillis() - _time; return time; } public int getElapsedTime() { return (int)(System.currentTimeMillis() - _time); } public void reset() { _time = System.currentTimeMillis(); time = 0; } public String toString() { int elapsed = getElapsedTime(); if (elapsed < 1000) return Integer.toString(elapsed) + " miliseconds"; else if (elapsed < 60000) { int seconds = elapsed/1000; int milis = (int)(elapsed % ((int)(elapsed/1000)*1000)); return Integer.toString(seconds) + "." + Integer.toString(milis) + " seconds"; } else { int minutes = elapsed/60000; int seconds = (int)((((double)elapsed)/60000.0f) % (int)(elapsed/60000)); return Integer.toString(minutes) + " minutes " + Integer.toString(seconds) + " seconds"; } } }
02285-ai-final
trunk/AI project/src/utils/Timer.java
Java
oos
1,119
package utils; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Queue; import LevelObjects.Field; public class BFS { public enum NodeColour { WHITE, GRAY, BLACK } private static class Node { int data; int distance; Field field; public Node(int data) { this.data = data; } public String toString() { return "(" + data + ",d=" + distance + ")"; } } Map<Node, List<Node>> nodes; private BFS() { nodes = new HashMap<Node, List<Node>>(); } public static int bfs(Field start_field, Field end_field) { ArrayList<String> fieldList = new ArrayList<String>(); Node start = new Node(0); start.distance = 0; start.field = start_field; fieldList.add(start.field.toString()); Queue<Node> q = new ArrayDeque<Node>(); q.add(start); while (!q.isEmpty()) { Node u = q.remove(); List<Node> adjacent_u = new ArrayList<Node>(); adjacent_u = getNeighbours(u, fieldList); if (adjacent_u != null) { for (Node v : adjacent_u) { if(v.field.x == end_field.x && v.field.y == end_field.y){ return u.distance + 1; } v.distance = u.distance + 1; q.add(v); // System.err.println("Field " + v.field + " added to path"); fieldList.add(v.field.toString()); } } } return -1; } public static int bfs(Field start_field, Field end_field, Field blocked_field) { ArrayList<String> fieldList = new ArrayList<String>(); Node start = new Node(0); Node blocked = new Node(0); start.distance = 0; start.field = start_field; blocked.field = blocked_field; fieldList.add(start.field.toString()); fieldList.add(blocked.field.toString()); Queue<Node> q = new ArrayDeque<Node>(); q.add(start); while (!q.isEmpty()) { Node u = q.remove(); List<Node> adjacent_u = new ArrayList<Node>(); adjacent_u = getNeighbours(u, fieldList); if (adjacent_u != null) { for (Node v : adjacent_u) { if(v.field.x == end_field.x && v.field.y == end_field.y){ return u.distance + 1; } v.distance = u.distance + 1; q.add(v); // System.err.println("Path found. Field " + v.field + " added to path"); fieldList.add(v.field.toString()); } } } return -1; } private static List<Node> getNeighbours(Node u, ArrayList<String> fieldList){ List<Node> adjacent_u = new ArrayList<Node>(); Node n = null; for (int i = 0; i < 4; i++) { if(u.field.neighbours[i] != null){ Field f = u.field.neighbours[i]; if(!fieldList.contains(f.toString())){ n = new Node(i); n.field = u.field.neighbours[i]; adjacent_u.add(n); } } } return adjacent_u; } }
02285-ai-final
trunk/AI project/src/utils/BFS.java
Java
oos
3,589
package utils; import java.util.ArrayList; import java.util.List; import LevelObjects.Agent; import LevelObjects.Box; import LevelObjects.Field; import LevelObjects.Goal; import LevelObjects.Level; public class GoalPriority { /** * Goal prioritization. Checks to see for every goal, how many boxes and goals are disconnected, by placing this goal. * This function can be used at any time. * @param level * @param ignore_goals_completed, if you want to ignore completed goals. * @return a Goal array with the prioritized number in goal.getPriority() */ public static ArrayList<Goal> createGoalPrioritization(Level level, boolean ignore_goals_completed){ // tester(level); Timer t1 = new Timer(); t1.takeTime(); for (Goal goal : level.goals) { //ignore completed goals.. boolean ignore_goal = false; //only enter if completed goals should be ignored if(ignore_goals_completed){ ignore_goal = checkToSeeIfGoalIsOnBox(goal, level); } Timer t2 = new Timer(); t2.takeTime(); if(!(ignore_goal && ignore_goals_completed)){ //first look at fields north and south || east and west are walls or other blocking elements? goals? goals later //If so level has been disconnected //look and see if the disconnect is a problem. int count_free_neighbours = countAdjacentFields(goal); // System.err.println("Goal " + goal.getId() + " has adjacent free fields: " + count_free_neighbours); if(count_free_neighbours == 1){ //Goal only has one Neighbour and should have a low value in goal priority //Know further tests. This is highest priority! } else { List<Field> free_neighbours = getFreeNeighbours(goal); int disconnected_goals = 0; switch(count_free_neighbours){ case 2: goal.setPriority(goal.getPriority() + 1); //Goal only has two Neighbours and has a high posibility of breaking the map into to areas when box on goal //See if path it is possible to get from one neighbour to the other disconnected_goals = getDisconnectedGoalsFromBoxes(free_neighbours.get(0).getClone(), free_neighbours.get(1).getClone(), level, goal); goal.setPriority(goal.getPriority() + disconnected_goals); break; case 3: goal.setPriority(goal.getPriority() + 2); //See if path it is possible to get from one neighbour to the other. There are now 3 neighbours. 0,1,2 disconnected_goals = getDisconnectedGoalsFromBoxes(free_neighbours.get(0).getClone(), free_neighbours.get(1).getClone(), level, goal); disconnected_goals += getDisconnectedGoalsFromBoxes(free_neighbours.get(1).getClone(), free_neighbours.get(2).getClone(), level, goal); disconnected_goals += getDisconnectedGoalsFromBoxes(free_neighbours.get(0).getClone(), free_neighbours.get(2).getClone(), level, goal); goal.setPriority(goal.getPriority() + disconnected_goals); break; case 4: goal.setPriority(goal.getPriority() + 3); //See if path it is possible to get from one neighbour to the other. There are now 4 neighbours. 0,1,2,3 disconnected_goals = getDisconnectedGoalsFromBoxes(free_neighbours.get(0).getClone(), free_neighbours.get(1).getClone(), level, goal); disconnected_goals += getDisconnectedGoalsFromBoxes(free_neighbours.get(0).getClone(), free_neighbours.get(2).getClone(), level, goal); disconnected_goals += getDisconnectedGoalsFromBoxes(free_neighbours.get(0).getClone(), free_neighbours.get(3).getClone(), level, goal); disconnected_goals += getDisconnectedGoalsFromBoxes(free_neighbours.get(1).getClone(), free_neighbours.get(0).getClone(), level, goal); disconnected_goals += getDisconnectedGoalsFromBoxes(free_neighbours.get(1).getClone(), free_neighbours.get(2).getClone(), level, goal); disconnected_goals += getDisconnectedGoalsFromBoxes(free_neighbours.get(1).getClone(), free_neighbours.get(3).getClone(), level, goal); disconnected_goals += getDisconnectedGoalsFromBoxes(free_neighbours.get(2).getClone(), free_neighbours.get(0).getClone(), level, goal); disconnected_goals += getDisconnectedGoalsFromBoxes(free_neighbours.get(2).getClone(), free_neighbours.get(1).getClone(), level, goal); disconnected_goals += getDisconnectedGoalsFromBoxes(free_neighbours.get(2).getClone(), free_neighbours.get(3).getClone(), level, goal); goal.setPriority(goal.getPriority() + disconnected_goals); break; } } } t2.stop(); // System.err.println("Goal " + goal.getId() +" prioritized.. Time taken: " + t2.toString()); } t1.stop(); // System.err.println("Goals prioritized. Time taken: " + t1.toString()); return level.goals; } private static void tester(Level level){ System.err.println("----------TESTER-----------"); Agent agent = level.agents.get(0); System.err.println("----------testing distance-----------"); for (Goal goal : level.goals) { System.err.println("Agent " + agent.getId() + " is " + BFS.bfs(agent.getAtField(), goal.getClone()) + " from goal " + goal.getId()); } System.err.println("----------TESTER-----------"); Field f = new Field(6,3); for (Goal goal : level.goals) { System.err.println("Agent " + agent.getId() + " at " + agent.getAtField() + " is " + BFS.bfs(agent.getAtField(), goal.getClone(), f) + " from goal " + goal.getId() + " at " + goal.getClone() + ". Field " + f + " is blocked"); } System.err.println("---------------------"); } private static int countGoalDisconnectedFromBox(List<Box> boxes, List<Goal> goals, Goal current_goal){ int goals_disconnecting = 0; boolean box_found = false; for (Goal goal : goals) { if(goal != current_goal){ box_found = false; for (Box box : boxes) { if(box.getId() == goal.getId()){ if(BFS.bfs(box.getAtField(), goal.getClone(), current_goal.getClone()) != -1){ box_found = true; } } } if(!box_found){ goals_disconnecting++; } } } return goals_disconnecting; } // private static Goal isAgentDisconnectedFromGoal(Agent agent, List<Goal> goals, Goal current_goal){ // for (Goal goal : goals) { // if(goal != current_goal){ // if(BFS.bfs(agent.getAtField(), goal.getClone(), current_goal.getClone()) == -1){ // return goal; // } // } // } // return null; // } private static List<Field> getFreeNeighbours(Goal goal){ List<Field> free_neighbours = new ArrayList<Field>(); for (int i = 0; i < 4; i++) { if(goal.neighbours[i] != null) free_neighbours.add(goal.neighbours[i]); } return free_neighbours; } private static int countAdjacentFields(Goal goal){ int counter = 0; for (int i = 0; i < 4; i++) { if(goal.neighbours[i] != null) counter++; } return counter; } private static boolean checkToSeeIfGoalIsOnBox(Goal goal, Level level){ boolean ignoreGoal =false; for (Box box : level.boxes) { if(goal.getId() == box.getId()){ if(goal.x == box.getAtField().x && goal.y == box.getAtField().y){ ignoreGoal = true; } } } return ignoreGoal; } private static int getDisconnectedGoalsFromBoxes(Field free_neighbours1, Field free_neighbours2, Level level, Goal goal){ int disconnected_goals = 0; //See if the two neighbours 1 and 2 are disconnected with the middle field blocked. if(BFS.bfs(free_neighbours1, free_neighbours2, goal.getClone()) == -1){ //Okay, there is a disconnect.Now count goals disconnected from boxes with the same id. disconnected_goals = countGoalDisconnectedFromBox(level.boxes, level.goals, goal); goal.setPriority(goal.getPriority() + disconnected_goals); } return disconnected_goals; } /** * Finds the goal with the highest priority for the given agent * @param agent: we want to find best goal for * @param level: containing level.goals to search through * @returns Goal goal with the highest priority */ public static Goal FindGoalWithHighestPriority(Agent agent, Box box, Level level, ArrayList<Goal> goals_assigned) { char id = box.getId(); Goal candidate = null; for (Goal goal : level.goals) { if(!goals_assigned.contains(goal)){ if(goal.getId() == id){ if(candidate != null){ if(candidate.getPriority() > goal.getPriority()) candidate = goal; } else{ candidate = goal; } } } } return candidate; } // public static Goal FindGoalWithHighestPriority(Agent agent, Level level) { // //// for (Box box : level.boxes) { //// if (agent.possibleBoxesToGoals.containsKey(box) && Utils.boxFitsGoal(box, g)){ //// } // // // // char id = box.getId(); // Utils.findPossibleBoxes(level, agent); // // Goal candidate = null; // // for (Goal goal : level.goals) { // if(goal.getId() == id){ // if(candidate != null){ // if(candidate.getPriority() > goal.getPriority()) // candidate = goal; // } // else{ // candidate = goal; // } // } // } // // // // return candidate; // } }
02285-ai-final
trunk/AI project/src/utils/GoalPriority.java
Java
oos
9,333
package utils; import constants.Constants.dir; import LevelObjects.Field; import client.Command; public class AStarField implements Comparable<AStarField> { public Field field; public int g; public int f; public int h; public Command c; public int timeStep; public AStarField(Field field) { this.field = field; } @Override public int compareTo(AStarField o) { return this.f - o.f; } public Field neighborTo(dir d) { return field.neighbours[d.ordinal()]; } }
02285-ai-final
trunk/AI project/src/utils/AStarField.java
Java
oos
526
package utils; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.PriorityQueue; import java.util.Set; import constants.Constants; import constants.Constants.Color; import constants.Constants.dir; import LevelObjects.Agent; import LevelObjects.Box; import LevelObjects.Field; import LevelObjects.Goal; import LevelObjects.Level; import client.Command; import datastructures.BoxCost; import datastructures.BoxInState; import datastructures.GoalActionSequence; import datastructures.GoalCost; import datastructures.GoalSequenceNode; import datastructures.MoveActionSequence; import datastructures.MoveBoxActionSequence; import datastructures.State; public class Utils { /** * * @param f The field * @param d The direction * @return true if the neighboring field in the direction is free */ public static boolean isNeighborFree(Field f, dir d){ return (f.neighbours[d.ordinal()] != null && f.neighbours[d.ordinal()].object == null); } /** * * @param l The level * @param from The field to travel from * @param to The field to travel to * @param blockedFields A list of fields inaccessible to the agent * @return a list of commands taking the agent from the from-field to the to-field */ public static MoveActionSequence findRoute(Level l, Field from, Field to, Collection<Field> blockedFields) { HashMap<AStarField, AStarField> cameFrom = new HashMap<AStarField, AStarField>(); PriorityQueue<AStarField> openSet = new PriorityQueue<AStarField>(); Set<Field> closedSet = new HashSet<Field>(); AStarField start = new AStarField(from); start.g = 0; start.f = start.g + heuristicEstimate(start.field, to, HeuristicType.MANHATTAN); openSet.add(start); AStarField curField = openSet.poll(); while (curField != null) { if (curField.field.equals(to)) break; closedSet.add(curField.field); int tentativeGScore = curField.g + 1; for (dir d : dir.values()) { Field neighbor = curField.neighborTo(d); if(blockedFields != null){ if ( neighbor == null || blockedFields.contains(neighbor) || closedSet.contains(neighbor)) continue; } else{ if ( neighbor == null || closedSet.contains(neighbor)) continue; } AStarField neighbourInOpenSet = null; for (AStarField aOpen : openSet) { if (aOpen.field == neighbor) neighbourInOpenSet = aOpen; } if (neighbourInOpenSet != null && tentativeGScore > neighbourInOpenSet.g) { continue; } else if (neighbourInOpenSet == null ){ neighbourInOpenSet = new AStarField(curField.neighborTo(d)); neighbourInOpenSet.g = tentativeGScore; neighbourInOpenSet.f = neighbourInOpenSet.g + heuristicEstimate(neighbourInOpenSet.field, to, HeuristicType.MANHATTAN); neighbourInOpenSet.c = new Command(d); cameFrom.put(neighbourInOpenSet, curField); openSet.add(neighbourInOpenSet); } } curField = openSet.poll(); } //If currentField is null, we didn't find a path. if (curField == null) return null; ArrayList<Command> commands = new ArrayList<Command>(); ArrayList<Field> fields = new ArrayList<Field>(); while (cameFrom.get(curField) != null) { fields.add(curField.field); commands.add(curField.c); curField = cameFrom.get(curField); } Collections.reverse(commands); Collections.reverse(fields); MoveActionSequence mas = new MoveActionSequence(from, to, commands); mas.fields = fields; return mas; } /** * * @param l The level * @param from The field to travel from * @param to The field to travel to * @param blockedFields A list of fields inaccessible to the agent * @return a list of commands taking the agent from the from-field to the to-field */ public static MoveActionSequence findRouteIgnoreObstacles(Level l, Agent agent, Field from, Field to, Collection<Field> blockedFields) { HashMap<AStarField, AStarField> cameFrom = new HashMap<AStarField, AStarField>(); HashSet<Field> ownBoxFields = new HashSet<Field>(); HashSet<Field> othersBoxFields = new HashSet<Field>(); for (Box b : l.boxes) { if (agent.getColor().equals(b.getColor())) ownBoxFields.add(b.getAtField()); else othersBoxFields.add(b.getAtField()); } PriorityQueue<AStarField> openSet = new PriorityQueue<AStarField>(); Set<Field> closedSet = new HashSet<Field>(); AStarField start = new AStarField(from); start.g = 0; start.f = start.g + heuristicEstimate(start.field, to, HeuristicType.MANHATTAN); openSet.add(start); AStarField curField = openSet.poll(); while (curField != null) { if (curField.field.equals(to)) break; closedSet.add(curField.field); int tentativeGScore = curField.g + 1; for (dir d : dir.values()) { Field neighbor = curField.neighborTo(d); if ( neighbor == null || (blockedFields != null && blockedFields.contains(neighbor)) || closedSet.contains(neighbor)) continue; AStarField neighbourInOpenSet = null; for (AStarField aOpen : openSet) { if (aOpen.field == neighbor) neighbourInOpenSet = aOpen; } if (neighbourInOpenSet != null) continue; neighbourInOpenSet = new AStarField(curField.neighborTo(d)); neighbourInOpenSet.g = tentativeGScore; if (ownBoxFields.contains(curField.field)) neighbourInOpenSet.g = tentativeGScore+50; else if (othersBoxFields.contains(curField.field)) neighbourInOpenSet.g = tentativeGScore+200; neighbourInOpenSet.f = neighbourInOpenSet.g + heuristicEstimate(neighbourInOpenSet.field, to, HeuristicType.MANHATTAN); neighbourInOpenSet.c = new Command(d); cameFrom.put(neighbourInOpenSet, curField); openSet.add(neighbourInOpenSet); } curField = openSet.poll(); } //If currentField is null, we didn't find a path. if (curField == null) return null; ArrayList<Command> commands = new ArrayList<Command>(); ArrayList<Field> fields = new ArrayList<Field>(); while (cameFrom.get(curField) != null) { fields.add(curField.field); commands.add(curField.c); //if (ownBoxFields.contains(curField.f)) curField = cameFrom.get(curField); } Collections.reverse(commands); Collections.reverse(fields); MoveActionSequence mas = new MoveActionSequence(from, to, commands); mas.fields = fields; return mas; } /** * * @param l The level * @param from The field to start from * @param to The field to get to * @return */ public static MoveActionSequence findRoute(Level l, Field from, Field to) { return findRoute(l, from, to, null); } public enum HeuristicType { EUCLID, MANHATTAN } public static int heuristicEstimate(Field a, Field goal, HeuristicType h) { switch (h) { case EUCLID: return heuristicEstimateEuclid(a, goal); case MANHATTAN: return heuristicEstimateManhattan(a, goal); default: return heuristicEstimateManhattan(a, goal); } } public static int heuristicEstimateEuclid(Field a, Field goal) { int h = (int) Math.sqrt(Math.pow(Math.abs(a.x - goal.x), 2) + Math.pow(Math.abs(a.y - goal.y), 2)); return h; } // Manhattan distance public static int heuristicEstimateManhattan(Field a, Field goal) { return Math.abs(a.x - goal.x) + Math.abs(a.y - goal.y); } public static boolean allGoalsHasBoxes(Level level) { int goalsFulfilled = 0; int totalGoals = level.goals.size(); for (Goal goal : level.goals) { for (Box box : level.boxes) { if (box.getAtField() == new Field(goal.x,goal.y) && Character.toLowerCase(box.getId()) == goal.getId()) { goalsFulfilled++; } } } if(goalsFulfilled == totalGoals) return true; else return false; } /** * checks if all goals has been fulfilled for the given agent * @param agent * @param level * @returns null if all goals are fulfilled, otherwise the goal with the highest priority */ public static Goal allOfAgentGoalsHasBoxes(Agent agent, Level level) { // Box current_box_color = a.possibleBoxesToGoals.keySet() int goalsFulfilled = 0; int totalBoxes = 0; Goal highestPriority = null; for (Goal goal : level.goals) { for (Box box : level.boxes) { if (agent.possibleBoxesToGoals.containsKey(box) && Utils.boxFitsGoal(box, goal)){ totalBoxes++; if (box.getAtField() == new Field(goal.x,goal.y) && Character.toLowerCase(box.getId()) == goal.getId()) { goalsFulfilled++; } else { if(highestPriority != null){ if(highestPriority.getPriority() > goal.getPriority()) highestPriority = goal; } else{ highestPriority = goal; } } } } } if(goalsFulfilled <= totalBoxes) return null; return highestPriority; } public static boolean GoalHasBox(Goal goal, Level level){ for (Box box : level.boxes) { if(boxFitsGoal(box, goal) && box.getAtField() == new Field(goal.x,goal.y)){ return true; } } return false; } public static MoveBoxActionSequence findEmptyFieldRoute(Level l, Agent a, Box b, Field freeField, Field agentFromField, Field agentToField, Field boxFromField, Collection<Field> blockedFields) { GoalActionSequence ga = findGoalRoute(l, a, b, agentFromField, agentToField, boxFromField, freeField, blockedFields); if (ga == null) return null; MoveBoxActionSequence mb = new MoveBoxActionSequence(); mb.setAgentLocation(ga.getAgentStartLocation()); mb.setBoxLocation(ga.getBoxStartLocation()); mb.setCommands(ga.getCommands()); mb.setTargetLocation(ga.getBoxEndLocation()); return mb; } public static Field getFreeField(Level l, Agent a, Box b, Field agentFromField, Field boxFromField, Collection<Field> blockedFields, int maxDepth, boolean includeGoalFields) { LinkedList<Field> openSet = new LinkedList<Field>(); HashSet<Field> closedSet = new HashSet<Field>(); Field current = boxFromField; Field candidate = current; int depth = 0; while (current != null && depth <= maxDepth) { candidate = current; closedSet.add(current); for (dir d : dir.values()) { Field neighbor = current.neighborTo(d); if ( neighbor != null && !blockedFields.contains(neighbor) && !closedSet.contains(neighbor) && (neighbor instanceof Goal && includeGoalFields)) openSet.add(neighbor); } current = openSet.poll(); } return candidate; } public static List<Field> getFreeFields(Field boxFromField, Collection<Field> blockedFields, int maxDepth, int maxReturnedFields, boolean includeGoalFields) { List<Field> l = getFreeFields(boxFromField, blockedFields, maxDepth, includeGoalFields); if (l.size()>maxReturnedFields) return l.subList(0, maxReturnedFields-1); return l; } public static ArrayList<Field> getFreeFields(Field boxFromField, Collection<Field> blockedFields, int maxDepth, boolean includeGoalFields) { LinkedList<Field> openSet = new LinkedList<Field>(); HashSet<Field> closedSet = new HashSet<Field>(); Field current = boxFromField; ArrayList<Field> candidates = new ArrayList<Field>(); candidates.add(current); int depth = 0; while (current != null && depth <= maxDepth) { closedSet.add(current); int count = 0; for (dir d : dir.values()) { Field neighbor = current.neighborTo(d); if ( neighbor != null && !blockedFields.contains(neighbor) && !closedSet.contains(neighbor) && (neighbor instanceof Goal && includeGoalFields)) { count++; openSet.add(neighbor); } } if (count==0) // a dead end is good! candidates.add(current); current = openSet.poll(); } return candidates; } public static Field getFirstFreeField(Field fromField, Collection<Field> escapeFromFields, Collection<Field> blockedFields, int maxDepth, boolean includeGoalFields) { LinkedList<Field> openSet = new LinkedList<Field>(); HashSet<Field> closedSet = new HashSet<Field>(); if (!escapeFromFields.contains(fromField)) escapeFromFields.add(fromField); Field current = fromField; int depth = 0; whileloop: while (current != null && depth <= maxDepth) { closedSet.add(current); for (dir d : dir.values()) { Field neighbor = current.neighborTo(d); if (neighbor == null) continue; if (!escapeFromFields.contains(neighbor)) { current = neighbor; break whileloop; } if ( escapeFromFields.contains(neighbor) && !closedSet.contains(neighbor) && !blockedFields.contains(neighbor) && (!(neighbor instanceof Goal) || includeGoalFields)) { openSet.add(neighbor); } } current = openSet.poll(); } return current; } public static Field getNthFreeField(Field fromField, Collection<Field> escapeFromFields, Collection<Field> blockedFields, int minDepth, int maxDepth, boolean includeGoalFields) { LinkedList<Field> openSet = new LinkedList<Field>(); HashSet<Field> closedSet = new HashSet<Field>(); if (!escapeFromFields.contains(fromField)) escapeFromFields.add(fromField); Field current = fromField; int depth = 0; whileloop: while (current != null && depth <= maxDepth) { closedSet.add(current); for (dir d : dir.values()) { Field neighbor = current.neighborTo(d); if (neighbor == null) continue; if(minDepth == 0 && !escapeFromFields.contains(current)){ break whileloop; } if (!escapeFromFields.contains(neighbor) && !closedSet.contains(neighbor) && !blockedFields.contains(neighbor)) { minDepth--; // current = neighbor; openSet.add(neighbor); } if ( escapeFromFields.contains(neighbor) && !closedSet.contains(neighbor) && !blockedFields.contains(neighbor) && (!(neighbor instanceof Goal) || includeGoalFields)) { openSet.add(neighbor); } } current = openSet.poll(); } return current; } // We know that the agent a has a box. Now we want to move the box to the // goal. public static GoalActionSequence findGoalRoute(Level l, Agent a, Box b, Field agentFromField, Field agentToField, Field boxFromField, Field boxToField, Collection<Field> blockedFields) { dir boxDir = null; GoalSequenceNode root = new GoalSequenceNode(boxFromField, agentFromField, null); PriorityQueue<GoalSequenceNode> queue = new PriorityQueue<GoalSequenceNode>(); // prune looped states (if agent and box ends up in a state already explored) HashMap<Field, ArrayList<Field>> closedSet = new HashMap<Field, ArrayList<Field>>(); //adding initial state to list set of explored states: ArrayList<Field> tempList = new ArrayList<Field>(); tempList.add(boxFromField); closedSet.put(agentFromField, tempList); int g = 0; root.g = g; root.f = root.g + heuristicEstimateManhattan(boxFromField, boxToField); //Add a closed set. queue.add(root); GoalSequenceNode currentNode = queue.poll(); while (currentNode != null && (currentNode.boxLocation != boxToField || currentNode.agentLocation != agentToField)) { boxDir = Agent.getBoxDirection(currentNode.agentLocation,currentNode.boxLocation); ArrayList<Command> foundCommands = addPossibleBoxCommandsForDirection(boxDir, currentNode.agentLocation, currentNode.boxLocation, blockedFields); for (Command command : foundCommands) { Field boxLocation = null; Field agentLocation = null; if (command.cmd.equals("Push")) { agentLocation = currentNode.boxLocation; boxLocation = currentNode.boxLocation.neighbours[command.dir2 .ordinal()]; } else { boxLocation = currentNode.agentLocation; agentLocation = currentNode.agentLocation.neighbours[command.dir1 .ordinal()]; } // Do we already have a way to get to this state? if (closedSet.containsKey(agentLocation)) { if (closedSet.get(agentLocation).contains(boxLocation)) continue; else // the agent has been here before but without the box in same location closedSet.get(agentLocation).add(boxLocation); } else { // neither the agent or the box has been here before. Update DS and create node in BTtree: ArrayList<Field> tempListe = new ArrayList<Field>(); tempListe.add(boxLocation); closedSet.put(agentLocation, tempListe); } GoalSequenceNode node = new GoalSequenceNode(boxLocation,agentLocation, command); node.parent = currentNode; node.g = node.parent.g+1; node.f = node.g + heuristicEstimateManhattan(boxLocation, boxToField); queue.add(node); } if (queue.isEmpty()) { //TODO: we have searched to the end without finding a solution. Move boxes to get access to goals return null; } currentNode = queue.poll(); } GoalActionSequence returnSequence = new GoalActionSequence(); returnSequence.setAgentStartLocation(currentNode.agentLocation); returnSequence.setBoxStartLocation(currentNode.boxLocation); ArrayList<Command> commands = new ArrayList<Command>(); while (currentNode.parent != null) { commands.add(currentNode.action); currentNode = currentNode.parent; } Collections.reverse(commands); returnSequence.setCommands(commands); return returnSequence; } public static ArrayList<Command> addPossibleBoxCommandsForDirection(dir direction, Field agentLocationInPlan, Field boxLocationInPlan, Collection<Field> blockedFields) { ArrayList<Command> possibleCommands = new ArrayList<Command>(); // Find possible pull commands for (dir d : dir.values()) { // we cannot pull a box forward in the box's direction if (d != direction && agentLocationInPlan.neighbours[d.ordinal()] != null && !blockedFields.contains(agentLocationInPlan.neighbours[d.ordinal()])) { possibleCommands.add(new Command("Pull", d, direction)); } } // Find possible push commands for (dir d : dir.values()) { // We cannot push a box backwards in the agents direction if (d != Constants.oppositeDir(direction) && boxLocationInPlan.neighbours[d.ordinal()] != null && !blockedFields.contains(boxLocationInPlan.neighbours[d.ordinal()])) { possibleCommands.add(new Command("Push", direction, d)); } } return possibleCommands; } public static boolean boxFitsGoal(Box b, Goal g){ return (g.getId() == Character.toLowerCase(b.getId())); } public static ArrayList<Box> getBoxesWithId(ArrayList<Box> boxes, char id) { ArrayList<Box> boxesWithId = new ArrayList<Box>(); for (Box b : boxes) if (b.getId() == id) boxesWithId.add(b); return boxesWithId; } public static ArrayList<Agent> getAgents( ArrayList<Agent> agents, Color color) { ArrayList<Agent> returnAgents = new ArrayList<Agent>(); for (Agent agent : agents) { if (agent.getColor() == color) { returnAgents.add(agent); } } return returnAgents; } public static boolean isFieldAvailable(Field f, ArrayList<Field> blockedFields) { for (Field field : blockedFields) { if (field == f) return false; } return true; } public static ArrayList<Box> getBoxesInLevel(ArrayList<Box> boxes, char id) { ArrayList<Box> boxesWithId = new ArrayList<Box>(); for (Box b : boxes) if (b.getId() == id) boxesWithId.add(b); return boxesWithId; } public static ArrayList<Field> findFreeField(Level level, ArrayList<Field> fields) { ArrayList<Field> returnFields = new ArrayList<Field>(); for (Field field : level.fields) { if(!fields.contains(field)) returnFields.add(field); } return returnFields; } public static ArrayList<Box> getBoxesWithColor(ArrayList<Box> boxes, Color color) { ArrayList<Box> returnBoxes = new ArrayList<Box>(); for (Box box : boxes) { if (box.getColor() == color) { returnBoxes.add(box); } } return returnBoxes; } public static ArrayList<Goal> getGoalsWithId(ArrayList<Goal> goals, char id) { ArrayList<Goal> returnGoals = new ArrayList<Goal>(); for (Goal goal : goals) { if (goal.getId() == id) { returnGoals.add(goal); } } return returnGoals; } /** * Calculates an a* like heuristic considering the traveled distance and the goal count * @param state * @param level * @return */ public static int CalculateStateHeuristic(State state, Level level) { int goalCountWeight = 5; int gScoreWeight = 1; int numberOfFulfilledGoals = 0; for (Goal g : level.goals) { for (BoxInState bPos : state.boxes) { if ( bPos.f == g && Character.toLowerCase(bPos.b.getId()) == g.getId()) { numberOfFulfilledGoals++; } } } int gScore = 0; // the g score is the cost of travelling here in terms of actionSequences (NOT actions) State parent = state; while(parent != null) { parent = parent.parent; gScore++; } return 1000 - (goalCountWeight*numberOfFulfilledGoals - gScoreWeight * gScore); } // public static BoxInState findBoxInCompletedState(State currentState, Box box) { // // BoxInState boxInState = currentState.goal.box; // // for (BoxInState b : currentState.boxes) { // if (b.b == boxInState.b && box == b.b) { // return new BoxInState(box, currentState.goal.boxToPos); // } else if (b.b == box) { // return b; // } // } // // return null; // } /** * Testing to if an agent can reach its boxes * @param level * @param agent * @param boxes * @return BoxInState it can reach */ public static HashMap<Box, BoxCost> findPossibleBoxes(Level level, Agent agent){ HashMap<Box, BoxCost> possibleBoxes = new HashMap<Box, BoxCost>(); for (Box box : level.boxes) { if(agent.getColor() == box.getColor()) { int cost = Utils.findRouteCostIgnoreBoxes(level, agent, agent.getAtField(), box.getAtField(), null); if (cost==-1) continue; if (possibleBoxes.containsKey(box)) { BoxCost bc = possibleBoxes.get(box); bc.box = box; bc.cost = cost; } else { BoxCost bc = new BoxCost(); bc.box = box; bc.cost = cost; possibleBoxes.put(box, bc); } } } if(possibleBoxes.isEmpty()) return possibleBoxes; for (Box box : possibleBoxes.keySet()) { for (Goal goal : level.goals) { if(!boxFitsGoal(box, goal)) continue; int cost = findRouteCostIgnoreBoxes(level, agent, box.getAtField(), (Field)goal, null)-50; //the box itself costs 50 if (cost==-1) continue; possibleBoxes.get(box).goalCosts.add(new GoalCost(goal, cost)); } } return possibleBoxes; } /** * * @param l The level * @param from The field to travel from * @param to The field to travel to * @param blockedFields A list of fields inaccessible to the agent * @return The cost of getting to the field. -1 if no route */ public static int findRouteCostIgnoreBoxes(Level l, Agent a, Field from, Field to, Collection<Field> blockedFields) { int cost = -1; HashMap<AStarField, AStarField> cameFrom = new HashMap<AStarField, AStarField>(); PriorityQueue<AStarField> openSet = new PriorityQueue<AStarField>(); HashSet<AStarField> openSetCopy = new HashSet<AStarField>(); Set<Field> closedSet = new HashSet<Field>(); HashSet<Field> ownBoxFields = new HashSet<Field>(); HashSet<Field> othersBoxFields = new HashSet<Field>(); for (Box b : l.boxes) { if (a.getColor().equals(b.getColor())) ownBoxFields.add(b.getAtField()); else othersBoxFields.add(b.getAtField()); } AStarField start = new AStarField(from); start.g = 0; start.f = start.g + heuristicEstimate(start.field, to, HeuristicType.MANHATTAN); openSet.add(start); openSetCopy.add(start); AStarField curField; while (true) { curField = openSet.poll(); // Are we there yet? if (curField.field.equals(to) || curField == null) break; openSetCopy.remove(curField); closedSet.add(curField.field); int gScore = curField.g + 1; for (dir d : dir.values()) { Field neighbor = curField.neighborTo(d); if (neighbor == null || (blockedFields != null && blockedFields.contains(neighbor)) || closedSet.contains(neighbor)) continue; // Is the neighbor already in the open set? As of uniform cost it can not be possible to find a faster route to it if (openSetCopy.contains(neighbor)) continue; // AStarField neighbourInOpenSet = null; // At some point test if it is faster to use this approach in stead of double openSet. // for (AStarField aOpen : openSet) { // if (aOpen.field == neighbor) continue; // } AStarField neighbourField = new AStarField(curField.neighborTo(d)); neighbourField.g = gScore; if (ownBoxFields.contains(curField.field)) neighbourField.g = gScore+50; else if (othersBoxFields.contains(curField.field)) neighbourField.g = gScore+200; neighbourField.f = neighbourField.g + heuristicEstimate(neighbourField.field, to, HeuristicType.MANHATTAN); neighbourField.c = new Command(d); cameFrom.put(neighbourField, curField); openSet.add(neighbourField); openSetCopy.add(neighbourField); } } if (curField != null) { cost = curField.f; } return cost; } public static ArrayList<Box> findRouteCountBoxesInTheWay(Level l, Agent a, Field from, Field to, Collection<Field> blockedFields) { ArrayList<Box> boxesInTheWay = null; HashMap<AStarField, AStarField> cameFrom = new HashMap<AStarField, AStarField>(); PriorityQueue<AStarField> openSet = new PriorityQueue<AStarField>(); HashSet<AStarField> openSetCopy = new HashSet<AStarField>(); Set<Field> closedSet = new HashSet<Field>(); HashSet<Field> ownBoxFields = new HashSet<Field>(); HashSet<Field> othersBoxFields = new HashSet<Field>(); for (Box b : l.boxes) { if (a.getColor().equals(b.getColor())) ownBoxFields.add(b.getAtField()); else othersBoxFields.add(b.getAtField()); } AStarField start = new AStarField(from); start.g = 0; start.f = start.g + heuristicEstimate(start.field, to, HeuristicType.MANHATTAN); openSet.add(start); openSetCopy.add(start); AStarField curField; boxesInTheWay = new ArrayList<Box>(); while (true) { curField = openSet.poll(); // Are we there yet? if (curField == null || curField.field.equals(to)) break; openSetCopy.remove(curField); closedSet.add(curField.field); int gScore = curField.g + 1; for (dir d : dir.values()) { Field neighbor = curField.neighborTo(d); if (neighbor == null || (blockedFields != null && blockedFields.contains(neighbor)) || closedSet.contains(neighbor)) continue; // Is the neighbor already in the open set? As of uniform cost it can not be possible to find a faster route to it if (openSetCopy.contains(neighbor)) continue; AStarField neighbourField = new AStarField(curField.neighborTo(d)); neighbourField.g = gScore; if (ownBoxFields.contains(curField.field)){ for (Box box : l.boxes) { if(box.getAtField() == curField.field) boxesInTheWay.add(box); } } else if (othersBoxFields.contains(curField.field)){ for (Box box : l.boxes) { if(box.getAtField() == curField.field) boxesInTheWay.add(box); } } neighbourField.f = neighbourField.g + heuristicEstimate(neighbourField.field, to, HeuristicType.MANHATTAN); neighbourField.c = new Command(d); cameFrom.put(neighbourField, curField); openSet.add(neighbourField); openSetCopy.add(neighbourField); } } return boxesInTheWay; } public static List<Field> getEscapeFieldsFromCommands(Agent a, Collection<Command> commandsNotCompleted) { ArrayList<Field> escapeFields = new ArrayList<Field>(); Field current = a.getAtField(); escapeFields.add(current); for (Command c : commandsNotCompleted) { if (c.cmd.equals("Move") || c.cmd.equals("Pull")) { current = current.neighbours[c.dir1.ordinal()]; } else if (c.cmd.equals("Push")) { current = current.neighbours[c.dir1.ordinal()]; } else if(c.cmd.equals("NoOp")){ continue; } if (current == null) continue; escapeFields.add(current); } return escapeFields; } /** * Checks if an agent was at this location last turn. this can happen on FOMA since actions are synchronous * @param level * @param field * @return */ public static boolean CheckIfAnAgentWasOnThisFieldLastTurn(Level level, Field field){ for (Agent agent : level.agents) { if(agent.lastLocation == field) return true; } return false; } public static Box FindBoxForAgent(Agent agent, Level level) { for (Box box : level.boxes) { if(box.getId() == agent.getId()){ return box; } } return null; } public static ArrayList<Box> OwnBoxesInTheWay(Agent agent, ArrayList<Box> boxes) { ArrayList<Box> ownBoxesInTheWay = new ArrayList<Box>(); ArrayList<Box> ownBoxesInTheWayChangeOrder = new ArrayList<Box>(); for (Box box : boxes) { if(box.getColor().equals(agent.getColor())) ownBoxesInTheWay.add(box); else break; } while(!ownBoxesInTheWay.isEmpty()){ ownBoxesInTheWayChangeOrder.add(ownBoxesInTheWay.remove(ownBoxesInTheWay.size()-1)); } return ownBoxesInTheWayChangeOrder; } public static boolean isNeighbor(Field atField, Field atField2) { for (Field nabo : atField.neighbours) { if(nabo != null && nabo.equals(atField2)) return true; } return false; } public static ArrayList<Box> changeOrderInTheArrayList(ArrayList<Box> ownBoxesInTheWay) { ArrayList<Box> tempOwnBoxesInTheWay = new ArrayList<Box>(); while(!ownBoxesInTheWay.isEmpty()){ tempOwnBoxesInTheWay.add(ownBoxesInTheWay.remove(ownBoxesInTheWay.size()-1)); } return tempOwnBoxesInTheWay; } public static Box getClosedBoxForGoal(Goal goal, Level level, HashMap<Box, BoxCost> keySet, ArrayList<Box> ignore_boxes) { Box candidate = null; int cost = 0; BoxCost boxCost; Iterator<Box> keySetIterator = keySet.keySet().iterator(); while(keySetIterator.hasNext()){ Box key = keySetIterator.next(); if(key == null || ignore_boxes.contains(key)) continue; boxCost = keySet.get(key); if(boxCost != null){ if(cost == 0) cost = boxCost.cost; if(boxCost.cost <= cost){ cost = boxCost.cost; candidate = boxCost.box; } } } return candidate; } }
02285-ai-final
trunk/AI project/src/utils/Utils.java
Java
oos
31,722
package utils; import java.util.ArrayList; import LevelObjects.Agent; import LevelObjects.Box; import LevelObjects.Field; import LevelObjects.Level; public class Communication { /** * find agent to move a given box that might be in the way for another agent * @param box * @param level * @return */ public static Agent FindAgentToMoveBox(Box box, Level level){ for (Agent candidate_agent : level.agents) { if(box.getColor() == candidate_agent.getColor()) return candidate_agent; } return null; } public static boolean isObsticalStillInTheWay(Agent agent, Object obstacle, ArrayList<Field> avoidFields){ if(obstacle instanceof Agent){ Agent agent_obstical = (Agent) obstacle; for (Field field : avoidFields) { if(agent_obstical.getAtField().equals(field)) return true; } } else if(obstacle instanceof Box){ Box box_obstical = (Box) obstacle; for (Field field : avoidFields) { if(box_obstical.getAtField().equals(field)) return true; } } return false; } }
02285-ai-final
trunk/AI project/src/utils/Communication.java
Java
oos
1,087
package utils; import java.util.ArrayList; import java.util.Collection; import java.util.List; import constants.Constants.dir; import LevelObjects.Agent; import LevelObjects.Box; import LevelObjects.Field; import LevelObjects.Level; import client.Command; import datastructures.ActionSequence; import datastructures.GoalActionSequence; import datastructures.MoveActionSequence; import datastructures.State; public class Moves { public static List<Field> getEscapeFieldsFromCommands(Agent a, Collection<Command> commandsNotCompleted) { ArrayList<Field> escapeFields = new ArrayList<Field>(); Field current = a.getAtField(); escapeFields.add(current); for (Command c : commandsNotCompleted) { if (c.cmd.equals("Move") || c.cmd.equals("Pull")) { current = current.neighbours[c.dir1.ordinal()]; } else if (c.cmd.equals("Push")) { current = current.neighbours[c.dir2.ordinal()]; } if (current == null) break; escapeFields.add(current); } return escapeFields; } public static void MoveABoxToLocation(Agent agent, Box box, Field newLocation, Level level){ GoalActionSequence routeToGoal; // if this is not possible due to box in the way call: //reinsert the objective ArrayList<Field> blockedFields = new ArrayList<Field>(); blockedFields.add(box.getAtField()); for (Agent tempAgent : level.agents) { if(agent != tempAgent && agent.isNooping) blockedFields.add(agent.getAtField()); } for (Box tempBox : level.boxes) { if(!tempBox.equals(box)) blockedFields.add(tempBox.getAtField()); } State newState = null; boxLoop: for (dir d : dir.values()) { Field neighbor = box.getAtField().neighborTo(d); if(neighbor == null) continue; MoveActionSequence moveAction = Utils.findRouteIgnoreObstacles(level, agent, agent.getAtField(), neighbor, blockedFields); if (moveAction == null) continue; //Here we have decided that we can get to a box. Now we must check if the box can get to a goal. //Because we are now moving the box, it's field is free. blockedFields.remove(box.getAtField()); for (dir goalNeighbourDir : dir.values()) { Field goalNeighbor = newLocation.neighbours[goalNeighbourDir.ordinal()]; if (goalNeighbor == null) continue; routeToGoal = Utils.findGoalRoute(level, agent, box, box.getAtField().neighbours[d.ordinal()], goalNeighbor, box.getAtField(), newLocation, blockedFields); if (routeToGoal != null) { newState = new State(); newState.actionSequencesFromParent.add(moveAction); newState.actionSequencesFromParent.add(routeToGoal); break boxLoop; } } blockedFields.add(box.getAtField()); } for (ActionSequence actionSequence : newState.actionSequencesFromParent) { for (Command command : actionSequence.getCommands()) { agent.commandQueue.add(command); } } } }
02285-ai-final
trunk/AI project/src/utils/Moves.java
Java
oos
3,015
package LevelObjects; import constants.Constants.Color; public class Box implements Comparable<Box> { private char id; // stored as lowercase so we can easily compare with goals private Color color; private Field atField; public Box(char id, Color color, Field atField) { this.id = Character.toLowerCase(id); this.color = color==null ? Color.blue : color; this.atField = atField; } // Getter / Setters public Field getAtField() { return atField; } public void setAtField(Field atField) { this.atField = atField; } public char getId() { return id; } public Color getColor() { return color; } @Override public int compareTo(Box o) { if (this.atField.x != o.atField.y) { return this.atField.x-o.atField.x; } else{ return this.atField.y-o.atField.y; } } }
02285-ai-final
trunk/AI project/src/LevelObjects/Box.java
Java
oos
814
package LevelObjects; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.LinkedList; import java.util.Queue; import java.util.Random; import agent.objectives.*; import agent.planners.AgentPlanner; import utils.Communication; import utils.Moves; import utils.Utils; import constants.Constants; import constants.Constants.Color; import constants.Constants.dir; import client.Command; import client.Desire; import datastructures.*; public class Agent { private static Random rand = new Random(); // del? private char id; public int number; private Color color; private Field atField; public HashMap<Box, BoxCost> possibleBoxesToGoals = new HashMap<Box, BoxCost>(); public Queue<ActionSequence> actions; public LinkedList<Objective> objectives = new LinkedList<Objective>(); public AgentPlanner planner; public boolean isNooping = false; public int priority; public Queue<Command> commandQueue; public Queue<Command> commandsNotCompleted; public Field lastLocation; public Desire desire; public Objective tempObjective; public Object obstacle; public boolean isTheCauseOfAConflict = false; private Conflict conflict; public Agent(char id, Color color, Field atField) { this.id = id; this.color = color==null ? Color.blue : color; this.atField = atField; this.commandQueue = new LinkedList<Command>(); this.commandsNotCompleted = new LinkedList<Command>(); } public Agent(char id, Color color, Field atField, AgentPlanner planner) { this(id, color, atField); this.planner = planner; } /** * Convert objective to commands and fill them in the commandqueue */ public void planAndExecute(Level level) { isNooping = false; Objective temp_o = this.objectives.peek(); if(temp_o instanceof GoalABox){ GoalABox gab = (GoalABox)temp_o; if(gab.goal.hasBox(level)){ this.objectives.remove(); } } // Check if previous action failed if (obstacle != null) { if (obstacle instanceof Agent) { Agent other = (Agent)obstacle; if (this.priority <= other.priority) { other.commandQueue.clear(); ArrayList<Field> list = new ArrayList<Field>(); list.add(this.getAtField()); other.objectives.addFirst(new Move(Utils.getEscapeFieldsFromCommands(this, commandsNotCompleted), list ,50)); other.obstacle = null; Command c; while ((c = commandsNotCompleted.poll()) != null) commandQueue.add(c); this.objectives.removeFirst(); } else this.commandsNotCompleted.clear(); } else if( obstacle instanceof Box) { //A box is in the way. find which box Box otherBox = (Box)obstacle; if(otherBox.getColor() == this.getColor()){ //Agent can move this box himself ArrayList<Field> blockedFields = new ArrayList<Field>(); ArrayList<Box> boxesInTheWay = new ArrayList<Box>(); ArrayList<Box> ownBoxesInTheWay = new ArrayList<Box>(); // getNthFreeField() java.util.List<Field> fieldsToAvoid = Utils.getEscapeFieldsFromCommands(this, commandsNotCompleted); Field field_from = null; Field field_to = null; Objective o = this.objectives.peekFirst(); if(o instanceof GoalABox){ field_from = ((GoalABox) o).box.getAtField(); field_to = new Field(((GoalABox) o).goal.x, ((GoalABox) o).goal.y); } for (Box b : level.boxes) { if(fieldsToAvoid.contains(b.getAtField())){ boxesInTheWay.add(b); } blockedFields.add(b.getAtField()); } ownBoxesInTheWay = Utils.OwnBoxesInTheWay(this, boxesInTheWay); if(Utils.isNeighbor(ownBoxesInTheWay.get(0).getAtField(), this.getAtField())){ //Change order ownBoxesInTheWay = Utils.changeOrderInTheArrayList(ownBoxesInTheWay); } if(ownBoxesInTheWay.size() > 31){ LinkedList<Objective> currentObj = new LinkedList<Objective>(); int currentBoxesInTheWay = boxesInTheWay.size(); LinkedList<Box> currentBox = new LinkedList<Box>(); currentBox.addAll(ownBoxesInTheWay); while(!currentBox.isEmpty()){ Box box = currentBox.poll(); if(box == null) continue; currentBoxesInTheWay--; Objective newObjective = new DockABox(new Field(3, 6), box, fieldsToAvoid, blockedFields, boxesInTheWay.size() - currentBoxesInTheWay, 15); currentObj.addFirst(newObjective); } while(!currentObj.isEmpty()){ Objective objective = currentObj.pollLast(); this.objectives.addFirst(objective); } // for (Box box : ownBoxesInTheWay) { // // Objective newObjective = new DockABox(new Field(3, 6), box, fieldsToAvoid, blockedFields, currentBoxesInTheWay, 15); // // currentObj.addFirst(newObjective); // currentBoxesInTheWay--; // if(currentBoxesInTheWay == 0) // break; // } // for (Objective objective : currentObj) { // this.objectives.addFirst(objective); // } } else { Objective newObjective = new DockABox(new Field(3, 6), otherBox, fieldsToAvoid, blockedFields, boxesInTheWay.size(), 15); this.objectives.addFirst(newObjective); } } else { //Find an agent to move the box Agent otherAgent = Communication.FindAgentToMoveBox(otherBox, level); if (this.id<otherAgent.id || otherAgent.commandQueue.isEmpty()) { ArrayList<Field> fieldsToAvoid = new ArrayList<Field>(); fieldsToAvoid.addAll(Moves.getEscapeFieldsFromCommands(this, commandsNotCompleted)); otherAgent.conflict = new Conflict(this, fieldsToAvoid, obstacle, otherBox, this.priority); } } this.commandsNotCompleted.clear(); } obstacle = null; return; } // if(this.conflict != null && this.conflict.isPriority() < this.id){ //Another agent has a conflict with this agent if(this.conflict != null && this.conflict.isPriority() <= this.priority){ if(this.conflict.getObstacle() instanceof Box) { //A box is in the way. find which box //Agent has to move the box for another agent Box box = this.conflict.getMoveaBox(); //Get to box if(this.objectives.getFirst() instanceof Move){ //Find a route for the agent and the box. this.commandQueue.clear(); ArrayList<Field> candidates = new ArrayList<Field>(); candidates = Utils.getFreeFields(box.getAtField(),this.conflict.getAvoidFields(),15,false); // Queue<Command> commandQueue = null; differentEndLocations: for (Field field : candidates) { Moves.MoveABoxToLocation(this, box, field, level); } } else if(this.objectives.getFirst() instanceof GoalABox){ //Find a route for the agent and the box. this.commandQueue.clear(); ArrayList<Field> blockedFields = new ArrayList<Field>(); blockedFields.add(this.conflict.getHelpAgent().getAtField()); Field candidates; candidates = Utils.getFirstFreeField(box.getAtField(), this.conflict.getAvoidFields(), (Collection<Field>) blockedFields, 25, true); Moves.MoveABoxToLocation(this, box, candidates, level); } else { //Other agent not doing anything - get to the box and move it.. this.commandQueue.clear(); ArrayList<Field> blockedFields = new ArrayList<Field>(); blockedFields.add(this.conflict.getHelpAgent().getAtField()); for (Box current_box : level.boxes) { blockedFields.add(current_box.getAtField()); } Field candidates; this.conflict.avoidFields.addAll(blockedFields); candidates = Utils.getFirstFreeField(box.getAtField(), this.conflict.getAvoidFields(), (Collection<Field>) blockedFields, 25, true); Moves.MoveABoxToLocation(this, box, candidates, level); } } this.conflict = null; } if(!this.commandQueue.isEmpty()){ return; } Objective o = objectives.peek(); if (o==null){ if(!objectives.isEmpty()){ objectives.remove(); } return; } boolean successful = false; if (o instanceof GoalABox) { GoalABox gab = (GoalABox)o; if(Utils.GoalHasBox(gab.goal, level)){ successful = true; } else { successful = planner.goalABox(this, gab.box, gab.goal); } } else if (o instanceof Move) { Move mv = (Move)o; successful = planner.move(this, mv.escapeFromFields, mv.blockedFields, mv.numberOfRounds); } else if (o instanceof DockABox) { DockABox dab = (DockABox)o; successful = planner.dock(this, dab.box, dab.field, dab.fieldsToAvoid , dab.blockedFields, dab.moveTheBoxFieldsFurther, dab.numberOfRounds); } else if (o instanceof Move) { Wait mv = (Wait)o; successful = planner.wait(this, mv.numberOfRounds); } if (successful) this.tempObjective = objectives.removeFirst(); } public Field getAtField() { return atField; } public void setAtField(Field atField) { this.atField = atField; } public char getId() { return id; } public Color getColor() { return color; } // Only used by random walk clients. public Command act() { ArrayList<Command> possibleCommands = new ArrayList<Command>(); for (dir d : dir.values()) { randomWalkAddPossibleCommandsForDirection(d, possibleCommands); } if (possibleCommands.size() == 0) possibleCommands.add(new Command(dir.N)); //Dummy command return possibleCommands.get(rand.nextInt(possibleCommands.size())); } private void randomWalkAddPossibleCommandsForDirection(dir direction, ArrayList<Command> possibleCommands){ if (neighbourFree(this.atField,direction)) { possibleCommands.add(new Command(direction)); } else if (neighbourIsBoxOfSameColor(direction)) { //Find possible pull commands for (dir d : dir.values()) { //we cannot pull a box forward in the box's direction if (d != direction && neighbourFree(this.atField,d)){ possibleCommands.add(new Command("Pull",d,direction)); } } //Find possible push commands for (dir d : dir.values()) { //We cannot push a box backwards in the agents direction if (d != Constants.oppositeDir(direction) && neighbourFree(this.getAtField().neighbours[direction.ordinal()],d)){ possibleCommands.add(new Command("Push",direction,d)); } } } } public ArrayList<Command> addPossibleCommandsForDirection(dir direction, Field agentLocationInPlan, Field boxLocationInPlan) { ArrayList<Command> possibleCommands = new ArrayList<Command>(); /* Commented because we are not interested in move commands at current time. if (neighbourFreeInPlan(agentLocationInPlan, direction, boxLocationInPlan) && this.desire.goal == null) { possibleCommands.add(new Command(direction)); }*/ // Find possible pull commands for (dir d : dir.values()) { // we cannot pull a box forward in the box's direction if (d != direction && neighbourFreeInPlan(agentLocationInPlan, d)) { possibleCommands.add(new Command("Pull", d, direction)); } } // Find possible push commands for (dir d : dir.values()) { // We cannot push a box backwards in the agents direction if (d != Constants.oppositeDir(direction) && neighbourFreeInPlan(boxLocationInPlan,d)) { possibleCommands.add(new Command("Push", direction, d)); } } return possibleCommands; } public boolean neighbourFree(Field f, dir d){ //System.err.println(f); return (f.neighbours[d.ordinal()] != null && f.neighbours[d.ordinal()].object == null); } //Checks if neighbour is free in the plan. public boolean neighbourFreeInPlan(Field posInPlan, dir d){ if (neighbourFree(posInPlan, d)) { return true; } //If the neighbour is free in actual state then everything is good. If it is not, we need to check if //it is free in the plan, by checking if the neighbour is the agent's or the box's location. else if(posInPlan.neighbours[d.ordinal()] != null && (posInPlan.neighbours[d.ordinal()] == this.getAtField() || (this.desire != null && posInPlan.neighbours[d.ordinal()] == this.desire.box.getAtField()))){ return true; } return false; } private boolean neighbourIsBoxOfSameColor(dir d){ return (this.getAtField().neighbours[d.ordinal()] != null && this.getAtField().neighbours[d.ordinal()].object instanceof Box && ((Box) this.getAtField().neighbours[d.ordinal()].object).getColor() == this.color); } //Find the box's direction, relative to the agent, if they are on adjacent fields. public static dir getBoxDirection(Field agentField, Field boxField){ if (boxField == null) return null; for (dir d : dir.values()) { if (agentField.neighbours[d.ordinal()] != null && agentField.neighbours[d.ordinal()] == boxField) { return d; } } return null; } }
02285-ai-final
trunk/AI project/src/LevelObjects/Agent.java
Java
oos
12,803
package LevelObjects; import java.util.ArrayList; public class Level { public ArrayList<Agent> agents = new ArrayList<Agent>(); public ArrayList<Box> boxes = new ArrayList<Box>(); public ArrayList<Field> fields = new ArrayList<Field>(); public ArrayList<Goal> goals = new ArrayList<Goal>(); public Field[][] fieldMap; public Field[][] getFieldMap() { return fieldMap; } public void setFieldMap(Field[][] field_map) { this.fieldMap = field_map; } }
02285-ai-final
trunk/AI project/src/LevelObjects/Level.java
Java
oos
472
package LevelObjects; import java.util.Comparator; import constants.Constants.dir; public class Field implements Comparator<Field> { // Order of directions. /*public static enum dir { N, W, E, S };*/ // Example: neighbours[Constants.Constants.dir.N] public Field[] neighbours = new Field[4]; public int x; //Increases from left to right. public int y; //Increases downwards public Object object; //Can be null (free), or box or agent. public Object getObject() { return object; } public void setObject(Object object) { this.object = object; } public Field(int x, int y){ this.x = x; this.y = y; this.object = null; } public Field(int x, int y, Object object){ this.x = x; this.y = y; this.object = object; } public Field neighborTo(dir d) { return neighbours[d.ordinal()]; } public boolean isNeighborFree(dir d){ return (neighbours[d.ordinal()] != null && neighbours[d.ordinal()].object == null); } @Override public int compare(Field arg0, Field arg1) { if (arg0.x==arg1.x && arg0.y == arg1.y) return 0; else return (Math.abs(arg0.x-arg1.x) + Math.abs(arg0.y-arg1.y)); } @Override public String toString(){ return "" + this.x + "." + this.y; } public Field getClone(){ return new Field(this.x, this.y); } }
02285-ai-final
trunk/AI project/src/LevelObjects/Field.java
Java
oos
1,301
package LevelObjects; import java.util.ArrayList; public class Conflict { private Agent helpAgent; private Object obstacle; private Box moveaBox; private int priority; public ArrayList<Field> avoidFields = new ArrayList<Field>(); public Conflict(Agent helpAgent, ArrayList<Field> avoidFields, Object obstacle) { super(); this.helpAgent = helpAgent; this.avoidFields = avoidFields; this.obstacle = obstacle; } public Conflict(Agent helpAgent, ArrayList<Field> avoidFields, Object obstacle, Box moveaBox) { super(); this.helpAgent = helpAgent; this.obstacle = obstacle; this.avoidFields = avoidFields; this.moveaBox = moveaBox; } public Conflict(Agent helpAgent, ArrayList<Field> avoidFields, Object obstacle, Box moveaBox, int priority) { super(); this.helpAgent = helpAgent; this.obstacle = obstacle; this.avoidFields = avoidFields; this.moveaBox = moveaBox; this.priority = priority; } public Agent getHelpAgent() { return helpAgent; } public void setHelpAgent(Agent helpAgent) { this.helpAgent = helpAgent; } public Box getMoveaBox() { return moveaBox; } public void setMoveaBox(Box moveaBox) { this.moveaBox = moveaBox; } public int isPriority() { return priority; } public void setPriority(int priority) { this.priority = priority; } public ArrayList<Field> getAvoidFields() { return avoidFields; } public void setAvoidFields(ArrayList<Field> avoidFields) { this.avoidFields = avoidFields; } public Object getObstacle() { return obstacle; } public void setObstacle(Object obstacle) { this.obstacle = obstacle; } }
02285-ai-final
trunk/AI project/src/LevelObjects/Conflict.java
Java
oos
1,700
package LevelObjects; public class Goal extends Field implements Comparable<Goal> { private char id; public int priority; public char getId() { return id; } public int getPriority() { return priority; } public void setPriority(int priority){ this.priority = priority; } public Goal(char id, int x, int y) { super(x, y); this.id = id; } public Goal(char id, int x, int y, Object object) { super(x, y, object); this.id = id; } @Override public int compareTo(Goal arg0) { return this.priority - arg0.priority; } public Goal(char id, int x, int y, Object object, int priority) { super(x, y, object); this.id = id; this.priority = priority; } public boolean hasBox(Level level){ for (Box box : level.boxes) { if(box.getAtField() == new Field(this.x, this.y)) return true; } return false; } }
02285-ai-final
trunk/AI project/src/LevelObjects/Goal.java
Java
oos
865