SIBR1X Demographics Program

View previous topic View next topic Go down

SIBR1X Demographics Program

Post by Ankoku on Sat Jul 07, 2012 5:54 pm

Hey everyone, I've been a big fan of sim bro for a while, but never really contributed (in fact this is my first post), but i finally stopped being lazy and made something for SIBR1X.

Since i use a lot of GPACs, i always wonder "How many of this type of girl do i have?" so i made a simple demographics program to tell me how many big boobed girls or nerdy girls with green hair there are in my sim bro world (note: it does not search for how many you actually own in your saved games... though i may add this feature if there is enough demand for it, i personally don't care to though, as its easy to keep track of 20-40 girls types for me, not so much for 500+).

I don't know if this program will work for any of the other sim bro projects as i don't know how the girls are stored in those, but it should work with any version of sibr1x.

I made the program using Java in the NetBeans IDE. I didn't make it part of the game or girl maker as i have no access to the source code of those, and java is the only programming language I'm any good at.

I named it Java Search so that i could keep it with my other NetBeans projects and have it not be blatantly obvious that its porn related (really the only thing that would suggest this program is porn related is the dropdown boxes and numToType method in the source code).

Download

Just the program:
rapidshare.com Java_Search.jar

The entire NetBeans project folder (including everything i used to make this, in case someone is interested in messing with it):
rapidshare.com Java_Search.zip

The source code (in case one of the developers wanna use part of it in the game or something, feel free.):
Code:
/*
 * JSearch.java
 *
 * Created on Jun 27, 2012, 1:46:56 AM
 */

package JSearch;

import java.awt.Font;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author Ankoku
 */

public class JSearch extends javax.swing.JFrame {
   
    /** Creates new form JSearch */
    public JSearch() {
        initComponents();
        setSize(625, 500);
        setLocationRelativeTo(null);
        jta.setFont(new Font("Monospaced", Font.PLAIN, 13));
        jta.append(String.format("%-36s%-10s%-1s\n", "Types", "Number", "Percent of total population"));
    }
   
    /** 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();
        jPanel8 = new javax.swing.JPanel();
        jcb1 = new javax.swing.JComboBox();
        jcb2 = new javax.swing.JComboBox();
        jcb3 = new javax.swing.JComboBox();
        jPanel9 = new javax.swing.JPanel();
        jbtSearch = new javax.swing.JButton();
        jbtClear = new javax.swing.JButton();
        jbtReport = new javax.swing.JButton();
        jchDetails = new javax.swing.JCheckBox();
        jchExclude = new javax.swing.JCheckBox();
        jPanel3 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jta = new javax.swing.JTextArea();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Sibr1x Demographics");

        jPanel1.setLayout(new java.awt.BorderLayout());

        jcb1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Any", "Lolita", "Big Boob", "Nerd", "Exotic", "Meek", "Slutty", "Athlete", "Nurse", "Tom Boy", "Mean", "Warrior", "Magical", "Religious", "Red Hair", "Purple Hair", "Green Hair", "Dark Hair", "White Hair", "Pink Hair", "Blonde Hair", "Blue Hair", "Brown Hair", "Outgoing", "Playful", "Proper", "Trendy", "None" }));
        jPanel8.add(jcb1);

        jcb2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Any", "Lolita", "Big Boob", "Nerd", "Exotic", "Meek", "Slutty", "Athlete", "Nurse", "Tom Boy", "Mean", "Warrior", "Magical", "Religious", "Red Hair", "Purple Hair", "Green Hair", "Dark Hair", "White Hair", "Pink Hair", "Blonde Hair", "Blue Hair", "Brown Hair", "Outgoing", "Playful", "Proper", "Trendy", "None" }));
        jPanel8.add(jcb2);

        jcb3.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Any", "Lolita", "Big Boob", "Nerd", "Exotic", "Meek", "Slutty", "Athlete", "Nurse", "Tom Boy", "Mean", "Warrior", "Magical", "Religious", "Red Hair", "Purple Hair", "Green Hair", "Dark Hair", "White Hair", "Pink Hair", "Blonde Hair", "Blue Hair", "Brown Hair", "Outgoing", "Playful", "Proper", "Trendy", "None" }));
        jPanel8.add(jcb3);

        jPanel1.add(jPanel8, java.awt.BorderLayout.NORTH);

        jbtSearch.setText("Search");
        jbtSearch.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtSearchActionPerformed(evt);
            }
        });
        jPanel9.add(jbtSearch);

        jbtClear.setText("Clear");
        jbtClear.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtClearActionPerformed(evt);
            }
        });
        jPanel9.add(jbtClear);

        jbtReport.setText("Generate Report");
        jbtReport.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtReportActionPerformed(evt);
            }
        });
        jPanel9.add(jbtReport);

        jchDetails.setText("Detailed Report");
        jPanel9.add(jchDetails);

        jchExclude.setSelected(true);
        jchExclude.setText("Exclude Redundant Types");
        jPanel9.add(jchExclude);

        jPanel1.add(jPanel9, java.awt.BorderLayout.SOUTH);

        getContentPane().add(jPanel1, java.awt.BorderLayout.NORTH);

        jPanel3.setLayout(new java.awt.BorderLayout());

        jta.setColumns(20);
        jta.setLineWrap(true);
        jta.setRows(5);
        jta.setWrapStyleWord(true);
        jScrollPane1.setViewportView(jta);

        jPanel3.add(jScrollPane1, java.awt.BorderLayout.CENTER);

        getContentPane().add(jPanel3, java.awt.BorderLayout.CENTER);

        pack();
    }// </editor-fold>//GEN-END:initComponents
   
    private int countIndexOf(String text, String search) {
        Matcher m = Pattern.compile(search).matcher(text);
        int count;
        for (count = 0; m.find(); count++);
        return count;
    }
   
    private String readGirls() throws IOException {
        FileReader fr = new FileReader("girls.txt");
        BufferedReader br = new BufferedReader(fr);
        String line;
        StringBuilder result = new StringBuilder();
        while ((line = br.readLine()) != null) {
            result.append(line);
        }
        fr.close();
        return result.toString();
    }
   
    private String numToType(int type){
        switch (type){
            case 0: return "";
            case 1: return "Lolita";
            case 2: return "Big Boobs";
            case 3: return "Nerd";
            case 4: return "Exotic";
            case 5: return "Meek";
            case 6: return "Slutty";
            case 7: return "Athlete";
            case 8: return "Nurse";
            case 9: return "Tom Boy";
            case 10: return "Mean";
            case 11: return "Warrior";
            case 12: return "Magical";
            case 13: return "Religious";
            case 14: return "Red Hair";
            case 15: return "Purple Hair";
            case 16: return "Green Hair";
            case 17: return "Dark Hair";
            case 18: return "White Hair";
            case 19: return "Pink Hair";
            case 20: return "Blonde Hair";
            case 21: return "Blue Hair";
            case 22: return "Brown Hair";
            case 23: return "Outgoing";
            case 24: return "Playful";
            case 25: return "Proper";
            case 26: return "Trendy";
            case 27: return "None";
            default: return "Error";
        }
    }
   
    private void jbtSearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtSearchActionPerformed
        try{
            String text = readGirls();
           
            String type1 = "0", type2 = "0", type3 = "([0-9]|1[0-9]|2[0-7])",
                    type1Name = "All", type2Name = " ", type3Name = " ";
            int tempResult, totalResult, totalPop;
           
            // Checks if any jcb is filled and assigns to types 1-3 if they are.
            if (jcb1.getSelectedIndex() > 0){
                type1 = "" + jcb1.getSelectedIndex();
                type1Name = jcb1.getSelectedItem().toString();
                if (jcb2.getSelectedIndex() > 0){
                    type2 = "" + jcb2.getSelectedIndex();
                    type2Name = jcb2.getSelectedItem().toString();
                    if (jcb3.getSelectedIndex() > 0){
                        type3 = "" + jcb3.getSelectedIndex();
                        type3Name = jcb3.getSelectedItem().toString();
                    }
                }
                else if (jcb3.getSelectedIndex() > 0){
                    type2 = "" + jcb3.getSelectedIndex();
                    type2Name = jcb3.getSelectedItem().toString();
                }
            }
            else if (jcb2.getSelectedIndex() > 0){
                type1 = "" + jcb2.getSelectedIndex();
                type1Name = jcb2.getSelectedItem().toString();
                if (jcb3.getSelectedIndex() > 0){
                    type2 = "" + jcb3.getSelectedIndex();
                    type2Name = jcb3.getSelectedItem().toString();
                }
            }
            else if (jcb3.getSelectedIndex() > 0){
                type1 = "" + jcb3.getSelectedIndex();
                type1Name = jcb3.getSelectedItem().toString();
            }
           
            totalPop = countIndexOf(text, "\\{([0-9]|1[0-9]|2[0-7])\\,([0-9]|1[0-9]|2[0-7])\\,([0-9]|1[0-9]|2[0-7])\\}");
           
            if (type1.equals("0")){
                totalResult = totalPop;
            }
            else if (type2.equals("0")){
                tempResult = countIndexOf(text, "\\{" + type1 + "\\,([0-9]|1[0-9]|2[0-7])\\,([0-9]|1[0-9]|2[0-7])\\}");
                totalResult = tempResult;
                tempResult = countIndexOf(text, "\\{([0-9]|1[0-9]|2[0-7])\\," + type1 + "\\,([0-9]|1[0-9]|2[0-7])\\}");
                totalResult += tempResult;
                tempResult = countIndexOf(text, "\\{([0-9]|1[0-9]|2[0-7])\\,([0-9]|1[0-9]|2[0-7])\\," + type1 + "\\}");
                totalResult += tempResult;
            }
            else {
                tempResult = countIndexOf(text, "\\{" + type1 + "\\," + type2 + "\\," + type3 + "\\}");
                totalResult = tempResult;
                tempResult = countIndexOf(text, "\\{" + type1 + "\\," + type3 + "\\," + type2 + "\\}");
                totalResult += tempResult;
                tempResult = countIndexOf(text, "\\{" + type2 + "\\," + type1 + "\\," + type3 + "\\}");
                totalResult += tempResult;
                tempResult = countIndexOf(text, "\\{" + type3 + "\\," + type1 + "\\," + type2 + "\\}");
                totalResult += tempResult;
                tempResult = countIndexOf(text, "\\{" + type2 + "\\," + type3 + "\\," + type1 + "\\}");
                totalResult += tempResult;
                tempResult = countIndexOf(text, "\\{" + type3 + "\\," + type2 + "\\," + type1 + "\\}");
                totalResult += tempResult;
            }
           
            double percent = ((double)totalResult / (double)totalPop) * 100.0;
           
            jta.append(String.format("%-12s%-12s%-12s%-10d%-1.2f%1s\n", type1Name,
                    type2Name, type3Name, totalResult, percent, "%"));
           
        } catch (IOException ex){
            jta.append(ex.toString());
        }
    }//GEN-LAST:event_jbtSearchActionPerformed
   
    private void jbtClearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtClearActionPerformed
        jta.setText(String.format("%-36s%-10s%-1s\n", "Types", "Number", "Percent of total population"));
    }//GEN-LAST:event_jbtClearActionPerformed
   
    private void jbtReportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtReportActionPerformed
        try{
            String text = readGirls();
           
            String type1Name = "", type2Name = "", type3Name = "";
            int tempResult, totalResult;
           
            int totalPop = totalResult = countIndexOf(text, "\\{([0-9]|1[0-9]|2[0-7])\\,([0-9]|1[0-9]|2[0-7])\\,([0-9]|1[0-9]|2[0-7])\\}");
           
            double percent = ((double)totalResult / (double)totalPop) * 100.0;
            jta.append(String.format("%-12s%-12s%-12s%-10d%-1.2f%1s\n", "",
                    "", "All", totalResult, percent, "%"));
           
            for (int type1c = 1; type1c < 28; type1c++){
                tempResult = countIndexOf(text, "\\{" + type1c + "\\,([0-9]|1[0-9]|2[0-7])\\,([0-9]|1[0-9]|2[0-7])\\}");
                totalResult = tempResult;
                tempResult = countIndexOf(text, "\\{([0-9]|1[0-9]|2[0-7])\\," + type1c + "\\,([0-9]|1[0-9]|2[0-7])\\}");
                totalResult += tempResult;
                tempResult = countIndexOf(text, "\\{([0-9]|1[0-9]|2[0-7])\\,([0-9]|1[0-9]|2[0-7])\\," + type1c + "\\}");
                totalResult += tempResult;
               
                if (totalResult > 0 || jchDetails.isSelected()){
                    percent = ((double)totalResult / (double)totalPop) * 100.0;
                   
                    type1Name = numToType(type1c);
                   
                    jta.append(String.format("%-12s%-12s%-12s%-10d%-1.2f%1s\n",
                            type3Name, type2Name, type1Name, totalResult,
                            percent, "%"));
                }
            }
           
            for (int type3c = 0; type3c < 28; type3c++){
                for (int type2c = 1; type2c < 28; type2c++){
                    for (int type1c = 1; type1c < 28; type1c++){
                        if (((type1c > type2c) && (type2c > type3c)) || (!jchExclude.isSelected())){
                            if (type3c == 0){
                                tempResult = countIndexOf(text, "\\{" + type1c + "\\," + type2c + "\\,([0-9]|1[0-9]|2[0-7])\\}");
                                totalResult = tempResult;
                                tempResult = countIndexOf(text, "\\{" + type1c + "\\,([0-9]|1[0-9]|2[0-7])\\," + type2c + "\\}");
                                totalResult += tempResult;
                                tempResult = countIndexOf(text, "\\{" + type2c + "\\," + type1c + "\\,([0-9]|1[0-9]|2[0-7])\\}");
                                totalResult += tempResult;
                                tempResult = countIndexOf(text, "\\{([0-9]|1[0-9]|2[0-7])\\," + type1c + "\\," + type2c + "\\}");
                                totalResult += tempResult;
                                tempResult = countIndexOf(text, "\\{" + type2c + "\\,([0-9]|1[0-9]|2[0-7])\\," + type1c + "\\}");
                                totalResult += tempResult;
                                tempResult = countIndexOf(text, "\\{([0-9]|1[0-9]|2[0-7])\\," + type2c + "\\," + type1c + "\\}");
                                totalResult += tempResult;
                            } else {
                                tempResult = countIndexOf(text, "\\{" + type1c + "\\," + type2c + "\\," + type3c + "\\}");
                                totalResult = tempResult;
                                tempResult = countIndexOf(text, "\\{" + type1c + "\\," + type3c + "\\," + type2c + "\\}");
                                totalResult += tempResult;
                                tempResult = countIndexOf(text, "\\{" + type2c + "\\," + type1c + "\\," + type3c + "\\}");
                                totalResult += tempResult;
                                tempResult = countIndexOf(text, "\\{" + type3c + "\\," + type1c + "\\," + type2c + "\\}");
                                totalResult += tempResult;
                                tempResult = countIndexOf(text, "\\{" + type2c + "\\," + type3c + "\\," + type1c + "\\}");
                                totalResult += tempResult;
                                tempResult = countIndexOf(text, "\\{" + type3c + "\\," + type2c + "\\," + type1c + "\\}");
                                totalResult += tempResult;
                            }
                           
                            if (totalResult > 0 || jchDetails.isSelected()){
                                percent = ((double)totalResult / (double)totalPop) * 100.0;
                               
                                type3Name = numToType(type3c);
                                type2Name = numToType(type2c);
                                type1Name = numToType(type1c);
                               
                                jta.append(String.format("%-12s%-12s%-12s%-10d%-1.2f%1s\n",
                                        type3Name, type2Name, type1Name, totalResult,
                                        percent, "%"));
                            }
                        }
                    }
                }
            }
        } catch (IOException ex){
            jta.append(ex.toString());
        }
    }//GEN-LAST:event_jbtReportActionPerformed
   
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
        * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
        */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(JSearch.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(JSearch.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(JSearch.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(JSearch.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>
       
        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
           
            public void run() {
                new JSearch().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JButton jbtClear;
    private javax.swing.JButton jbtReport;
    private javax.swing.JButton jbtSearch;
    private javax.swing.JComboBox jcb1;
    private javax.swing.JComboBox jcb2;
    private javax.swing.JComboBox jcb3;
    private javax.swing.JCheckBox jchDetails;
    private javax.swing.JCheckBox jchExclude;
    private javax.swing.JTextArea jta;
    // End of variables declaration//GEN-END:variables
}

Installation

Just move Java Search.jar into your sibr1x folder (the same folder as the girls.txt file) and double click it. For those who downloaded the entire project folder, the .jar is in the dist folder.

Instructions

To find how many of a specific type of girl you have, simply select the type from the dropdown boxes and hit the Search button, it doesn't matter which dropdown box you put the type in, it will find all the girls with purple hair no matter which dropdown you put it in. Leaving all 3 dropdowns as "Any" will just give you the total population.

The Clear button will reset the text area to the way it was when you brought up the program.

The Generate Report button will tell you how many of every possible combination of the types you have. As there is nearly 22,000 possible combinations, it may freeze the program for a few second or minutes depending on your computer while it searches before it displays the results, just be patient and it will unfreeze.

By default the Generate Report button wont display types of girls which you have 0 of, To change this, you can check the Detailed Report check box.

The Exclude Redundant Types check box makes the generated report not display both Big Boobed Nerd Exotic and Big Boobed Exotic Nerd, or Nerd Nerd Nerd or similar redundant types of girls. You may un-check this box to include redundant types, which may make it easier to read the report. Do note that un-checking this check box will make the search take longer to perform.

Trouble Shooting

Q: The program wont run at all!
A: Make sure you have the latest version of java installed.

Q: Whenever i hit the Search or Generate Report button all it says is "java.io.FileNotFoundException: girls.txt (The system cannot find the file specified)"
A: Make sure you have the girls.txt file in the same folder as the program.

Q: The program freezes when i hit the Generate Report button!
A: This is normal, just be patient and it will unfreeze, there are nearly 22,000 possible combinations of girls it has to search for, this takes time and I'm too lazy to make a "searching..." screen for it.

If you have any other problems please reply to this thread with them and i will try my best to resolve them.

Ankoku

Posts : 2
Reputation : 3
Join date : 2012-06-27

View user profile

Back to top Go down

Re: SIBR1X Demographics Program

Post by Sky on Sun Jul 08, 2012 6:17 pm

Nifty. I've been waiting for emcioran to build something like this into the game, and to be honest I've been dreading what it would tell me - since I already knew my GPACs aren't particuarly well balanced demographicly. It's a problem I started to address a little with my last pac, and with this I can clearly see which areas need attention most.

Thumbs up from me.
avatar
Sky

Posts : 28
Reputation : 8
Join date : 2011-10-30

View user profile

Back to top Go down

haha, nice work but....

Post by emcioran on Tue Jul 10, 2012 4:35 pm

Actually girlmaker has had this functionality all along. If you hit the demographics report button in the right side button collection a file will be created in your install directory that lists all this information. The file is called chars_data.txt.

Yours does have a bunch of extra functionality that is really nice though so feel free to keep plugging away at it. I'll probably use it at some point to help balancing. Smile

emcioran

Posts : 147
Reputation : 49
Join date : 2009-10-17

View user profile

Back to top Go down

Re: SIBR1X Demographics Program

Post by Ankoku on Tue Jul 10, 2012 7:34 pm

Oh wow, i never knew the Demographics Report button actually worked, i thought it was just there as a planned feature since it didn't look like it did anything when i pressed it.

Well, if anyone can think of some useful features to add to this, feel free to post em, and ill likely add them.

Ankoku

Posts : 2
Reputation : 3
Join date : 2012-06-27

View user profile

Back to top Go down

Re: SIBR1X Demographics Program

Post by Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum