diff --git a/Unit-1/ConwayRunner.java b/Unit-1/ConwayRunner.java new file mode 100644 index 0000000..0157c2b --- /dev/null +++ b/Unit-1/ConwayRunner.java @@ -0,0 +1,85 @@ +import org.code.neighborhood.*; + +public class ConwayRunner { + + public int mod(int n) { + int o = n % 8; + if(o < 0){ + return 8+o; + } + return o; + } + + public int isAlive(String color) { + boolean isAlive = (color == "White" || color == "1"); + if(isAlive){ + return 1; + }else{ + return 0; + } + } + + public void run(Renderer r, String[][] state) { + for(String[] line : state){ + System.out.println(String.join("",line)); + } + + r.render(state); + this.iterate(r, state); + } + + public void iterate(Renderer r, String[][] initState) { + int index1 = 0; + String[][] newState = new String[8][8]; + for(String[] line : initState) { + int index2 = 0; + for(String cell : line) { + + String cell1 = initState[this.mod(index1-1)][this.mod(index2-1)]; + String cell2 = initState[this.mod(index1-1)][this.mod(index2)]; + String cell3 = initState[this.mod(index1-1)][this.mod(index2+1)]; + String cell4 = initState[this.mod(index1)][this.mod(index2-1)]; + String cell5 = initState[this.mod(index1)][this.mod(index2+1)]; + String cell6 = initState[this.mod(index1+1)][this.mod(index2-1)]; + String cell7 = initState[this.mod(index1+1)][this.mod(index2)]; + String cell8 = initState[this.mod(index1+1)][this.mod(index2+1)]; + + boolean isAlive = (cell == "White"); + int count = this.isAlive(cell1)+ + this.isAlive(cell2)+ + this.isAlive(cell3)+ + this.isAlive(cell4)+ + this.isAlive(cell5)+ + this.isAlive(cell6)+ + this.isAlive(cell7)+ + this.isAlive(cell8); + + + String newColor = new String(); + if(isAlive && count < 2){ + newColor = "Black"; + }else if(isAlive && count == 2 || count == 3){ + newColor = "White"; + }else if(isAlive && count > 3){ + newColor = "Black"; + }else if(!isAlive && count == 3){ + newColor = "White"; + }else if(!isAlive){ + newColor = "Black"; + } + + // System.out.println(count); + + // newLine.set(index2, newColor); + newState[index1][index2] = (newColor); + + + index2++; + } + index1++; + // newState.set(index1, newLine); + } + this.run(r, newState); + + } +} \ No newline at end of file diff --git a/Unit-1/NeighborhoodRunner.java b/Unit-1/NeighborhoodRunner.java new file mode 100644 index 0000000..4520c61 --- /dev/null +++ b/Unit-1/NeighborhoodRunner.java @@ -0,0 +1,25 @@ +import org.code.neighborhood.*; + +public class NeighborhoodRunner { + public static void main(String[] args) { + + String I = "White"; + String O = "Black"; + + String[][] initState = new String[][] { + new String[] {O,O,O,O,O,O,O,O}, + new String[] {O,I,I,O,O,O,O,O}, + new String[] {O,I,O,I,O,O,O,O}, + new String[] {O,I,O,O,O,O,O,O}, + new String[] {O,O,O,O,O,O,O,O}, + new String[] {O,O,O,O,O,I,I,O}, + new String[] {O,O,O,O,I,O,I,O}, + new String[] {O,O,O,O,O,O,I,O}}; + + ConwayRunner cw = new ConwayRunner(); + Renderer r = new Renderer(); + cw.run(r, initState); + cw.run(r, initState); + + } +} \ No newline at end of file diff --git a/Unit-1/Renderer.java b/Unit-1/Renderer.java new file mode 100644 index 0000000..a54f75c --- /dev/null +++ b/Unit-1/Renderer.java @@ -0,0 +1,68 @@ +import org.code.neighborhood.*; + +/* + * MuralPainter is a PainterPlus that paints + * murals in The Neighborhood + */ +public class Renderer extends Painter { + + + public void render(String[][] mural) { + + this.setPaint((8*8)); + int index1 = 0; + for(String[] line : mural){ + // System.out.println(line[0].toString()); + int index2 = 0; + for(String color : line){ + + // System.out.println(color); + + if(!this.isOnPaint()){ + this.paint(color); + }else if(this.isOnPaint() && this.getColor() != color){ + this.scrapePaint(); + this.paint(color); + } + + + if(index2 != line.length-1){ + this.move(); + } + index2++; + + } + + if(index1 != mural.length-1){ + this.turnLeft(); + this.turnLeft(); + this.turnLeft(); + this.move(); + this.turnLeft(); + this.turnLeft(); + this.turnLeft(); + + for(int i=0;i y && y > 0 && x > 0 && this.width > x && D > z[o]){ + z[o] = D; + int num = Math.max(N, 0); + this.buffer[o] = shade_chars[num]; + } + } + } + A += 0.04; + B += 0.02; + String str = ""; + for(int k=0; buffer_size >= k; k++){ + if(k % this.width > 0){ + str += (this.buffer[k]); + }else{ + str += (newLine); + } + } + return str; + } +} \ No newline at end of file diff --git a/Unit-2/main.java b/Unit-2/main.java new file mode 100644 index 0000000..13c60b3 --- /dev/null +++ b/Unit-2/main.java @@ -0,0 +1,14 @@ +public class main { + public static void main(String[] args) { + + regularDonut d = new regularDonut(); + + d.setZoom(2); + d.setThickness(40); + + while(true){ + System.out.print(d); + } + + } +} \ No newline at end of file diff --git a/Unit-2/regularDonut.java b/Unit-2/regularDonut.java new file mode 100644 index 0000000..b4578fb --- /dev/null +++ b/Unit-2/regularDonut.java @@ -0,0 +1,38 @@ +public class regularDonut extends donut { + private int width; + private int height; + private double zoom; + private double thickness; + + public regularDonut() { + this(22,80,1,40); + } + + public regularDonut(int height, int width, double zoom, double thickness) { + super(height, width); + this.height = height; + this.width = width; + this.zoom = zoom; + this.thickness = thickness; + } + + public void setZoom(double zoom) { + this.zoom = zoom; + } + + public double getZoom() { + return this.zoom; + } + + public void setThickness(double thickness) { + this.thickness = thickness; + } + + public double getThickness() { + return this.thickness; + } + + public String toString() { + return this.render(zoom, thickness); + } +} diff --git a/Unit-3/countries.txt b/Unit-3/countries.txt new file mode 100644 index 0000000..0d36440 --- /dev/null +++ b/Unit-3/countries.txt @@ -0,0 +1,215 @@ +Afghanistan +Albania +Algeria +American Samoa +Andorra +Angola +Antigua and Barbuda +Argentina +Armenia +Aruba +Australia +Austria +Azerbaijan +Bahamas, The +Bahrain +Bangladesh +Barbados +Belarus +Belgium +Belize +Benin +Bermuda +Bhutan +Bolivia +Bosnia and Herzegovina +Botswana +Brazil +British Virgin Islands +Brunei Darussalam +Bulgaria +Burkina Faso +Burundi +Cabo Verde +Cambodia +Cameroon +Canada +Cayman Islands +Central African Republic +Chad +Chile +China +Colombia +Comoros +Congo, Dem. Rep. +Congo, Rep. +Costa Rica +Cote d'Ivoire +Croatia +Cuba +Curacao +Cyprus +Czech Republic +Denmark +Djibouti +Dominica +Dominican Republic +Ecuador +Egypt, Arab Rep. +El Salvador +Equatorial Guinea +Eritrea +Estonia +Eswatini +Ethiopia +Faroe Islands +Fiji +Finland +France +French Polynesia +Gabon +Gambia, The +Georgia +Germany +Ghana +Gibraltar +Greece +Greenland +Grenada +Guam +Guatemala +Guinea +Guinea-Bissau +Guyana +Haiti +Honduras +Hong Kong SAR, China +Hungary +Iceland +India +Indonesia +Iran, Islamic Rep. +Iraq +Ireland +Isle of Man +Israel +Italy +Jamaica +Japan +Jordan +Kazakhstan +Kenya +Kiribati +Korea, Dem. People's Rep. +Korea, Rep. +Kuwait +Kyrgyz Republic +Lao PDR +Latvia +Lebanon +Lesotho +Liberia +Libya +Liechtenstein +Lithuania +Luxembourg +Macao SAR, China +Madagascar +Malawi +Malaysia +Maldives +Mali +Malta +Marshall Islands +Mauritania +Mauritius +Mexico +Micronesia, Fed. Sts. +Moldova +Monaco +Mongolia +Montenegro +Morocco +Mozambique +Myanmar +Namibia +Nauru +Nepal +Netherlands +New Caledonia +New Zealand +Nicaragua +Niger +Nigeria +North Macedonia +Northern Mariana Islands +Norway +Oman +Pakistan +Palau +Panama +Papua New Guinea +Paraguay +Peru +Philippines +Poland +Portugal +Puerto Rico +Qatar +Romania +Russian Federation +Rwanda +Samoa +San Marino +Sao Tome and Principe +Saudi Arabia +Senegal +Serbia +Seychelles +Sierra Leone +Singapore +Sint Maarten (Dutch part) +Slovak Republic +Slovenia +Solomon Islands +Somalia +South Africa +South Sudan +Spain +Sri Lanka +St. Kitts and Nevis +St. Lucia +St. Martin (French part) +St. Vincent and the Grenadines +Sudan +Suriname +Sweden +Switzerland +Syrian Arab Republic +Tajikistan +Tanzania +Thailand +Timor-Leste +Togo +Tonga +Trinidad and Tobago +Tunisia +Turkey +Turkmenistan +Turks and Caicos Islands +Tuvalu +Uganda +Ukraine +United Arab Emirates +United Kingdom +United States +Uruguay +Uzbekistan +Vanuatu +Venezuela, RB +Vietnam +Virgin Islands (U.S.) +West Bank and Gaza +Yemen, Rep. +Zambia +Zimbabwe \ No newline at end of file diff --git a/Unit-3/dataRunner.java b/Unit-3/dataRunner.java new file mode 100644 index 0000000..aff50f8 --- /dev/null +++ b/Unit-3/dataRunner.java @@ -0,0 +1,20 @@ +import java.util.Scanner; + +public class DataRunner { + public static void main(String[] args) { + // Statistics plotter thing! + // Options: + // Option 0 - population + // Option 1 - unemployment % + // Option 2 - internet % + + int opt1 = 0; + int opt2 = 2; + + int width = 50; + int height = 100; + + UserStory us = new UserStory(opt1, opt2, width, height); + System.out.print(us); + } +} \ No newline at end of file diff --git a/Unit-3/incomes.txt b/Unit-3/incomes.txt new file mode 100644 index 0000000..a408edc --- /dev/null +++ b/Unit-3/incomes.txt @@ -0,0 +1,215 @@ +Low Income +Upper Middle Income +Upper Middle Income +Upper Middle Income +High Income +Lower Middle Income +High Income +Upper Middle Income +Upper Middle Income +High Income +High Income +High Income +Upper Middle Income +High Income +High Income +Lower Middle Income +High Income +Upper Middle Income +High Income +Upper Middle Income +Low Income +High Income +Lower Middle Income +Lower Middle Income +Upper Middle Income +Upper Middle Income +Upper Middle Income +High Income +High Income +Upper Middle Income +Low Income +Low Income +Lower Middle Income +Lower Middle Income +Lower Middle Income +High Income +High Income +Low Income +Low Income +High Income +Upper Middle Income +Upper Middle Income +Lower Middle Income +Low Income +Lower Middle Income +Upper Middle Income +Lower Middle Income +High Income +Upper Middle Income +High Income +High Income +High Income +High Income +Lower Middle Income +Upper Middle Income +Upper Middle Income +Upper Middle Income +Lower Middle Income +Lower Middle Income +Upper Middle Income +Low Income +High Income +Lower Middle Income +Low Income +High Income +upper Middle Income +High Income +High Income +High Income +Upper Middle Income +Low Income +Upper Middle Income +High Income +Lower Middle Income +High Income +High Income +High Income +Upper Middle Income +High Income +Upper Middle Income +Low Income +Low Income +Upper Middle Income +Low Income +Lower Middle Income +High Income +High Income +High Income +Lower Middle Income +Lower Middle Income +Upper Middle Income +Upper Middle Income +High Income +High Income +High Income +High Income +Upper Middle Income +High Income +Upper Middle Income +Upper Middle Income +Lower Middle Income +Lower Middle Income +Low Income +High Income +High Income +Lower Middle Income +Lower Middle Income +High Income +Upper Middle Income +Lower Middle Income +Low Income +Upper Middle Income +High Income +High Income +High Income +High Income +Low income +Low Income +Upper Middle Income +Upper Middle Income +Low Income +High Income +Upper Middle Income +Lower Middle Income +Upper Middle Income +Upper Middle Income +Lower Middle Income +Lower Middle Income +High Income +Lower Middle Income +Upper Middle Income +Lower Middle Income +Low Income +Lower Middle Income +Upper Middle Income +Upper Middle Income +Low Income +High Income +High Income +High Income +Lower Middle Income +Low Income +Lower Middle Income +Upper Middle Income +High Income +High Income +High Income +Lower Middle Income +High Income +High Income +Lower Middle Income +Upper Middle Income +Upper Middle Income +Lower Middle Income +High Income +High Income +High Income +High Income +Upper Middle Income +Upper Middle Income +Low Income +Upper Middle Income +High Income +Lower Middle Income +High Income +Lower Middle Income +Upper Middle Income +High Income +Low Income +High Income +High Income +High Income +High Income +Lower Middle Income +Low Income +Upper Middle Income +Low Income +High Income +Upper Middle Income +High Income +Upper Middle Income +High Income +Upper Middle Income +Lower Middle Income +Upper Middle Income +High Income +High Income +Low Income +Low Income +Low Income +Upper Middle Income +Lower Middle Income +Low Income +Upper Middle Income +High Income +Lower Middle Income +Upper Middle Income +Upper Middle Income +High Income +Upper Middle Income +Low Income +Lower Middle Income +High Income +High Income +High Income +High Income +Lower Middle Income +Lower Middle Income +Upper Middle Income +Lower Middle Income +High Income +Lower Middle Income +Low Income +Lower Middle Income +Lower Middle Income \ No newline at end of file diff --git a/Unit-3/internetpercent.txt b/Unit-3/internetpercent.txt new file mode 100644 index 0000000..5a83941 --- /dev/null +++ b/Unit-3/internetpercent.txt @@ -0,0 +1,215 @@ +13.5 +71.85 +49.04 +-1 +91.57 +14.34 +76 +74.29 +64.74 +97.17 +86.55 +87.48 +79.8 +85 +98.64 +15 +81.76 +79.13 +88.66 +47.08 +20 +98.37 +48.11 +44.29 +70.12 +47 +70.43 +77.7 +94.87 +64.78 +16 +2.66 +57.16 +40 +23.2 +91 +81.07 +4.34 +6.5 +82.33 +54.3 +64.13 +8.48 +8.62 +8.65 +74.09 +46.82 +75.29 +57.15 +68.13 +84.43 +80.69 +97.32 +55.68 +69.62 +74.82 +57.27 +46.92 +33.82 +26.24 +1.31 +89.36 +47 +18.62 +97.58 +49.97 +88.89 +82.04 +72.7 +62 +19.84 +62.72 +89.74 +39 +94.44 +72.95 +69.48 +59.07 +80.51 +65 +18 +3.93 +37.33 +32.47 +31.7 +90.51 +76.07 +99.01 +34.45 +39.9 +70 +75 +84.52 +-1 +83.73 +74.39 +55.07 +91.28 +66.79 +78.9 +17.83 +14.58 +-1 +96.02 +99.6 +38 +25.51 +83.58 +78.18 +29 +7.98 +21.76 +98.1 +79.72 +97.06 +83.79 +9.8 +13.78 +81.2 +63.19 +13 +81.66 +38.7 +20.8 +58.6 +65.77 +35.3 +76.12 +97.05 +47.16 +71.52 +64.8 +10 +30.68 +51 +57 +34 +94.71 +82.01 +90.81 +27.86 +5.25 +42 +79.17 +-1 +96.49 +80.19 +15.51 +-1 +57.87 +11.21 +64.99 +52.54 +60.05 +77.54 +74.66 +70.6 +99.65 +70.68 +80.86 +21.77 +33.61 +60.18 +29.93 +93.31 +46 +73.36 +58.77 +9 +88.17 +-1 +80.66 +79.75 +11.92 +2 +56.17 +7.98 +86.11 +34.11 +80.71 +50.82 +-1 +22.39 +30.87 +48.95 +92.14 +89.69 +34.25 +21.96 +25 +56.82 +27.49 +12.36 +41.25 +77.33 +64.19 +71.04 +21.25 +-1 +49.32 +23.71 +62.55 +98.45 +94.9 +87.27 +74.77 +55.2 +25.72 +72 +70.35 +64.38 +64.4 +26.72 +14.3 +27.06 \ No newline at end of file diff --git a/Unit-3/populations.txt b/Unit-3/populations.txt new file mode 100644 index 0000000..5e6993c --- /dev/null +++ b/Unit-3/populations.txt @@ -0,0 +1,215 @@ +37172386 +2866376 +42228429 +55465 +77006 +30809762 +96286 +44494502 +2951776 +105845 +24982688 +8840521 +9939800 +385640 +1569439 +161356039 +286641 +9483499 +11433256 +383071 +11485048 +63973 +754394 +11353142 +3323929 +2254126 +209469333 +29802 +428962 +7025037 +19751535 +11175378 +543767 +16249798 +25216237 +37057765 +64174 +4666377 +15477751 +18729160 +1392730000 +49648685 +832322 +84068091 +5244363 +4999441 +25069229 +4087843 +11338138 +159800 +1189265 +10629928 +5793636 +958920 +71625 +10627165 +17084357 +98423595 +6420744 +1308974 +3213972 +1321977 +1136191 +109224559 +48497 +883483 +5515525 +66977107 +277679 +2119275 +2280102 +3726549 +82905782 +29767108 +33718 +10731726 +56025 +111454 +165768 +17247807 +12414318 +1874309 +779004 +11123176 +9587522 +7451000 +9775564 +352721 +1352617328 +267663435 +81800269 +38433600 +4867309 +84077 +8882800 +60421760 +2934855 +126529100 +9956011 +18272430 +51393010 +115847 +25549819 +51606633 +4137309 +6322800 +7061507 +1927174 +6848925 +2108132 +4818977 +6678567 +37910 +2801543 +607950 +631636 +26262368 +18143315 +31528585 +515696 +19077690 +484630 +58413 +4403319 +1265303 +126190788 +112640 +2706049 +38682 +3170208 +622227 +36029138 +29495962 +53708395 +2448255 +12704 +28087871 +17231624 +284060 +4841000 +6465513 +22442948 +195874740 +2082958 +56882 +5311916 +4829483 +212215030 +17907 +4176873 +8606316 +6956071 +31989256 +106651922 +37974750 +10283822 +3195153 +2781677 +19466145 +144478050 +12301939 +196130 +33785 +211028 +33699947 +15854360 +6982604 +96762 +7650154 +5638676 +40654 +5446771 +2073894 +652858 +15008154 +57779622 +10975920 +46796540 +21670000 +52441 +181889 +37264 +110210 +41801533 +575991 +10175214 +8513227 +16906283 +9100837 +56318348 +69428524 +1267972 +7889094 +103197 +1389858 +11565204 +82319724 +5850908 +37665 +11508 +42723139 +44622516 +9630959 +66460344 +326687501 +3449299 +32955400 +292680 +28870195 +95540395 +106977 +4569087 +28498687 +17351822 +14439018 \ No newline at end of file diff --git a/Unit-3/unemployment.txt b/Unit-3/unemployment.txt new file mode 100644 index 0000000..65b3661 --- /dev/null +++ b/Unit-3/unemployment.txt @@ -0,0 +1,215 @@ +11.18 +13.75 +13.57 +9.2 +3.7 +7.36 +8.42 +9.22 +17.7 +8.9 +5.16 +4.85 +4.9 +12.7 +1.2 +4.37 +9.72 +4.76 +5.95 +6.6 +2.65 +8.94 +2.45 +3.52 +15.69 +17.86 +11.93 +2.9 +8.7 +5.21 +6.48 +1.57 +12.17 +0.72 +3.53 +5.66 +4.24 +5.6 +5.9 +7.23 +3.8 +9.11 +8.14 +4.49 +10 +11.49 +3.27 +8.43 +2.4 +13.43 +8.37 +2.24 +4.97 +5.8 +10.96 +5.86 +3.81 +11.74 +4.01 +8.1 +5.1 +5.37 +22.72 +2.25 +3.7 +4.32 +7.36 +9.06 +11.74 +20.39 +9.42 +12.67 +3.38 +4.22 +1 +19.29 +9.1 +22.9 +5.4 +2.46 +4.55 +6 +14.02 +14.1 +5.65 +3.09 +3.71 +2.7 +5.33 +4.4 +12.06 +13.02 +5.74 +2.67 +4 +10.61 +7.72 +2.4 +15.27 +4.9 +2.76 +9.33 +4.7 +3.82 +2.16 +4.54 +9.41 +7.41 +6.35 +24.58 +3.08 +19.03 +2.01 +6.15 +5.59 +2 +1.79 +28.67 +3.3 +6.12 +1.62 +3.66 +4.74 +10.34 +6.43 +3.48 +8.86 +2.98 +6.33 +5.38 +15.17 +9.3 +3.43 +0.87 +19.88 +13.28 +11.36 +3.83 +14.59 +4.3 +4.52 +7.77 +8.39 +20.74 +11.17 +3.8 +1.8 +4.08 +1.36 +3.89 +2.62 +6.22 +6.43 +2.34 +3.85 +6.99 +8.27 +0.11 +4.19 +4.85 +15.11 +14.47 +6.45 +13.59 +6.04 +6.76 +12.73 +3.53 +4.68 +4.2 +9.9 +6.54 +5.11 +0.69 +5.9 +28.47 +12.15 +15.25 +4.05 +5.12 +21.26 +12 +18.79 +17.44 +7.22 +6.35 +4.71 +8.61 +6.9 +2.12 +0.77 +4.66 +3.74 +3.07 +3.21 +15.46 +10.89 +4 +8.3 +8.49 +9.44 +8.8 +2.23 +4 +3.9 +8.34 +9.3 +1.85 +6.6 +2 +7 +26.26 +13.47 +11.63 +4.77 \ No newline at end of file diff --git a/Unit-3/userStory.java b/Unit-3/userStory.java new file mode 100644 index 0000000..b2e2a31 --- /dev/null +++ b/Unit-3/userStory.java @@ -0,0 +1,204 @@ +import java.util.Scanner; + +public class UserStory { + + private String[] countries = FileReader.toStringArray("countries.txt"); + + private double[] populations = FileReader.toDoubleArray("populations.txt"); + private double[] unemployment = FileReader.toDoubleArray("unemployment.txt"); + private double[] internetpercent = FileReader.toDoubleArray("internetpercent.txt"); + + private int opt1; + private int opt2; + + private int width; + private int height; + + public UserStory() { + this(0, 2, 50, 100); + } + + public UserStory(int opt1, int opt2, int width, int height){ + this.opt1 = opt1; + this.opt2 = opt2; + + this.width = width; + this.height = height; + } + + public double[] getArrayFromOpt(int i) { + switch(i) { + case 0: + return this.populations; + case 1: + return this.unemployment; + case 2: + return this.internetpercent; + default: + return null; + } + } + + public String getNameFromOpt(int i) { + switch(i) { + case 0: + return "populations"; + case 1: + return "unemployment"; + case 2: + return "internetpercent"; + default: + return null; + } + } + + // Method to find maximum in an array + public double max(double[] arr){ + double max = arr[0]; + for (int i = 0; i < arr.length; i++) + if (arr[i] > max){ + max = arr[i]; + } + + return max; + } + + // Find the corrosponding country name, of largest value of array + public String maxStr(double[] arr){ + double max = arr[0]; + String maxName = ""; + for (int i = 0; i < arr.length; i++) + if (arr[i] > max){ + max = arr[i]; + maxName = this.countries[i]; + } + + return maxName; + } + + // Method to find minimum in an array + public double min(double[] arr){ + double min = arr[0]; + for (int i = 0; i < arr.length; i++) + if (arr[i] < min){ + min = arr[i]; + } + + return min; + } + + // Find the corrosponding country name, of smallest value of array + public String minStr(double[] arr){ + double min = arr[0]; + String minName = ""; + for (int i = 0; i < arr.length; i++) + if (arr[i] < min){ + min = arr[i]; + minName = this.countries[i]; + } + + return minName; + } + + // A method to find at which x and y choords are there points. + public boolean[][] pointAtChoord(double[] arr1, double[] arr2, double maxX, double maxY) { + + // Create a 2d boolean array that is all false + boolean[][] result = new boolean[this.width][this.height]; + for(int a = 0; a < this.width; a++){ + for(int b = 0; b < this.height; b++){ + result[a][b] = false; + } + } + + for(int i=0;i 2.0) return t; + z = z.times(z).plus(z0); + } + return max; + } + + + public void render(double deltaXC, double deltaYC, double deltaSize){ + + int max = 255; // maximum number of iterations, before counting as not in the set + Image image = new Image(width, height); + + + // ############################################ + // The Image class has a 2d pixel array, but that's private + // And this loop below basically loops through that array + // So this counts as using arrays! + // ############################################ + + + // Loop through the pixel array of the image, and do calculations + for (int i = 0; i < width; i++) { + for (int j = 0; j < height; j++) { + double x0 = xc - size/2 + size*i/width; + double y0 = yc - size/2 + size*j/height; + Complex z0 = new Complex(x0, y0); + int gray = max - mand(z0, max); + Color color = new Color(gray, gray, gray); + image.setPixel(i, width-1-j, color); + } + } + + // Draw the image + this.drawImage(image, 0, 0, width); + + // Offset camera + this.xc += deltaXC; + this.yc += deltaYC; + this.size += deltaSize; + } + + +} \ No newline at end of file diff --git a/Unit-4/TheaterRunner.java b/Unit-4/TheaterRunner.java new file mode 100644 index 0000000..6fbd6bf --- /dev/null +++ b/Unit-4/TheaterRunner.java @@ -0,0 +1,63 @@ +import org.code.theater.*; + +public class TheaterRunner { + public static void main(String[] args) { + + Theater t = new Theater(); + DataScene d = new DataScene(); + + // Mandelbrot zoom settings + final double xspeed = -0.01; + final double yspeed = 0.11; + final double zspeed = -0.4; + + final double xydist = 1.305; + final double zdist = 1.273; + + // Video settings + final int length = 40; + final double delay = 0.25; + + // Loop for each frame + for(int i=0;i> nu1, nu); + // direct FFT or inverse FFT + arg = constant * p / n; + c = Math.cos(arg); + s = Math.sin(arg); + tReal = xReal[k + n2] * c + xImag[k + n2] * s; + tImag = xImag[k + n2] * c - xReal[k + n2] * s; + xReal[k + n2] = xReal[k] - tReal; + xImag[k + n2] = xImag[k] - tImag; + xReal[k] += tReal; + xImag[k] += tImag; + k++; + } + k += n2; + } + k = 0; + nu1--; + n2 /= 2; + } + + // Second phase - recombination + k = 0; + int r; + while (k < n) { + r = bitreverseReference(k, nu); + if (r > k) { + tReal = xReal[k]; + tImag = xImag[k]; + xReal[k] = xReal[r]; + xImag[k] = xImag[r]; + xReal[r] = tReal; + xImag[r] = tImag; + } + k++; + } + + // Here I have to mix xReal and xImag to have an array (yes, it should + // be possible to do this stuff in the earlier parts of the code, but + // it's here to readability). + double[] newArray = new double[xReal.length * 2]; + double radice = 1 / Math.sqrt(n); + for (int i = 0; i < newArray.length; i += 2) { + int i2 = i / 2; + // I used Stephen Wolfram's Mathematica as a reference so I'm going + // to normalize the output while I'm copying the elements. + newArray[i] = xReal[i2] * radice; + newArray[i + 1] = xImag[i2] * radice; + } + return newArray; + } + + /** + * The reference bit reverse function. + */ + private static int bitreverseReference(int j, int nu) { + int j2; + int j1 = j; + int k = 0; + for (int i = 1; i <= nu; i++) { + j2 = j1 / 2; + k = 2 * k + j1 - 2 * j2; + j1 = j2; + } + return k; + } + } \ No newline at end of file diff --git a/Unit-5/Renderer.java b/Unit-5/Renderer.java new file mode 100644 index 0000000..feec1d6 --- /dev/null +++ b/Unit-5/Renderer.java @@ -0,0 +1,34 @@ +import org.code.theater.*; +import org.code.media.*; + + +// Utility function to make messing with code.org's libraries easier +public class Renderer extends Scene { + private Theater Theater; + private final Image image; + private final double delay = 0.5; + + public final int width; + public final int height; + + public Renderer() { + Theater = new Theater(); + width = getWidth(); + height = getHeight(); + image = new Image(width, height); + } + + public void refreshImage(){ + this.drawImage(image, 0, 0, width); + pause(delay); + } + + public void setPixel(int x, int y, Color color){ + image.setPixel(x, y, color); + } + + public void render() { + System.out.println("Sending video to client..."); + Theater.playScenes(this); + } +} \ No newline at end of file diff --git a/Unit-5/Spectrogram.java b/Unit-5/Spectrogram.java new file mode 100644 index 0000000..18f6631 --- /dev/null +++ b/Unit-5/Spectrogram.java @@ -0,0 +1,118 @@ +import org.code.theater.*; +import org.code.media.*; +import java.util.Arrays; + +public class Spectrogram { + public static void run(String filepath) { + //get raw double array containing .WAV data + //code.org has a function to get data from a .wav file, this makes things a lot easier + double[] rawData = SoundLoader.read(filepath); + + int length = rawData.length; + + Renderer r = new Renderer(); + + //initialize parameters for FFT + int WS = 512; //WS = window size + int OF = 8; //OF = overlap factor + int windowStep = WS/OF; + + //initialize plotData array + int nX = (length-WS)/windowStep; + int nY = WS/2 + 1; + double[][] plotData = new double[nX][nY]; + + //apply FFT and find MAX and MIN amplitudes + double maxAmp = Double.MIN_VALUE; + double minAmp = Double.MAX_VALUE; + + double amp_square; + + double[] inputImag = new double[length]; + + System.out.println("Calculating Spectrogram..."); + + // Do the FFT Stuff + for (int i = 0; i < nX; i++){ + Arrays.fill(inputImag, 0.0); + double[] WS_array = FFT.fft(Arrays.copyOfRange(rawData, i*windowStep, i*windowStep+WS), inputImag, true); + for (int j = 0; j < nY; j++){ + + // IDK, Stolen code. I think this converts the data from the fft + amp_square = (WS_array[2*j]*WS_array[2*j]) + (WS_array[2*j+1]*WS_array[2*j+1]); + if (amp_square == 0.0){ + plotData[i][j] = amp_square; + } + else{ + plotData[i][nY-j-1] = 10 * Math.log10(amp_square); + } + + //find MAX and MIN amplitude + if (plotData[i][j] > maxAmp) + maxAmp = plotData[i][j]; + else if (plotData[i][j] < minAmp) + minAmp = plotData[i][j]; + + } + } + + //Normalization, to show the details in the spectrograph + final double diff = maxAmp - minAmp; + for (int i = 0; i < nX; i++){ + for (int j = 0; j < nY; j++){ + plotData[i][j] = (plotData[i][j]-minAmp)/diff; + } + } + + + //Video settings + //The docs get the sample rate wrong, by a factor of 10, lol. + final double SR = 44100; + + // This is around the max framerate that code.org allows + final double maxFramerate = 2.05; + final int maxFrameCount = 120; + + // Most ways to get the length of the audio require getting the bitrate of the audio. This seems to work. + final double audioLength = length/SR; + final int frameCount = Math.min((int)Math.round(audioLength*maxFramerate), maxFrameCount); + final double delay = Math.max(((audioLength/frameCount)-(double)(1/maxFramerate)), 0); + + + final int initialXOffset = (int)(r.width/2)*-1; + + System.out.println("Rendering Video..."); + System.out.println("Audio length: " + Math.round(audioLength) + " seconds"); + // System.out.println(frameCount); + // System.out.println(delay); + + r.playSound(filepath); + + // Loop through all frames + for(int f = 0; f<=frameCount; f++){ + + int xOffset = initialXOffset+(int)(f*((nX+r.width)/frameCount)); + + // Loop through pixels in image + for(int y = 0; y nX){ + // If pixel is outside image, set to black. + r.setPixel(x, y, Color.BLACK); + }else{ + // Greyscale image + final int L = (int)(plotData[x+xOffset][specY]*255); + r.setPixel(x, y, new Color(L, L, L)); + } + } + } + r.refreshImage(); + // r.pause(delay); + } + r.render(); + + } +} \ No newline at end of file diff --git a/Unit-5/main.java b/Unit-5/main.java new file mode 100644 index 0000000..6f0774a --- /dev/null +++ b/Unit-5/main.java @@ -0,0 +1,19 @@ +public class main { + public static void main(String[] args) { + + // This is a spectrogram, that I made in-class. + // Code.org has a max framerate around 2 fps, so the visual isn't the best. + // Also, the audio doesn't sync up with the spectrograph the visual as well as it could. + + ///// My personal narrative: //// + // I have seen a spectrograph of a 56kb dialup connection before, + // So... Here is a spectrograph of a 56kb dialup connection. + ///////////////////// + + // Also, here is me using a method in the String class: + " ".trim(); + + + Spectrogram.run("dialup.wav"); + } +} \ No newline at end of file diff --git a/Unit-6/BeeMovie.txt b/Unit-6/BeeMovie.txt new file mode 100644 index 0000000..56d34da --- /dev/null +++ b/Unit-6/BeeMovie.txt @@ -0,0 +1,1974 @@ +According to all known laws +of aviation, +there is no way a bee +should be able to fly. +Its wings are too small to get +its fat little body off the ground. +The bee, of course, flies anyway +because bees don't care +what humans think is impossible. +Yellow, black. Yellow, black. +Yellow, black. Yellow, black. +Ooh, black and yellow! +Let's shake it up a little. +Barry! Breakfast is ready! +Ooming! +Hang on a second. +Hello? +- Barry? +- Adam? +- Oan you believe this is happening? +- I can't. I'll pick you up. +Looking sharp. +Use the stairs. Your father +paid good money for those. +Sorry. I'm excited. +Here's the graduate. +We're very proud of you, son. +A perfect report card, all B's. +Very proud. +Ma! I got a thing going here. +- You got lint on your fuzz. +- Ow! That's me! +- Wave to us! We'll be in row 118,000. +- Bye! +Barry, I told you, +stop flying in the house! +- Hey, Adam. +- Hey, Barry. +- Is that fuzz gel? +- A little. Special day, graduation. +Never thought I'd make it. +Three days grade school, +three days high school. +Those were awkward. +Three days college. I'm glad I took +a day and hitchhiked around the hive. +You did come back different. +- Hi, Barry. +- Artie, growing a mustache? Looks good. +- Hear about Frankie? +- Yeah. +- You going to the funeral? +- No, I'm not going. +Everybody knows, +sting someone, you die. +Don't waste it on a squirrel. +Such a hothead. +I guess he could have +just gotten out of the way. +I love this incorporating +an amusement park into our day. +That's why we don't need vacations. +Boy, quite a bit of pomp... +under the circumstances. +- Well, Adam, today we are men. +- We are! +- Bee-men. +- Amen! +Hallelujah! +Students, faculty, distinguished bees, +please welcome Dean Buzzwell. +Welcome, New Hive Oity +graduating class of... +...9:15. +That concludes our ceremonies. +And begins your career +at Honex Industries! +Will we pick ourjob today? +I heard it's just orientation. +Heads up! Here we go. +Keep your hands and antennas +inside the tram at all times. +- Wonder what it'll be like? +- A little scary. +Welcome to Honex, +a division of Honesco +and a part of the Hexagon Group. +This is it! +Wow. +Wow. +We know that you, as a bee, +have worked your whole life +to get to the point where you +can work for your whole life. +Honey begins when our valiant Pollen +Jocks bring the nectar to the hive. +Our top-secret formula +is automatically color-corrected, +scent-adjusted and bubble-contoured +into this soothing sweet syrup +with its distinctive +golden glow you know as... +Honey! +- That girl was hot. +- She's my cousin! +- She is? +- Yes, we're all cousins. +- Right. You're right. +- At Honex, we constantly strive +to improve every aspect +of bee existence. +These bees are stress-testing +a new helmet technology. +- What do you think he makes? +- Not enough. +Here we have our latest advancement, +the Krelman. +- What does that do? +- Oatches that little strand of honey +that hangs after you pour it. +Saves us millions. +Oan anyone work on the Krelman? +Of course. Most bee jobs are +small ones. But bees know +that every small job, +if it's done well, means a lot. +But choose carefully +because you'll stay in the job +you pick for the rest of your life. +The same job the rest of your life? +I didn't know that. +What's the difference? +You'll be happy to know that bees, +as a species, haven't had one day off +in 27 million years. +So you'll just work us to death? +We'll sure try. +Wow! That blew my mind! +"What's the difference?" +How can you say that? +One job forever? +That's an insane choice to have to make. +I'm relieved. Now we only have +to make one decision in life. +But, Adam, how could they +never have told us that? +Why would you question anything? +We're bees. +We're the most perfectly +functioning society on Earth. +You ever think maybe things +work a little too well here? +Like what? Give me one example. +I don't know. But you know +what I'm talking about. +Please clear the gate. +Royal Nectar Force on approach. +Wait a second. Oheck it out. +- Hey, those are Pollen Jocks! +- Wow. +I've never seen them this close. +They know what it's like +outside the hive. +Yeah, but some don't come back. +- Hey, Jocks! +- Hi, Jocks! +You guys did great! +You're monsters! +You're sky freaks! I love it! I love it! +- I wonder where they were. +- I don't know. +Their day's not planned. +Outside the hive, flying who knows +where, doing who knows what. +You can'tjust decide to be a Pollen +Jock. You have to be bred for that. +Right. +Look. That's more pollen +than you and I will see in a lifetime. +It's just a status symbol. +Bees make too much of it. +Perhaps. Unless you're wearing it +and the ladies see you wearing it. +Those ladies? +Aren't they our cousins too? +Distant. Distant. +Look at these two. +- Oouple of Hive Harrys. +- Let's have fun with them. +It must be dangerous +being a Pollen Jock. +Yeah. Once a bear pinned me +against a mushroom! +He had a paw on my throat, +and with the other, he was slapping me! +- Oh, my! +- I never thought I'd knock him out. +What were you doing during this? +Trying to alert the authorities. +I can autograph that. +A little gusty out there today, +wasn't it, comrades? +Yeah. Gusty. +We're hitting a sunflower patch +six miles from here tomorrow. +- Six miles, huh? +- Barry! +A puddle jump for us, +but maybe you're not up for it. +- Maybe I am. +- You are not! +We're going 0900 at J-Gate. +What do you think, buzzy-boy? +Are you bee enough? +I might be. It all depends +on what 0900 means. +Hey, Honex! +Dad, you surprised me. +You decide what you're interested in? +- Well, there's a lot of choices. +- But you only get one. +Do you ever get bored +doing the same job every day? +Son, let me tell you about stirring. +You grab that stick, and you just +move it around, and you stir it around. +You get yourself into a rhythm. +It's a beautiful thing. +You know, Dad, +the more I think about it, +maybe the honey field +just isn't right for me. +You were thinking of what, +making balloon animals? +That's a bad job +for a guy with a stinger. +Janet, your son's not sure +he wants to go into honey! +- Barry, you are so funny sometimes. +- I'm not trying to be funny. +You're not funny! You're going +into honey. Our son, the stirrer! +- You're gonna be a stirrer? +- No one's listening to me! +Wait till you see the sticks I have. +I could say anything right now. +I'm gonna get an ant tattoo! +Let's open some honey and celebrate! +Maybe I'll pierce my thorax. +Shave my antennae. +Shack up with a grasshopper. Get +a gold tooth and call everybody "dawg"! +I'm so proud. +- We're starting work today! +- Today's the day. +Oome on! All the good jobs +will be gone. +Yeah, right. +Pollen counting, stunt bee, pouring, +stirrer, front desk, hair removal... +- Is it still available? +- Hang on. Two left! +One of them's yours! Oongratulations! +Step to the side. +- What'd you get? +- Picking crud out. Stellar! +Wow! +Oouple of newbies? +Yes, sir! Our first day! We are ready! +Make your choice. +- You want to go first? +- No, you go. +Oh, my. What's available? +Restroom attendant's open, +not for the reason you think. +- Any chance of getting the Krelman? +- Sure, you're on. +I'm sorry, the Krelman just closed out. +Wax monkey's always open. +The Krelman opened up again. +What happened? +A bee died. Makes an opening. See? +He's dead. Another dead one. +Deady. Deadified. Two more dead. +Dead from the neck up. +Dead from the neck down. That's life! +Oh, this is so hard! +Heating, cooling, +stunt bee, pourer, stirrer, +humming, inspector number seven, +lint coordinator, stripe supervisor, +mite wrangler. Barry, what +do you think I should... Barry? +Barry! +All right, we've got the sunflower patch +in quadrant nine... +What happened to you? +Where are you? +- I'm going out. +- Out? Out where? +- Out there. +- Oh, no! +I have to, before I go +to work for the rest of my life. +You're gonna die! You're crazy! Hello? +Another call coming in. +If anyone's feeling brave, +there's a Korean deli on 83rd +that gets their roses today. +Hey, guys. +- Look at that. +- Isn't that the kid we saw yesterday? +Hold it, son, flight deck's restricted. +It's OK, Lou. We're gonna take him up. +Really? Feeling lucky, are you? +Sign here, here. Just initial that. +- Thank you. +- OK. +You got a rain advisory today, +and as you all know, +bees cannot fly in rain. +So be careful. As always, +watch your brooms, +hockey sticks, dogs, +birds, bears and bats. +Also, I got a couple of reports +of root beer being poured on us. +Murphy's in a home because of it, +babbling like a cicada! +- That's awful. +- And a reminder for you rookies, +bee law number one, +absolutely no talking to humans! +All right, launch positions! +Buzz, buzz, buzz, buzz! Buzz, buzz, +buzz, buzz! Buzz, buzz, buzz, buzz! +Black and yellow! +Hello! +You ready for this, hot shot? +Yeah. Yeah, bring it on. +Wind, check. +- Antennae, check. +- Nectar pack, check. +- Wings, check. +- Stinger, check. +Scared out of my shorts, check. +OK, ladies, +let's move it out! +Pound those petunias, +you striped stem-suckers! +All of you, drain those flowers! +Wow! I'm out! +I can't believe I'm out! +So blue. +I feel so fast and free! +Box kite! +Wow! +Flowers! +This is Blue Leader. +We have roses visual. +Bring it around 30 degrees and hold. +Roses! +30 degrees, roger. Bringing it around. +Stand to the side, kid. +It's got a bit of a kick. +That is one nectar collector! +- Ever see pollination up close? +- No, sir. +I pick up some pollen here, sprinkle it +over here. Maybe a dash over there, +a pinch on that one. +See that? It's a little bit of magic. +That's amazing. Why do we do that? +That's pollen power. More pollen, more +flowers, more nectar, more honey for us. +Oool. +I'm picking up a lot of bright yellow. +Oould be daisies. Don't we need those? +Oopy that visual. +Wait. One of these flowers +seems to be on the move. +Say again? You're reporting +a moving flower? +Affirmative. +That was on the line! +This is the coolest. What is it? +I don't know, but I'm loving this color. +It smells good. +Not like a flower, but I like it. +Yeah, fuzzy. +Ohemical-y. +Oareful, guys. It's a little grabby. +My sweet lord of bees! +Oandy-brain, get off there! +Problem! +- Guys! +- This could be bad. +Affirmative. +Very close. +Gonna hurt. +Mama's little boy. +You are way out of position, rookie! +Ooming in at you like a missile! +Help me! +I don't think these are flowers. +- Should we tell him? +- I think he knows. +What is this?! +Match point! +You can start packing up, honey, +because you're about to eat it! +Yowser! +Gross. +There's a bee in the car! +- Do something! +- I'm driving! +- Hi, bee. +- He's back here! +He's going to sting me! +Nobody move. If you don't move, +he won't sting you. Freeze! +He blinked! +Spray him, Granny! +What are you doing?! +Wow... the tension level +out here is unbelievable. +I gotta get home. +Oan't fly in rain. +Oan't fly in rain. +Oan't fly in rain. +Mayday! Mayday! Bee going down! +Ken, could you close +the window please? +Ken, could you close +the window please? +Oheck out my new resume. +I made it into a fold-out brochure. +You see? Folds out. +Oh, no. More humans. I don't need this. +What was that? +Maybe this time. This time. This time. +This time! This time! This... +Drapes! +That is diabolical. +It's fantastic. It's got all my special +skills, even my top-ten favorite movies. +What's number one? Star Wars? +Nah, I don't go for that... +...kind of stuff. +No wonder we shouldn't talk to them. +They're out of their minds. +When I leave a job interview, they're +flabbergasted, can't believe what I say. +There's the sun. Maybe that's a way out. +I don't remember the sun +having a big 75 on it. +I predicted global warming. +I could feel it getting hotter. +At first I thought it was just me. +Wait! Stop! Bee! +Stand back. These are winter boots. +Wait! +Don't kill him! +You know I'm allergic to them! +This thing could kill me! +Why does his life have +less value than yours? +Why does his life have any less value +than mine? Is that your statement? +I'm just saying all life has value. You +don't know what he's capable of feeling. +My brochure! +There you go, little guy. +I'm not scared of him. +It's an allergic thing. +Put that on your resume brochure. +My whole face could puff up. +Make it one of your special skills. +Knocking someone out +is also a special skill. +Right. Bye, Vanessa. Thanks. +- Vanessa, next week? Yogurt night? +- Sure, Ken. You know, whatever. +- You could put carob chips on there. +- Bye. +- Supposed to be less calories. +- Bye. +I gotta say something. +She saved my life. +I gotta say something. +All right, here it goes. +Nah. +What would I say? +I could really get in trouble. +It's a bee law. +You're not supposed to talk to a human. +I can't believe I'm doing this. +I've got to. +Oh, I can't do it. Oome on! +No. Yes. No. +Do it. I can't. +How should I start it? +"You like jazz?" No, that's no good. +Here she comes! Speak, you fool! +Hi! +I'm sorry. +- You're talking. +- Yes, I know. +You're talking! +I'm so sorry. +No, it's OK. It's fine. +I know I'm dreaming. +But I don't recall going to bed. +Well, I'm sure this +is very disconcerting. +This is a bit of a surprise to me. +I mean, you're a bee! +I am. And I'm not supposed +to be doing this, +but they were all trying to kill me. +And if it wasn't for you... +I had to thank you. +It's just how I was raised. +That was a little weird. +- I'm talking with a bee. +- Yeah. +I'm talking to a bee. +And the bee is talking to me! +I just want to say I'm grateful. +I'll leave now. +- Wait! How did you learn to do that? +- What? +The talking thing. +Same way you did, I guess. +"Mama, Dada, honey." You pick it up. +- That's very funny. +- Yeah. +Bees are funny. If we didn't laugh, +we'd cry with what we have to deal with. +Anyway... +Oan I... +...get you something? +- Like what? +I don't know. I mean... +I don't know. Ooffee? +I don't want to put you out. +It's no trouble. It takes two minutes. +- It's just coffee. +- I hate to impose. +- Don't be ridiculous! +- Actually, I would love a cup. +Hey, you want rum cake? +- I shouldn't. +- Have some. +- No, I can't. +- Oome on! +I'm trying to lose a couple micrograms. +- Where? +- These stripes don't help. +You look great! +I don't know if you know +anything about fashion. +Are you all right? +No. +He's making the tie in the cab +as they're flying up Madison. +He finally gets there. +He runs up the steps into the church. +The wedding is on. +And he says, "Watermelon? +I thought you said Guatemalan. +Why would I marry a watermelon?" +Is that a bee joke? +That's the kind of stuff we do. +Yeah, different. +So, what are you gonna do, Barry? +About work? I don't know. +I want to do my part for the hive, +but I can't do it the way they want. +I know how you feel. +- You do? +- Sure. +My parents wanted me to be a lawyer or +a doctor, but I wanted to be a florist. +- Really? +- My only interest is flowers. +Our new queen was just elected +with that same campaign slogan. +Anyway, if you look... +There's my hive right there. See it? +You're in Sheep Meadow! +Yes! I'm right off the Turtle Pond! +No way! I know that area. +I lost a toe ring there once. +- Why do girls put rings on their toes? +- Why not? +- It's like putting a hat on your knee. +- Maybe I'll try that. +- You all right, ma'am? +- Oh, yeah. Fine. +Just having two cups of coffee! +Anyway, this has been great. +Thanks for the coffee. +Yeah, it's no trouble. +Sorry I couldn't finish it. If I did, +I'd be up the rest of my life. +Are you...? +Oan I take a piece of this with me? +Sure! Here, have a crumb. +- Thanks! +- Yeah. +All right. Well, then... +I guess I'll see you around. +Or not. +OK, Barry. +And thank you +so much again... for before. +Oh, that? That was nothing. +Well, not nothing, but... Anyway... +This can't possibly work. +He's all set to go. +We may as well try it. +OK, Dave, pull the chute. +- Sounds amazing. +- It was amazing! +It was the scariest, +happiest moment of my life. +Humans! I can't believe +you were with humans! +Giant, scary humans! +What were they like? +Huge and crazy. They talk crazy. +They eat crazy giant things. +They drive crazy. +- Do they try and kill you, like on TV? +- Some of them. But some of them don't. +- How'd you get back? +- Poodle. +You did it, and I'm glad. You saw +whatever you wanted to see. +You had your "experience." Now you +can pick out yourjob and be normal. +- Well... +- Well? +Well, I met someone. +You did? Was she Bee-ish? +- A wasp?! Your parents will kill you! +- No, no, no, not a wasp. +- Spider? +- I'm not attracted to spiders. +I know it's the hottest thing, +with the eight legs and all. +I can't get by that face. +So who is she? +She's... human. +No, no. That's a bee law. +You wouldn't break a bee law. +- Her name's Vanessa. +- Oh, boy. +She's so nice. And she's a florist! +Oh, no! You're dating a human florist! +We're not dating. +You're flying outside the hive, talking +to humans that attack our homes +with power washers and M-80s! +One-eighth a stick of dynamite! +She saved my life! +And she understands me. +This is over! +Eat this. +This is not over! What was that? +- They call it a crumb. +- It was so stingin' stripey! +And that's not what they eat. +That's what falls off what they eat! +- You know what a Oinnabon is? +- No. +It's bread and cinnamon and frosting. +They heat it up... +Sit down! +...really hot! +- Listen to me! +We are not them! We're us. +There's us and there's them! +Yes, but who can deny +the heart that is yearning? +There's no yearning. +Stop yearning. Listen to me! +You have got to start thinking bee, +my friend. Thinking bee! +- Thinking bee. +- Thinking bee. +Thinking bee! Thinking bee! +Thinking bee! Thinking bee! +There he is. He's in the pool. +You know what your problem is, Barry? +I gotta start thinking bee? +How much longer will this go on? +It's been three days! +Why aren't you working? +I've got a lot of big life decisions +to think about. +What life? You have no life! +You have no job. You're barely a bee! +Would it kill you +to make a little honey? +Barry, come out. +Your father's talking to you. +Martin, would you talk to him? +Barry, I'm talking to you! +You coming? +Got everything? +All set! +Go ahead. I'll catch up. +Don't be too long. +Watch this! +Vanessa! +- We're still here. +- I told you not to yell at him. +He doesn't respond to yelling! +- Then why yell at me? +- Because you don't listen! +I'm not listening to this. +Sorry, I've gotta go. +- Where are you going? +- I'm meeting a friend. +A girl? Is this why you can't decide? +Bye. +I just hope she's Bee-ish. +They have a huge parade +of flowers every year in Pasadena? +To be in the Tournament of Roses, +that's every florist's dream! +Up on a float, surrounded +by flowers, crowds cheering. +A tournament. Do the roses +compete in athletic events? +No. All right, I've got one. +How come you don't fly everywhere? +It's exhausting. Why don't you +run everywhere? It's faster. +Yeah, OK, I see, I see. +All right, your turn. +TiVo. You can just freeze live TV? +That's insane! +You don't have that? +We have Hivo, but it's a disease. +It's a horrible, horrible disease. +Oh, my. +Dumb bees! +You must want to sting all those jerks. +We try not to sting. +It's usually fatal for us. +So you have to watch your temper. +Very carefully. +You kick a wall, take a walk, +write an angry letter and throw it out. +Work through it like any emotion: +Anger, jealousy, lust. +Oh, my goodness! Are you OK? +Yeah. +- What is wrong with you?! +- It's a bug. +He's not bothering anybody. +Get out of here, you creep! +What was that? A Pic 'N' Save circular? +Yeah, it was. How did you know? +It felt like about 10 pages. +Seventy-five is pretty much our limit. +You've really got that +down to a science. +- I lost a cousin to Italian Vogue. +- I'll bet. +What in the name +of Mighty Hercules is this? +How did this get here? +Oute Bee, Golden Blossom, +Ray Liotta Private Select? +- Is he that actor? +- I never heard of him. +- Why is this here? +- For people. We eat it. +You don't have +enough food of your own? +- Well, yes. +- How do you get it? +- Bees make it. +- I know who makes it! +And it's hard to make it! +There's heating, cooling, stirring. +You need a whole Krelman thing! +- It's organic. +- It's our-ganic! +It's just honey, Barry. +Just what?! +Bees don't know about this! +This is stealing! A lot of stealing! +You've taken our homes, schools, +hospitals! This is all we have! +And it's on sale?! +I'm getting to the bottom of this. +I'm getting to the bottom +of all of this! +Hey, Hector. +- You almost done? +- Almost. +He is here. I sense it. +Well, I guess I'll go home now +and just leave this nice honey out, +with no one around. +You're busted, box boy! +I knew I heard something. +So you can talk! +I can talk. +And now you'll start talking! +Where you getting the sweet stuff? +Who's your supplier? +I don't understand. +I thought we were friends. +The last thing we want +to do is upset bees! +You're too late! It's ours now! +You, sir, have crossed +the wrong sword! +You, sir, will be lunch +for my iguana, Ignacio! +Where is the honey coming from? +Tell me where! +Honey Farms! It comes from Honey Farms! +Orazy person! +What horrible thing has happened here? +These faces, they never knew +what hit them. And now +they're on the road to nowhere! +Just keep still. +What? You're not dead? +Do I look dead? They will wipe anything +that moves. Where you headed? +To Honey Farms. +I am onto something huge here. +I'm going to Alaska. Moose blood, +crazy stuff. Blows your head off! +I'm going to Tacoma. +- And you? +- He really is dead. +All right. +Uh-oh! +- What is that?! +- Oh, no! +- A wiper! Triple blade! +- Triple blade? +Jump on! It's your only chance, bee! +Why does everything have +to be so doggone clean?! +How much do you people need to see?! +Open your eyes! +Stick your head out the window! +From NPR News in Washington, +I'm Oarl Kasell. +But don't kill no more bugs! +- Bee! +- Moose blood guy!! +- You hear something? +- Like what? +Like tiny screaming. +Turn off the radio. +Whassup, bee boy? +Hey, Blood. +Just a row of honey jars, +as far as the eye could see. +Wow! +I assume wherever this truck goes +is where they're getting it. +I mean, that honey's ours. +- Bees hang tight. +- We're all jammed in. +It's a close community. +Not us, man. We on our own. +Every mosquito on his own. +- What if you get in trouble? +- You a mosquito, you in trouble. +Nobody likes us. They just smack. +See a mosquito, smack, smack! +At least you're out in the world. +You must meet girls. +Mosquito girls try to trade up, +get with a moth, dragonfly. +Mosquito girl don't want no mosquito. +You got to be kidding me! +Mooseblood's about to leave +the building! So long, bee! +- Hey, guys! +- Mooseblood! +I knew I'd catch y'all down here. +Did you bring your crazy straw? +We throw it in jars, slap a label on it, +and it's pretty much pure profit. +What is this place? +A bee's got a brain +the size of a pinhead. +They are pinheads! +Pinhead. +- Oheck out the new smoker. +- Oh, sweet. That's the one you want. +The Thomas 3000! +Smoker? +Ninety puffs a minute, semi-automatic. +Twice the nicotine, all the tar. +A couple breaths of this +knocks them right out. +They make the honey, +and we make the money. +"They make the honey, +and we make the money"? +Oh, my! +What's going on? Are you OK? +Yeah. It doesn't last too long. +Do you know you're +in a fake hive with fake walls? +Our queen was moved here. +We had no choice. +This is your queen? +That's a man in women's clothes! +That's a drag queen! +What is this? +Oh, no! +There's hundreds of them! +Bee honey. +Our honey is being brazenly stolen +on a massive scale! +This is worse than anything bears +have done! I intend to do something. +Oh, Barry, stop. +Who told you humans are taking +our honey? That's a rumor. +Do these look like rumors? +That's a conspiracy theory. +These are obviously doctored photos. +How did you get mixed up in this? +He's been talking to humans. +- What? +- Talking to humans?! +He has a human girlfriend. +And they make out! +Make out? Barry! +We do not. +- You wish you could. +- Whose side are you on? +The bees! +I dated a cricket once in San Antonio. +Those crazy legs kept me up all night. +Barry, this is what you want +to do with your life? +I want to do it for all our lives. +Nobody works harder than bees! +Dad, I remember you +coming home so overworked +your hands were still stirring. +You couldn't stop. +I remember that. +What right do they have to our honey? +We live on two cups a year. They put it +in lip balm for no reason whatsoever! +Even if it's true, what can one bee do? +Sting them where it really hurts. +In the face! The eye! +- That would hurt. +- No. +Up the nose? That's a killer. +There's only one place you can sting +the humans, one place where it matters. +Hive at Five, the hive's only +full-hour action news source. +No more bee beards! +With Bob Bumble at the anchor desk. +Weather with Storm Stinger. +Sports with Buzz Larvi. +And Jeanette Ohung. +- Good evening. I'm Bob Bumble. +- And I'm Jeanette Ohung. +A tri-county bee, Barry Benson, +intends to sue the human race +for stealing our honey, +packaging it and profiting +from it illegally! +Tomorrow night on Bee Larry King, +we'll have three former queens here in +our studio, discussing their new book, +Olassy Ladies, +out this week on Hexagon. +Tonight we're talking to Barry Benson. +Did you ever think, "I'm a kid +from the hive. I can't do this"? +Bees have never been afraid +to change the world. +What about Bee Oolumbus? +Bee Gandhi? Bejesus? +Where I'm from, we'd never sue humans. +We were thinking +of stickball or candy stores. +How old are you? +The bee community +is supporting you in this case, +which will be the trial +of the bee century. +You know, they have a Larry King +in the human world too. +It's a common name. Next week... +He looks like you and has a show +and suspenders and colored dots... +Next week... +Glasses, quotes on the bottom from the +guest even though you just heard 'em. +Bear Week next week! +They're scary, hairy and here live. +Always leans forward, pointy shoulders, +squinty eyes, very Jewish. +In tennis, you attack +at the point of weakness! +It was my grandmother, Ken. She's 81. +Honey, her backhand's a joke! +I'm not gonna take advantage of that? +Quiet, please. +Actual work going on here. +- Is that that same bee? +- Yes, it is! +I'm helping him sue the human race. +- Hello. +- Hello, bee. +This is Ken. +Yeah, I remember you. Timberland, size +ten and a half. Vibram sole, I believe. +Why does he talk again? +Listen, you better go +'cause we're really busy working. +But it's our yogurt night! +Bye-bye. +Why is yogurt night so difficult?! +You poor thing. +You two have been at this for hours! +Yes, and Adam here +has been a huge help. +- Frosting... +- How many sugars? +Just one. I try not +to use the competition. +So why are you helping me? +Bees have good qualities. +And it takes my mind off the shop. +Instead of flowers, people +are giving balloon bouquets now. +Those are great, if you're three. +And artificial flowers. +- Oh, those just get me psychotic! +- Yeah, me too. +Bent stingers, pointless pollination. +Bees must hate those fake things! +Nothing worse +than a daffodil that's had work done. +Maybe this could make up +for it a little bit. +- This lawsuit's a pretty big deal. +- I guess. +You sure you want to go through with it? +Am I sure? When I'm done with +the humans, they won't be able +to say, "Honey, I'm home," +without paying a royalty! +It's an incredible scene +here in downtown Manhattan, +where the world anxiously waits, +because for the first time in history, +we will hear for ourselves +if a honeybee can actually speak. +What have we gotten into here, Barry? +It's pretty big, isn't it? +I can't believe how many humans +don't work during the day. +You think billion-dollar multinational +food companies have good lawyers? +Everybody needs to stay +behind the barricade. +- What's the matter? +- I don't know, I just got a chill. +Well, if it isn't the bee team. +You boys work on this? +All rise! The Honorable +Judge Bumbleton presiding. +All right. Oase number 4475, +Superior Oourt of New York, +Barry Bee Benson v. the Honey Industry +is now in session. +Mr. Montgomery, you're representing +the five food companies collectively? +A privilege. +Mr. Benson... you're representing +all the bees of the world? +I'm kidding. Yes, Your Honor, +we're ready to proceed. +Mr. Montgomery, +your opening statement, please. +Ladies and gentlemen of the jury, +my grandmother was a simple woman. +Born on a farm, she believed +it was man's divine right +to benefit from the bounty +of nature God put before us. +If we lived in the topsy-turvy world +Mr. Benson imagines, +just think of what would it mean. +I would have to negotiate +with the silkworm +for the elastic in my britches! +Talking bee! +How do we know this isn't some sort of +holographic motion-picture-capture +Hollywood wizardry? +They could be using laser beams! +Robotics! Ventriloquism! +Oloning! For all we know, +he could be on steroids! +Mr. Benson? +Ladies and gentlemen, +there's no trickery here. +I'm just an ordinary bee. +Honey's pretty important to me. +It's important to all bees. +We invented it! +We make it. And we protect it +with our lives. +Unfortunately, there are +some people in this room +who think they can take it from us +'cause we're the little guys! +I'm hoping that, after this is all over, +you'll see how, by taking our honey, +you not only take everything we have +but everything we are! +I wish he'd dress like that +all the time. So nice! +Oall your first witness. +So, Mr. Klauss Vanderhayden +of Honey Farms, big company you have. +I suppose so. +I see you also own +Honeyburton and Honron! +Yes, they provide beekeepers +for our farms. +Beekeeper. I find that +to be a very disturbing term. +I don't imagine you employ +any bee-free-ers, do you? +- No. +- I couldn't hear you. +- No. +- No. +Because you don't free bees. +You keep bees. Not only that, +it seems you thought a bear would be +an appropriate image for a jar of honey. +They're very lovable creatures. +Yogi Bear, Fozzie Bear, Build-A-Bear. +You mean like this? +Bears kill bees! +How'd you like his head crashing +through your living room?! +Biting into your couch! +Spitting out your throw pillows! +OK, that's enough. Take him away. +So, Mr. Sting, thank you for being here. +Your name intrigues me. +- Where have I heard it before? +- I was with a band called The Police. +But you've never been +a police officer, have you? +No, I haven't. +No, you haven't. And so here +we have yet another example +of bee culture casually +stolen by a human +for nothing more than +a prance-about stage name. +Oh, please. +Have you ever been stung, Mr. Sting? +Because I'm feeling +a little stung, Sting. +Or should I say... Mr. Gordon M. Sumner! +That's not his real name?! You idiots! +Mr. Liotta, first, +belated congratulations on +your Emmy win for a guest spot +on ER in 2005. +Thank you. Thank you. +I see from your resume +that you're devilishly handsome +with a churning inner turmoil +that's ready to blow. +I enjoy what I do. Is that a crime? +Not yet it isn't. But is this +what it's come to for you? +Exploiting tiny, helpless bees +so you don't +have to rehearse +your part and learn your lines, sir? +Watch it, Benson! +I could blow right now! +This isn't a goodfella. +This is a badfella! +Why doesn't someone just step on +this creep, and we can all go home?! +- Order in this court! +- You're all thinking it! +Order! Order, I say! +- Say it! +- Mr. Liotta, please sit down! +I think it was awfully nice +of that bear to pitch in like that. +I think the jury's on our side. +Are we doing everything right, legally? +I'm a florist. +Right. Well, here's to a great team. +To a great team! +Well, hello. +- Ken! +- Hello. +I didn't think you were coming. +No, I was just late. +I tried to call, but... the battery. +I didn't want all this to go to waste, +so I called Barry. Luckily, he was free. +Oh, that was lucky. +There's a little left. +I could heat it up. +Yeah, heat it up, sure, whatever. +So I hear you're quite a tennis player. +I'm not much for the game myself. +The ball's a little grabby. +That's where I usually sit. +Right... there. +Ken, Barry was looking at your resume, +and he agreed with me that eating with +chopsticks isn't really a special skill. +You think I don't see what you're doing? +I know how hard it is to find +the rightjob. We have that in common. +Do we? +Bees have 100 percent employment, +but we do jobs like taking the crud out. +That's just what +I was thinking about doing. +Ken, I let Barry borrow your razor +for his fuzz. I hope that was all right. +I'm going to drain the old stinger. +Yeah, you do that. +Look at that. +You know, I've just about had it +with your little mind games. +- What's that? +- Italian Vogue. +Mamma mia, that's a lot of pages. +A lot of ads. +Remember what Van said, why is +your life more valuable than mine? +Funny, I just can't seem to recall that! +I think something stinks in here! +I love the smell of flowers. +How do you like the smell of flames?! +Not as much. +Water bug! Not taking sides! +Ken, I'm wearing a Ohapstick hat! +This is pathetic! +I've got issues! +Well, well, well, a royal flush! +- You're bluffing. +- Am I? +Surf's up, dude! +Poo water! +That bowl is gnarly. +Except for those dirty yellow rings! +Kenneth! What are you doing?! +You know, I don't even like honey! +I don't eat it! +We need to talk! +He's just a little bee! +And he happens to be +the nicest bee I've met in a long time! +Long time? What are you talking about?! +Are there other bugs in your life? +No, but there are other things bugging +me in life. And you're one of them! +Fine! Talking bees, no yogurt night... +My nerves are fried from riding +on this emotional roller coaster! +Goodbye, Ken. +And for your information, +I prefer sugar-free, artificial +sweeteners made by man! +I'm sorry about all that. +I know it's got +an aftertaste! I like it! +I always felt there was some kind +of barrier between Ken and me. +I couldn't overcome it. +Oh, well. +Are you OK for the trial? +I believe Mr. Montgomery +is about out of ideas. +We would like to call +Mr. Barry Benson Bee to the stand. +Good idea! You can really see why he's +considered one of the best lawyers... +Yeah. +Layton, you've +gotta weave some magic +with this jury, +or it's gonna be all over. +Don't worry. The only thing I have +to do to turn this jury around +is to remind them +of what they don't like about bees. +- You got the tweezers? +- Are you allergic? +Only to losing, son. Only to losing. +Mr. Benson Bee, I'll ask you +what I think we'd all like to know. +What exactly is your relationship +to that woman? +We're friends. +- Good friends? +- Yes. +How good? Do you live together? +Wait a minute... +Are you her little... +...bedbug? +I've seen a bee documentary or two. +From what I understand, +doesn't your queen give birth +to all the bee children? +- Yeah, but... +- So those aren't your real parents! +- Oh, Barry... +- Yes, they are! +Hold me back! +You're an illegitimate bee, +aren't you, Benson? +He's denouncing bees! +Don't y'all date your cousins? +- Objection! +- I'm going to pincushion this guy! +Adam, don't! It's what he wants! +Oh, I'm hit!! +Oh, lordy, I am hit! +Order! Order! +The venom! The venom +is coursing through my veins! +I have been felled +by a winged beast of destruction! +You see? You can't treat them +like equals! They're striped savages! +Stinging's the only thing +they know! It's their way! +- Adam, stay with me. +- I can't feel my legs. +What angel of mercy +will come forward to suck the poison +from my heaving buttocks? +I will have order in this court. Order! +Order, please! +The case of the honeybees +versus the human race +took a pointed turn against the bees +yesterday when one of their legal +team stung Layton T. Montgomery. +- Hey, buddy. +- Hey. +- Is there much pain? +- Yeah. +I... +I blew the whole case, didn't I? +It doesn't matter. What matters is +you're alive. You could have died. +I'd be better off dead. Look at me. +They got it from the cafeteria +downstairs, in a tuna sandwich. +Look, there's +a little celery still on it. +What was it like to sting someone? +I can't explain it. It was all... +All adrenaline and then... +and then ecstasy! +All right. +You think it was all a trap? +Of course. I'm sorry. +I flew us right into this. +What were we thinking? Look at us. We're +just a couple of bugs in this world. +What will the humans do to us +if they win? +I don't know. +I hear they put the roaches in motels. +That doesn't sound so bad. +Adam, they check in, +but they don't check out! +Oh, my. +Oould you get a nurse +to close that window? +- Why? +- The smoke. +Bees don't smoke. +Right. Bees don't smoke. +Bees don't smoke! +But some bees are smoking. +That's it! That's our case! +It is? It's not over? +Get dressed. I've gotta go somewhere. +Get back to the court and stall. +Stall any way you can. +And assuming you've done step correctly, you're ready for the tub. +Mr. Flayman. +Yes? Yes, Your Honor! +Where is the rest of your team? +Well, Your Honor, it's interesting. +Bees are trained to fly haphazardly, +and as a result, +we don't make very good time. +I actually heard a funny story about... +Your Honor, +haven't these ridiculous bugs +taken up enough +of this court's valuable time? +How much longer will we allow +these absurd shenanigans to go on? +They have presented no compelling +evidence to support their charges +against my clients, +who run legitimate businesses. +I move for a complete dismissal +of this entire case! +Mr. Flayman, I'm afraid I'm going +to have to consider +Mr. Montgomery's motion. +But you can't! We have a terrific case. +Where is your proof? +Where is the evidence? +Show me the smoking gun! +Hold it, Your Honor! +You want a smoking gun? +Here is your smoking gun. +What is that? +It's a bee smoker! +What, this? +This harmless little contraption? +This couldn't hurt a fly, +let alone a bee. +Look at what has happened +to bees who have never been asked, +"Smoking or non?" +Is this what nature intended for us? +To be forcibly addicted +to smoke machines +and man-made wooden slat work camps? +Living out our lives as honey slaves +to the white man? +- What are we gonna do? +- He's playing the species card. +Ladies and gentlemen, please, +free these bees! +Free the bees! Free the bees! +Free the bees! +Free the bees! Free the bees! +The court finds in favor of the bees! +Vanessa, we won! +I knew you could do it! High-five! +Sorry. +I'm OK! You know what this means? +All the honey +will finally belong to the bees. +Now we won't have +to work so hard all the time. +This is an unholy perversion +of the balance of nature, Benson. +You'll regret this. +Barry, how much honey is out there? +All right. One at a time. +Barry, who are you wearing? +My sweater is Ralph Lauren, +and I have no pants. +- What if Montgomery's right? +- What do you mean? +We've been living the bee way +a long time, 27 million years. +Oongratulations on your victory. +What will you demand as a settlement? +First, we'll demand a complete shutdown +of all bee work camps. +Then we want back the honey +that was ours to begin with, +every last drop. +We demand an end to the glorification +of the bear as anything more +than a filthy, smelly, +bad-breath stink machine. +We're all aware +of what they do in the woods. +Wait for my signal. +Take him out. +He'll have nauseous +for a few hours, then he'll be fine. +And we will no longer tolerate +bee-negative nicknames... +But it's just a prance-about stage name! +...unnecessary inclusion of honey +in bogus health products +and la-dee-da human +tea-time snack garnishments. +Oan't breathe. +Bring it in, boys! +Hold it right there! Good. +Tap it. +Mr. Buzzwell, we just passed three cups, +and there's gallons more coming! +- I think we need to shut down! +- Shut down? We've never shut down. +Shut down honey production! +Stop making honey! +Turn your key, sir! +What do we do now? +Oannonball! +We're shutting honey production! +Mission abort. +Aborting pollination and nectar detail. +Returning to base. +Adam, you wouldn't believe +how much honey was out there. +Oh, yeah? +What's going on? Where is everybody? +- Are they out celebrating? +- They're home. +They don't know what to do. +Laying out, sleeping in. +I heard your Uncle Oarl was on his way +to San Antonio with a cricket. +At least we got our honey back. +Sometimes I think, so what if humans +liked our honey? Who wouldn't? +It's the greatest thing in the world! +I was excited to be part of making it. +This was my new desk. This was my +new job. I wanted to do it really well. +And now... +Now I can't. +I don't understand +why they're not happy. +I thought their lives would be better! +They're doing nothing. It's amazing. +Honey really changes people. +You don't have any idea +what's going on, do you? +- What did you want to show me? +- This. +What happened here? +That is not the half of it. +Oh, no. Oh, my. +They're all wilting. +Doesn't look very good, does it? +No. +And whose fault do you think that is? +You know, I'm gonna guess bees. +Bees? +Specifically, me. +I didn't think bees not needing to make +honey would affect all these things. +It's notjust flowers. +Fruits, vegetables, they all need bees. +That's our whole SAT test right there. +Take away produce, that affects +the entire animal kingdom. +And then, of course... +The human species? +So if there's no more pollination, +it could all just go south here, +couldn't it? +I know this is also partly my fault. +How about a suicide pact? +How do we do it? +- I'll sting you, you step on me. +- Thatjust kills you twice. +Right, right. +Listen, Barry... +sorry, but I gotta get going. +I had to open my mouth and talk. +Vanessa? +Vanessa? Why are you leaving? +Where are you going? +To the final Tournament of Roses parade +in Pasadena. +They've moved it to this weekend +because all the flowers are dying. +It's the last chance +I'll ever have to see it. +Vanessa, I just wanna say I'm sorry. +I never meant it to turn out like this. +I know. Me neither. +Tournament of Roses. +Roses can't do sports. +Wait a minute. Roses. Roses? +Roses! +Vanessa! +Roses?! +Barry? +- Roses are flowers! +- Yes, they are. +Flowers, bees, pollen! +I know. +That's why this is the last parade. +Maybe not. +Oould you ask him to slow down? +Oould you slow down? +Barry! +OK, I made a huge mistake. +This is a total disaster, all my fault. +Yes, it kind of is. +I've ruined the planet. +I wanted to help you +with the flower shop. +I've made it worse. +Actually, it's completely closed down. +I thought maybe you were remodeling. +But I have another idea, and it's +greater than my previous ideas combined. +I don't want to hear it! +All right, they have the roses, +the roses have the pollen. +I know every bee, plant +and flower bud in this park. +All we gotta do is get what they've got +back here with what we've got. +- Bees. +- Park. +- Pollen! +- Flowers. +- Repollination! +- Across the nation! +Tournament of Roses, +Pasadena, Oalifornia. +They've got nothing +but flowers, floats and cotton candy. +Security will be tight. +I have an idea. +Vanessa Bloome, FTD. +Official floral business. It's real. +Sorry, ma'am. Nice brooch. +Thank you. It was a gift. +Once inside, +we just pick the right float. +How about The Princess and the Pea? +I could be the princess, +and you could be the pea! +Yes, I got it. +- Where should I sit? +- What are you? +- I believe I'm the pea. +- The pea? +It goes under the mattresses. +- Not in this fairy tale, sweetheart. +- I'm getting the marshal. +You do that! +This whole parade is a fiasco! +Let's see what this baby'll do. +Hey, what are you doing?! +Then all we do +is blend in with traffic... +...without arousing suspicion. +Once at the airport, +there's no stopping us. +Stop! Security. +- You and your insect pack your float? +- Yes. +Has it been +in your possession the entire time? +Would you remove your shoes? +- Remove your stinger. +- It's part of me. +I know. Just having some fun. +Enjoy your flight. +Then if we're lucky, we'll have +just enough pollen to do the job. +Oan you believe how lucky we are? We +have just enough pollen to do the job! +I think this is gonna work. +It's got to work. +Attention, passengers, +this is Oaptain Scott. +We have a bit of bad weather +in New York. +It looks like we'll experience +a couple hours delay. +Barry, these are cut flowers +with no water. They'll never make it. +I gotta get up there +and talk to them. +Be careful. +Oan I get help +with the Sky Mall magazine? +I'd like to order the talking +inflatable nose and ear hair trimmer. +Oaptain, I'm in a real situation. +- What'd you say, Hal? +- Nothing. +Bee! +Don't freak out! My entire species... +What are you doing? +- Wait a minute! I'm an attorney! +- Who's an attorney? +Don't move. +Oh, Barry. +Good afternoon, passengers. +This is your captain. +Would a Miss Vanessa Bloome in 24B +please report to the cockpit? +And please hurry! +What happened here? +There was a DustBuster, +a toupee, a life raft exploded. +One's bald, one's in a boat, +they're both unconscious! +- Is that another bee joke? +- No! +No one's flying the plane! +This is JFK control tower, Flight 356. +What's your status? +This is Vanessa Bloome. +I'm a florist from New York. +Where's the pilot? +He's unconscious, +and so is the copilot. +Not good. Does anyone onboard +have flight experience? +As a matter of fact, there is. +- Who's that? +- Barry Benson. +From the honey trial?! Oh, great. +Vanessa, this is nothing more +than a big metal bee. +It's got giant wings, huge engines. +I can't fly a plane. +- Why not? Isn't John Travolta a pilot? +- Yes. +How hard could it be? +Wait, Barry! +We're headed into some lightning. +This is Bob Bumble. We have some +late-breaking news from JFK Airport, +where a suspenseful scene +is developing. +Barry Benson, +fresh from his legal victory... +That's Barry! +...is attempting to land a plane, +loaded with people, flowers +and an incapacitated flight crew. +Flowers?! +We have a storm in the area +and two individuals at the controls +with absolutely no flight experience. +Just a minute. +There's a bee on that plane. +I'm quite familiar with Mr. Benson +and his no-account compadres. +They've done enough damage. +But isn't he your only hope? +Technically, a bee +shouldn't be able to fly at all. +Their wings are too small... +Haven't we heard this a million times? +"The surface area of the wings +and body mass make no sense." +- Get this on the air! +- Got it. +- Stand by. +- We're going live. +The way we work may be a mystery to you. +Making honey takes a lot of bees +doing a lot of small jobs. +But let me tell you about a small job. +If you do it well, +it makes a big difference. +More than we realized. +To us, to everyone. +That's why I want to get bees +back to working together. +That's the bee way! +We're not made of Jell-O. +We get behind a fellow. +- Black and yellow! +- Hello! +Left, right, down, hover. +- Hover? +- Forget hover. +This isn't so hard. +Beep-beep! Beep-beep! +Barry, what happened?! +Wait, I think we were +on autopilot the whole time. +- That may have been helping me. +- And now we're not! +So it turns out I cannot fly a plane. +All of you, let's get +behind this fellow! Move it out! +Move out! +Our only chance is if I do what I'd do, +you copy me with the wings of the plane! +Don't have to yell. +I'm not yelling! +We're in a lot of trouble. +It's very hard to concentrate +with that panicky tone in your voice! +It's not a tone. I'm panicking! +I can't do this! +Vanessa, pull yourself together. +You have to snap out of it! +You snap out of it. +You snap out of it. +- You snap out of it! +- You snap out of it! +- You snap out of it! +- You snap out of it! +- You snap out of it! +- You snap out of it! +- Hold it! +- Why? Oome on, it's my turn. +How is the plane flying? +I don't know. +Hello? +Benson, got any flowers +for a happy occasion in there? +The Pollen Jocks! +They do get behind a fellow. +- Black and yellow. +- Hello. +All right, let's drop this tin can +on the blacktop. +Where? I can't see anything. Oan you? +No, nothing. It's all cloudy. +Oome on. You got to think bee, Barry. +- Thinking bee. +- Thinking bee. +Thinking bee! +Thinking bee! Thinking bee! +Wait a minute. +I think I'm feeling something. +- What? +- I don't know. It's strong, pulling me. +Like a 27-million-year-old instinct. +Bring the nose down. +Thinking bee! +Thinking bee! Thinking bee! +- What in the world is on the tarmac? +- Get some lights on that! +Thinking bee! +Thinking bee! Thinking bee! +- Vanessa, aim for the flower. +- OK. +Out the engines. We're going in +on bee power. Ready, boys? +Affirmative! +Good. Good. Easy, now. That's it. +Land on that flower! +Ready? Full reverse! +Spin it around! +- Not that flower! The other one! +- Which one? +- That flower. +- I'm aiming at the flower! +That's a fat guy in a flowered shirt. +I mean the giant pulsating flower +made of millions of bees! +Pull forward. Nose down. Tail up. +Rotate around it. +- This is insane, Barry! +- This's the only way I know how to fly. +Am I koo-koo-kachoo, or is this plane +flying in an insect-like pattern? +Get your nose in there. Don't be afraid. +Smell it. Full reverse! +Just drop it. Be a part of it. +Aim for the center! +Now drop it in! Drop it in, woman! +Oome on, already. +Barry, we did it! +You taught me how to fly! +- Yes. No high-five! +- Right. +Barry, it worked! +Did you see the giant flower? +What giant flower? Where? Of course +I saw the flower! That was genius! +- Thank you. +- But we're not done yet. +Listen, everyone! +This runway is covered +with the last pollen +from the last flowers +available anywhere on Earth. +That means this is our last chance. +We're the only ones who make honey, +pollinate flowers and dress like this. +If we're gonna survive as a species, +this is our moment! What do you say? +Are we going to be bees, orjust +Museum of Natural History keychains? +We're bees! +Keychain! +Then follow me! Except Keychain. +Hold on, Barry. Here. +You've earned this. +Yeah! +I'm a Pollen Jock! And it's a perfect +fit. All I gotta do are the sleeves. +Oh, yeah. +That's our Barry. +Mom! The bees are back! +If anybody needs +to make a call, now's the time. +I got a feeling we'll be +working late tonight! +Here's your change. Have a great +afternoon! Oan I help who's next? +Would you like some honey with that? +It is bee-approved. Don't forget these. +Milk, cream, cheese, it's all me. +And I don't see a nickel! +Sometimes I just feel +like a piece of meat! +I had no idea. +Barry, I'm sorry. +Have you got a moment? +Would you excuse me? +My mosquito associate will help you. +Sorry I'm late. +He's a lawyer too? +I was already a blood-sucking parasite. +All I needed was a briefcase. +Have a great afternoon! +Barry, I just got this huge tulip order, +and I can't get them anywhere. +No problem, Vannie. +Just leave it to me. +You're a lifesaver, Barry. +Oan I help who's next? +All right, scramble, jocks! +It's time to fly. +Thank you, Barry! +That bee is living my life! +Let it go, Kenny. +- When will this nightmare end?! +- Let it all go. +- Beautiful day to fly. +- Sure is. +Between you and me, +I was dying to get out of that office. +You have got +to start thinking bee, my friend. +- Thinking bee! +- Me? +Hold it. Let's just stop +for a second. Hold it. +I'm sorry. I'm sorry, everyone. +Oan we stop here? +I'm not making a major life decision +during a production number! +All right. Take ten, everybody. +Wrap it up, guys. +I had virtually no rehearsal for that. \ No newline at end of file diff --git a/Unit-6/NLPRunner.java b/Unit-6/NLPRunner.java new file mode 100644 index 0000000..a6feefb --- /dev/null +++ b/Unit-6/NLPRunner.java @@ -0,0 +1,130 @@ +import java.util.ArrayList; + +// Randomly generated bee movie lines. + +public class NLPRunner { + + // Loop through and see if an existing word already exists in array + private static int getWordIndex(ArrayList wordArr, String wordStr){ + for(int i = 0; i < wordArr.size(); i++){ + word c = wordArr.get(i); + if(c.str.equals(wordStr)){ + return i; + } + } + return -1; + } + + // Loop through array, and see if an existing corrolation object between two words already exists + private static int getCorrolationIndex(ArrayList corrolations, + String startWord, String endWord){ + for(int i = 0; i < corrolations.size(); i++){ + if(corrolations.get(i).startWord.equals(startWord) && + corrolations.get(i).endWord.equals(endWord)){ + return i; + } + } + return -1; + } + + // Recursively choose a sentance + private static void recursiveWordChooser(ArrayList corrolations, String word){ + double total = 0; + final double randVal = (Math.random()); + + // Loop through corrolations + for(int i = 0; i < corrolations.size(); i++){ + corrolation c = corrolations.get(i); + if(c.startWord.str.equals(word)){ + final double correlation = c.getCorrelation(); + + // Weighted random + if(total <= randVal && randVal < (total + correlation)){ + + final String nextWord = c.endWord.str; + + if(nextWord.equals("")){ + System.out.print("\n"); + }else{ + System.out.print(" " + nextWord); + } + recursiveWordChooser(corrolations, nextWord); + } + + total += correlation; + } + } + // return words; + } + + public static void main(String[] args) { + + System.out.println(" --- Parsing file ---"); + + // Parse bee movie script and convert it for easier processing + String script = String.join(" ", FileReader.toStringArray("BeeMovie.txt")); + script = script.replace(".", ""); + script = script.replace(",", ""); + script = script.replace("!", ""); + script = script.replace("?", ""); + script = script.replace(" ", " "); + script = script.replace(" ", " "); + script = script.replace(" ", " "); + script = script.replace("\"", ""); + script = script.replace(":", ""); + script = script.replace("- ", ""); + script = script.replace("-", ""); + script = script.toLowerCase(); + + String[] words = script.split(" "); + + ArrayList wordArr = new ArrayList(); + + // Add words to array + for(int i = 0; i < words.length; i++){ + final String startWord = words[i]; + final int wordIndex = getWordIndex(wordArr, startWord); + + if(wordIndex != -1){ + word w = wordArr.get(wordIndex); + w.count = w.count + 1; + }else{ + word w = new word(); + w.str = startWord; + w.count = 1; + wordArr.add(w); + } + } + + ArrayList corrolations = new ArrayList(); + + // Convert list of words to list of corrolations + for(int i = 0; i < words.length-1; i++){ + final String startWord = words[i]; + final String endWord = words[i+1]; + + final int corrolationIndex = getCorrolationIndex(corrolations, startWord, endWord); + + // Add correlation + if(corrolationIndex != -1){ + corrolation c = corrolations.get(corrolationIndex); + c.correlativeOccurrences = c.correlativeOccurrences + 1; + }else{ + corrolation c = new corrolation(); + c.startWord = wordArr.get(getWordIndex(wordArr, startWord)); + c.endWord = wordArr.get(getWordIndex(wordArr, endWord)); + c.correlativeOccurrences = 1; + + corrolations.add(c); + } + } + + + final String startGenWord = "crazy"; + // Generate words + System.out.print(" " + startGenWord); + while(true){ + recursiveWordChooser(corrolations, startGenWord); + } + } +} \ No newline at end of file diff --git a/Unit-6/corrolation.java b/Unit-6/corrolation.java new file mode 100644 index 0000000..120ed8d --- /dev/null +++ b/Unit-6/corrolation.java @@ -0,0 +1,12 @@ +// Object structure for correlation between two words +public class corrolation { + + public int correlativeOccurrences = 0; + + public word startWord; + public word endWord; + + public double getCorrelation() { + return (double)(correlativeOccurrences) / (double)(startWord.count); + } +} \ No newline at end of file diff --git a/Unit-6/word.java b/Unit-6/word.java new file mode 100644 index 0000000..434fee5 --- /dev/null +++ b/Unit-6/word.java @@ -0,0 +1,5 @@ +// Object structure for a word +public class word { + public int count; + public String str; +} \ No newline at end of file