Welcome to Our Community

Register on JustAnimeForum and start chatting about anime with like-minded people!

Sign Up / Login
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Thank you for the years of fun feel free to join the discord here! Please enjoy the forum for the short time it may be up feel free to make an account here or see what forums you dont need to make an account here
    with love,
    shedninja the sites biggest bug

Paste Game

Discussion in 'The Asylum' started by Sporadic, Apr 11, 2013.

  1. Belsfir Trophy Hunter

    Rank:
    Rank:
    Rank:
    Messages:
    24
    Joined:
    Apr 20, 2013
    Likes Received:
    3
    Trophy Points:
    150

    Ratings:
    +3 / 0 / -0
  2. Sporadic Site Dev Moderator Director

    Rank:
    Rank:
    Rank:
    Messages:
    8,972
    Joined:
    Mar 26, 2013
    Likes Received:
    972
    Trophy Points:
    335

    Ratings:
    +981 / 0 / -0
    (•_•)
    ( •_•)>⌐■-■
    (⌐■_■)
     
  3. Jaysp656 Artificial Intelligence

    Rank:
    Rank:
    Rank:
    Messages:
    1,130
    Joined:
    Apr 13, 2013
    Likes Received:
    19
    Trophy Points:
    210

    Ratings:
    +19 / 0 / -0
  4. KarmaDelta Trophy Hunter

    Rank:
    Rank:
    Rank:
    Messages:
    672
    Joined:
    Apr 13, 2013
    Likes Received:
    7
    Trophy Points:
    165

    Ratings:
    +7 / 0 / -0
  5. Miss Elegent Serenity Your loveable social admin & RP president Moderator Community Relations Content Manager

    Rank:
    Rank:
    Rank:
    Messages:
    1,650
    Joined:
    Apr 21, 2013
    Likes Received:
    284
    Trophy Points:
    305

    Ratings:
    +290 / 0 / -0
  6. Sporadic Site Dev Moderator Director

    Rank:
    Rank:
    Rank:
    Messages:
    8,972
    Joined:
    Mar 26, 2013
    Likes Received:
    972
    Trophy Points:
    335

    Ratings:
    +981 / 0 / -0
    https://sphotos-a.xx.fbcdn.net/hphotos-ash4/1000982_10152031240264966_939083539_n.jpg
     
  7. BK-201 The Black Reaper Moderator

    Rank:
    Rank:
    Rank:
    Messages:
    2,549
    Joined:
    Apr 20, 2013
    Likes Received:
    120
    Trophy Points:
    210

    Ratings:
    +124 / 1 / -0
    lost in cyber space
     
  8. Sporadic Site Dev Moderator Director

    Rank:
    Rank:
    Rank:
    Messages:
    8,972
    Joined:
    Mar 26, 2013
    Likes Received:
    972
    Trophy Points:
    335

    Ratings:
    +981 / 0 / -0
  9. Jaysp656 Artificial Intelligence

    Rank:
    Rank:
    Rank:
    Messages:
    1,130
    Joined:
    Apr 13, 2013
    Likes Received:
    19
    Trophy Points:
    210

    Ratings:
    +19 / 0 / -0
  10. Sporadic Site Dev Moderator Director

    Rank:
    Rank:
    Rank:
    Messages:
    8,972
    Joined:
    Mar 26, 2013
    Likes Received:
    972
    Trophy Points:
    335

    Ratings:
    +981 / 0 / -0
  11. Jaysp656 Artificial Intelligence

    Rank:
    Rank:
    Rank:
    Messages:
    1,130
    Joined:
    Apr 13, 2013
    Likes Received:
    19
    Trophy Points:
    210

    Ratings:
    +19 / 0 / -0
    9781890774561
     
  12. Sporadic Site Dev Moderator Director

    Rank:
    Rank:
    Rank:
    Messages:
    8,972
    Joined:
    Mar 26, 2013
    Likes Received:
    972
    Trophy Points:
    335

    Ratings:
    +981 / 0 / -0
    https://0-media-cdn.foolz.us/ffuuka/board/wsg/image/1342/03/1342032096472.gif
     
  13. Jaysp656 Artificial Intelligence

    Rank:
    Rank:
    Rank:
    Messages:
    1,130
    Joined:
    Apr 13, 2013
    Likes Received:
    19
    Trophy Points:
    210

    Ratings:
    +19 / 0 / -0
    http://www.youtube.com/watch?v=u_ErxlI03V4
     
  14. KarmaDelta Trophy Hunter

    Rank:
    Rank:
    Rank:
    Messages:
    672
    Joined:
    Apr 13, 2013
    Likes Received:
    7
    Trophy Points:
    165

    Ratings:
    +7 / 0 / -0
    [4:27:19 AM] Sai: nah
    [4:27:19 AM] Sai: i dont like yaoi
     
  15. Sir-Maddy Finger Lickin' Good™

    Rank:
    Rank:
    Rank:
    Messages:
    8,436
    Joined:
    Apr 20, 2013
    Likes Received:
    256
    Trophy Points:
    210

    Ratings:
    +260 / 0 / -1
    http://kevo.dasaku.net/wp-content/uploads/2009/11/sw2.jpg

    Dawwwwww, crap.
     
  16. Jaysp656 Artificial Intelligence

    Rank:
    Rank:
    Rank:
    Messages:
    1,130
    Joined:
    Apr 13, 2013
    Likes Received:
    19
    Trophy Points:
    210

    Ratings:
    +19 / 0 / -0
    http://puu.sh/3Bazv.jpg
     
  17. Heizengard AKA Cernel Joson

    Rank:
    Rank:
    Rank:
    Messages:
    1,449
    Joined:
    Apr 11, 2013
    Likes Received:
    133
    Trophy Points:
    200

    Ratings:
    +133 / 0 / -0
    I don't even know what that is so.... I win!
     
  18. Jaysp656 Artificial Intelligence

    Rank:
    Rank:
    Rank:
    Messages:
    1,130
    Joined:
    Apr 13, 2013
    Likes Received:
    19
    Trophy Points:
    210

    Ratings:
    +19 / 0 / -0
    http://puu.sh/3BtEx.png
     
  19. JAMSM Trophy Hunter

    Rank:
    Rank:
    Rank:
    Messages:
    12
    Joined:
    Apr 22, 2013
    Likes Received:
    0
    Trophy Points:
    150

    Ratings:
    +0 / 0 / -0
    Oh lord, ok, having seen what I pasted, I know why it was in my clipboard, but it still shocked me...

    last semester, one of my projects in my CS class was to write a tic tac toe game in java.

    yesterday, I decided to fix the damn thing, so the computer wasn't horrible at the game.

    What I then did, was take a good 5 hours worth of sleeping time to ratchet out about 500 lines of code (hence it's not formatted very nicely, don't poke fun at my late night code conventions) this morning, I showed my sister the newly upgraded tic tac toe game, and she decided she wanted a rock paper scissors program. So I obliged her, but rather than starting from scratch, I figured I could just rework my existing code, so I copied the source code, and put it into a new project (Yes, I use an IDE, easier to copy the source code than the file)

    Code:
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    
    public class TicTacToe implements ActionListener, MouseListener {
    
    	public static void main(String[] args) {
    		TicTacToe e = new TicTacToe();
    	}
    	
    	private ArrayList buttons = new ArrayList(9);
    	private final int EASY = 0, MEDIUM = 1, HARD = 2, IMPOSSIBLE = 3;
    	private int mode = EASY;
    	private String modeName = "Easy";
    	private JLabel label0, label1, label2, label3, label4, label5, label6, label7, label8;
    	private JPopupMenu popup0, popup1;
    	private JMenuItem easy, medium, hard, impossible;
    	private JMenuItem x, o;
    	private JDialog gameEnd;
    	private JPanel panel2, panel3;
    	private JButton yesButton, noButton;
    	private Random ran = new Random();
    	private JButton[] buttonArray;
    	private ArrayList buttonList = new ArrayList(),
    			lineList = new ArrayList(), strat = new ArrayList();
    	private String player = "X", computer = "o";
    	private boolean gameDone = false;
    	private int sCount, pWin = 0, cWin = 0, noWin = 0, gCount = 0;
    	
    	TicTacToe() {
    		JFrame frame = new JFrame("TicTacToe");
    		frame.setPreferredSize(new Dimension(200,300));
    		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    		frame.setResizable(false);
    		Container pane = frame.getContentPane();
    		pane.setLayout(new FlowLayout(FlowLayout.CENTER));
    		JPanel panel0 = new JPanel();
    		panel0.setPreferredSize(new Dimension(180, 20));
    		label0 = new JLabel("Difficulty");
    		label0.addMouseListener(this);
    		popup0 = new JPopupMenu();
    		easy = new JMenuItem("Easy");
    		easy.addActionListener(this);
    		medium = new JMenuItem("Medium");
    		medium.addActionListener(this);
    		hard = new JMenuItem("Hard");
    		hard.addActionListener(this);
    		impossible = new JMenuItem("Impossible");
    		impossible.addActionListener(this);
    		popup0.add(easy);
    		popup0.add(medium);
    		popup0.add(hard);
    		popup0.add(impossible);
    		label0.add(popup0);
    		label1 = new JLabel(" | ");
    		label2 = new JLabel("Letter");
    		label2.addMouseListener(this);
    		popup1 = new JPopupMenu();
    		x = new JMenuItem("X");
    		x.addActionListener(this);
    		o = new JMenuItem("o");
    		o.addActionListener(this);
    		popup1.add(x);
    		popup1.add(o);
    		label5 = new JLabel(" | ");
    		label6 = new JLabel("Reset");
    		label6.addMouseListener(this);
    		panel0.add(label0);
    		panel0.add(label1);
    		panel0.add(label2);
    		panel0.add(label5);
    		panel0.add(label6);
    		JPanel panel1 = new JPanel();
    		panel1.setPreferredSize(new Dimension(180,170));
    		JButton[] button = new JButton[9];
    		JPanel panel4 = new JPanel();
    		panel4.setPreferredSize(new Dimension(200, 2));
    		panel4.setBackground(Color.BLACK);
    		JPanel panel5 = new JPanel();
    		panel5.setPreferredSize(new Dimension(200, 80));
    		label7 = new JLabel("Difficulty: " + modeName + "  |  Games: " + gCount);
    		label8 = new JLabel("Won: "+pWin+"  |  Lost: "+cWin+"  |  Draws: "+noWin);
    		panel5.add(label7);
    		panel5.add(label8);
    		
    		gameEnd = new JDialog();
    		gameEnd.setResizable(false);
    		panel2 = new JPanel();
    		label3 = new JLabel();
    		label4 = new JLabel();
    		panel3 = new JPanel();
    		yesButton = new JButton("Yes");
    		yesButton.addActionListener(this);
    		noButton = new JButton("No");
    		noButton.addActionListener(this);
    		panel3.add(yesButton);
    		panel3.add(noButton);
    		panel2.add(label3);
    		panel2.add(label4);
    		panel2.add(panel3);
    		gameEnd.add(panel2);
    		gameEnd.setBounds(150, 150, 180, 110);
    		
    		for (int i = 0; i1) {
    				index = ran.nextInt(lineList.size());
    				if (lineList.get(index).getText().length()0) {
    				sCount++;
    			}
    		}
    		sCount = sCount/2;
    		switch (sCount) {
    		case 1:
    			if (buttons.get(0).getText().equals(player)) {
    				strat.add(buttons.get(1));
    				strat.add(buttons.get(3));
    			} else if (buttons.get(1).getText().equals(player)) {
    				strat.add(buttons.get(6));
    				strat.add(buttons.get(8));
    			} else if (buttons.get(2).getText().equals(player)) {
    				strat.add(buttons.get(1));
    				strat.add(buttons.get(5));
    			} else if (buttons.get(3).getText().equals(player)) {
    				strat.add(buttons.get(2));
    				strat.add(buttons.get(8));
    			} else if (buttons.get(5).getText().equals(player)) {
    				strat.add(buttons.get(0));
    				strat.add(buttons.get(6));
    			} else if (buttons.get(6).getText().equals(player)) {
    				strat.add(buttons.get(3));
    				strat.add(buttons.get(7));
    			} else if (buttons.get(7).getText().equals(player)) {
    				strat.add(buttons.get(0));
    				strat.add(buttons.get(2));
    			} else if (buttons.get(8).getText().equals(player)) {
    				strat.add(buttons.get(5));
    				strat.add(buttons.get(7));
    			}
    			sort();
    			return;
    		case 2: case 3: case 4:
    			for (int i = 0; i < buttons.size(); i += 2) {
    				if (buttons.get(i).getText().length()
     
  20. Sporadic Site Dev Moderator Director

    Rank:
    Rank:
    Rank:
    Messages:
    8,972
    Joined:
    Mar 26, 2013
    Likes Received:
    972
    Trophy Points:
    335

    Ratings:
    +981 / 0 / -0
    jesus is gonna f*ck things up soon
     

Share This Page