Pages

ApplePacker Olympics - Finals

The Teams

/**************************/
/* Regional Apple Packers */
/**************************/

class Northwest
{
    public static ApplePackerFranchise[] applePackers =
    {
        // ApplePacker99 (a.k.a. The Sandbagger): Mr. Spurgeon

        new ApplePacker99(1),
        new ApplePacker99(2),
        new ApplePacker99(3),
        new ApplePacker99(4),
        new ApplePacker99(5),

        // ApplePacker1: Katie, Nicholas

        new ApplePacker1("ApplePacker1", "c Team - Katies apples", 1),
        new ApplePacker1("ApplePacker1", "c Team - Katies apples"),
        new ApplePacker1("ApplePacker1", "c Team - Katies apples"),
        new ApplePacker1("ApplePacker1", "c Team - Nicks apples"),
        new ApplePacker1("ApplePacker1", "c Team - Nicks apples"),

        // ApplePacker510: Raj, Jaden, Nathan, Ethan Bly

        new ApplePacker510("ApplePacker510", "R3B Corporate", 500),
        new ApplePacker510("ApplePacker510", "R3B North", 250),
        new ApplePacker510("ApplePacker510", "R3B South", 150),
        new ApplePacker510("ApplePacker510", "R3B East", 100),
        new ApplePacker510("ApplePacker510", "R3B West", 100),

        // ApplePacker8 (a.k.a. Blue Hole): Alex, Jerry

        new ApplePacker8(1),
        new ApplePacker8(2),
        new ApplePacker8(3),
        new ApplePacker8(4),
        new ApplePacker8(5),

        // ApplePacker37 (a.k.a. The Supreme Pack): Cherry, Helen, Zoe, Yang

        new ApplePacker37(1),
        new ApplePacker37(2),
        new ApplePacker37(3),
        new ApplePacker37(4),
        new ApplePacker37(5),

        // ApplePacker46: Phillip, Ethan Bardon, Steven, Luke M.

        new ApplePacker46("ApplePacker46", "Academic Integrity", 100), 
        new ApplePacker46("ApplePacker46", "The UnderTaker",50),
        new ApplePacker46("ApplePacker46", "Sharing is Caring", 1000),
        new ApplePacker46("ApplePacker46", "We Know the Way", 300),
        new ApplePacker46("ApplePacker46", "We Know it All",30),

        // ApplePacker42 (a.k.a. Speedy): Neil, Eric, Matt, Luke N.

        new ApplePacker42(1),
        new ApplePacker42(2),
        new ApplePacker42(3),
        new ApplePacker42(4),
        new ApplePacker42(5),

        // ApplePacker11: Jeffrey, Shivani

        new ApplePacker11("ApplePacker11"),
        new ApplePacker11("ApplePacker11", "Valley Catholic, LLC", 500),
        new ApplePacker11("ApplePacker11", "Valley Catholic, LLC", 500),
        new ApplePacker11("ApplePacker11", "The Original Valley Catholic"),
        new ApplePacker11("ApplePacker11", "Catholic", 50)
        };
}

Rankings

OVERALL COMPETITION

1. ApplePacker46 (234042)
2. ApplePacker510 (241799)
3. ApplePacker11 (276670)
4. Speedy (281484)
5. ApplePacker1 (293305)
6. Blue Hole (293527)
7. ApplePacker99 (297644)
8. The Supreme Pack (299661)

PACK TIME COMPETITION

Parent Co. Ranking

1. ApplePacker1 (21049)
2. ApplePacker46 (25654)
3. ApplePacker11 (29791)
4. ApplePacker510 (39066)
5. Speedy (71923)
6. Blue Hole (81806)
7. ApplePacker99 (95185)
8. The Supreme Pack (95846)

Top 10 Individual Franchise Scores

1. ApplePacker46: We Know it All (2.308E-6)
2. ApplePacker46: We Know it All (2.675E-6)
3. ApplePacker1: c Team - Katies apples (2.924E-6)
4. ApplePacker46: We Know it All (3.066E-6)
5. ApplePacker1: c Team - Katies apples (3.123E-6)
6. ApplePacker46: The UnderTaker (3.212E-6)
7. ApplePacker46: The UnderTaker (3.315E-6)
8. ApplePacker1: c Team - Katies apples (3.449E-6)
9. ApplePacker46: We Know it All (3.641E-6)
10. ApplePacker46: The UnderTaker (3.656E-6)

AVG AGE COMPETITION

Parent Co. Ranking

1. ApplePacker1 (14511)
2. ApplePacker46 (24785)
3. ApplePacker510 (27286)
4. ApplePacker11 (50420)
5. Blue Hole (76352)
6. Speedy (79494)
7. ApplePacker99 (82453)
8. The Supreme Pack (84152)

Top 10 Individual Franchise Scores

1. ApplePacker46: We Know it All (2.2504E-4)
2. ApplePacker46: Academic Integrity (2.252908E-4)
3. ApplePacker46: The UnderTaker (2.2721999999999998E-4)
4. ApplePacker1: c Team - Nicks apples (2.28088E-4)
5. ApplePacker46: We Know it All (2.2820466666666664E-4)
6. ApplePacker46: The UnderTaker (2.285365E-4)
7. ApplePacker46: The UnderTaker (2.289024E-4)
8. ApplePacker46: We Know it All (2.2901833333333334E-4)
9. ApplePacker46: We Know it All (2.292145E-4)
10. ApplePacker46: Academic Integrity (2.3033466666666665E-4)

WGT EFFICIENCY COMPETITION

Parent Co. Ranking

1. The Supreme Pack (23100)
2. ApplePacker99 (23254)
3. Speedy (52499)
4. ApplePacker11 (54749)
5. Blue Hole (55047)
6. ApplePacker510 (72116)
7. ApplePacker46 (72616)
8. ApplePacker1 (86072)

Top 10 Individual Franchise Scores

1. ApplePacker11: Valley (0.6104073927861784)
2. ApplePacker11: Valley (0.6157716676499275)
3. ApplePacker46: The UnderTaker (0.6159704543673817)
4. ApplePacker11: Valley Catholic, LLC (0.629512728687806)
5. ApplePacker46: Sharing is Caring (0.6298875847013918)
6. Speedy: 42 Pack (0.6319913109037306)
7. ApplePacker99: ApplePacker99a (0.6326185303611075)
8. ApplePacker99: ApplePacker99a (0.6331623011556705)
9. The Supreme Pack: ApplePacker37a (0.6334661728634411)
10. ApplePacker99: ApplePacker99a (0.6337240330504227)

VAL EFFICIENCY COMPETITION

Parent Co. Ranking

1. Speedy (24009)
2. Blue Hole (24828)
3. ApplePacker510 (32662)
4. ApplePacker46 (40002)
5. The Supreme Pack (73005)
6. ApplePacker99 (73061)
7. ApplePacker1 (85598)
8. ApplePacker11 (86288)

Top 10 Individual Franchise Scores

1. ApplePacker46: Sharing is Caring (0.762934865953611)
2. ApplePacker510: R3B North (0.7474678175075323)
3. ApplePacker46: We Know it All (0.7399074024122775)
4. ApplePacker46: The UnderTaker (0.7379528858123311)
5. ApplePacker46: We Know the Way (0.734130329227611)
6. ApplePacker46: Sharing is Caring (0.7313189445757301)
7. ApplePacker46: We Know the Way (0.7309115612126617)
8. ApplePacker46: We Know the Way (0.7302715749414393)
9. ApplePacker510: R3B Corporate (0.7296530749497199)
10. ApplePacker510: R3B Corporate (0.729211872781217)

VOL EFFICIENCY COMPETITION

Parent Co. Ranking

1. The Supreme Pack (23558)
2. ApplePacker99 (23691)
3. Speedy (53559)
4. ApplePacker11 (55422)
5. Blue Hole (55494)
6. ApplePacker510 (70669)
7. ApplePacker46 (70985)
8. ApplePacker1 (86075)

Top 10 Individual Franchise Scores

1. ApplePacker11: Valley (0.9855712874872348)
2. ApplePacker11: Valley (0.9769855152576065)
3. ApplePacker46: Sharing is Caring (0.9652516016619571)
4. ApplePacker46: The UnderTaker (0.9558900038553204)
5. ApplePacker11: Valley Catholic, LLC (0.9556597866639028)
6. ApplePacker99: ApplePacker99a (0.9509680338585694)
7. ApplePacker99: ApplePacker99a (0.950151325974301)
8. The Supreme Pack: ApplePacker37a (0.9496955414061066)
9. ApplePacker99: ApplePacker99a (0.9493091134704267)
10. The Supreme Pack: ApplePacker37a (0.9491725743435175)

Team Strategies

Declassified on 12 March 2018

/*****************/
/* ApplePacker99 */
/*****************/

class ApplePacker99 implements ApplePackerFranchise
{
    private final String parentCo = "ApplePacker99";
    private ApplePacker packer;
    public ApplePacker99(int version) {
        packer = new ApplePacker99a(this.parentCo, 300);
    }
    public String parentCompany() { return packer.parentCompany(); }
    public String businessName()  { return packer.businessName(); }
    public void initialize()      { packer.initialize(); }
    public boolean receive(Collection<BagOfApples> bags) { return packer.receive(bags); }
    public Collection<AppleCarton> pack(Collection<AppleCarton> cartons) {
        return packer.pack(cartons);
    }
    
    private class ApplePacker99a extends ApplePacker
    {
        public ApplePacker99a(String parentCo, int inventorySize) {
            super(parentCo, "ApplePacker99a", inventorySize);
            this.preferredSuppliers.add(Grower.RANDOM_REDS);
        }
        public void initialize() { /* do nothing */ }
        public Collection<AppleCarton> pack(Collection<AppleCarton> cartons) {
            for (AppleCarton carton : cartons)
            {
                if (this.inventory.count() < 10) this.restock();
                BagOfApples bag = inventory.oneVolLt(carton.remainingSpace());
                while (bag != null)
                {
                    if (!inventory.remove(bag)) return null;
                    if (!carton.add(bag)) return null;
                    bag = inventory.oneVolLt(carton.remainingSpace());
                }
                if (!carton.close()) return null;
            }
            return cartons;
        }
    }
}

/****************/
/* ApplePacker1 */
/****************/

class ApplePacker1 extends ApplePacker
{
    public ApplePacker1(String parentCo)
    {
        this(parentCo, "Johnny Appleseed");
    }
    public ApplePacker1(String parentCo, String businessName)
    {
        this(parentCo, businessName, 14);
    }
    public ApplePacker1(String parentCo, String businessName, int storageSpace)
    {
        super(parentCo, businessName, storageSpace);
    }
    public void initialize()
    {
        this.preferredSuppliers.add(Grower.APPLE_BEES);
        this.restock();
    }
    public Collection<AppleCarton> pack(Collection<AppleCarton> cartons)
    {
        for (AppleCarton carton : cartons)
        {
            BagOfApples bag = inventory.oneVolLt(carton.remainingSpace());
            while (bag != null)
            {
                if (!inventory.remove(bag)) return null;
                if (!carton.add(bag)) return null;
                bag = inventory.oneVolGt(carton.remainingSpace());
            }
            if (!carton.close()) return null;
        }
        return cartons;
    }
     
}

// Previous version:

/**
 * Our packing strategy was to change the supplier
 * because the apples that they provide were more
 * expensive, therefore it was a better value.
 * Another change we made is that we changed the 
 * default storage space because we found that the
 * score went up in multiple categories.
 * 
 * Got help from Mr.Spurgeon
 * 
 * 
 * */

/*
class ApplePacker1 extends ApplePacker
{
    public ApplePacker1(String parentCo)
    {
        this(parentCo, "Johnny Appleseed");
    }
    public ApplePacker1(String parentCo, String businessName)
    {
        this(parentCo, businessName, 10);
    }
    public ApplePacker1(String parentCo, String businessName, int storageSpace)
    {
        super(parentCo, businessName, storageSpace);
    }
    public void initialize()
    {
        this.preferredSuppliers.add(Grower.APPLE_BEES);
        this.restock();
    }
    public Collection<AppleCarton> pack(Collection<AppleCarton> cartons)
    {
        for (AppleCarton carton : cartons)
        {
            BagOfApples bag = inventory.oneVolLt(carton.remainingSpace());
            while (bag != null)
            {
                if (!inventory.remove(bag) || (!carton.add(bag))) return null;
                bag = inventory.oneVolLt(carton.remainingSpace());
            }
            if (!carton.close()) return null;
        }
        return cartons;
    }
}
*/

/****************/
/* ApplePacker510 */
/****************/

class ApplePacker510 extends ApplePacker
{
    public ApplePacker510(String parentCo)
    {
        this(parentCo, "R3B");
    }
    public ApplePacker510(String parentCo, String businessName)
    {
        this(parentCo, businessName, 25);
    }
    public ApplePacker510(String parentCo, String businessName, int storageSpace)
    {
        super(parentCo, businessName, storageSpace);
    }
    public void initialize()
    {
        this.preferredSuppliers.add(Grower.APPLE_BEES);
        this.preferredSuppliers.add(Grower.FRIENDLY_FRUITS);
        this.restock();
    }
    public Collection<AppleCarton> pack(Collection<AppleCarton> cartons)
    {
        for (AppleCarton carton : cartons)
        {
            BagOfApples bag = inventory.oneVolLt(carton.remainingSpace());
            while (bag != null)
            {
                if (!inventory.remove(bag)) return null;
                if (!carton.add(bag)) return null;
                
                Collection<BagOfApples> allVolLt = inventory.allVolLt(carton.remainingSpace());
                BagOfApples oneMinVol = Get.most(allVolLt, Lamb.vol, Lamb.gt);
                bag = oneMinVol;
            }
            if (!carton.close()) return null;
        }
        return cartons;
    }
}

/*****************/
/* ApplePacker8 */
/*****************/

class ApplePacker8 implements ApplePackerFranchise
{
 private final String parentCo = "Blue Hole";
 private ApplePacker packer;
 public ApplePacker8(int version) {
  switch (version) {
   case 1:
    packer = new ApplePacker8a(this.parentCo, "Ash", 200);
    break;
   case 2:
    packer = new ApplePacker8a(this.parentCo, "Mira", 200);
    break;
   case 3:
    packer = new ApplePacker8a(this.parentCo, "Rook", 200);
    break;
   case 4:
    packer = new ApplePacker8a(this.parentCo, "Lion", 200);
    break;
   case 5:
    packer = new ApplePacker8a(this.parentCo, "Ela", 200);
    break;
   default:
    packer = new ApplePacker8a(this.parentCo, "Sophor", 200);
    break;
  }
 }
 public String parentCompany() { return packer.parentCompany(); }
 public String businessName()  { return packer.businessName(); }
 public void initialize()      { packer.initialize(); }
 public boolean receive(Collection<BagOfApples> bags) { return packer.receive(bags); }
 public Collection<AppleCarton> pack(Collection<AppleCarton> cartons) {
  return packer.pack(cartons);
 }
 private class ApplePacker8a extends ApplePacker
 {
  public ApplePacker8a(String parentCo, String businessName, int inventorySize) {
   super(parentCo, businessName, inventorySize);
   this.preferredSuppliers.add(Grower.APPLE_BEES);
  }
  public void initialize() { /* do nothing */ }
  public Collection<AppleCarton> pack(Collection<AppleCarton> cartons) {
   for (AppleCarton carton : cartons)
   {
    if (this.inventory.count() < 10) this.restock();
    BagOfApples bag = inventory.oneVolLt(carton.remainingSpace());
    while (bag != null)
    {
     if (!inventory.remove(bag)) return null;
     if (!carton.add(bag)) return null;
     bag = inventory.oneVolLt(carton.remainingSpace());
    }
    if (!carton.close()) return null;
   }
   return cartons;
  }
 }
}

/* Previous version:

class ApplePacker8 implements ApplePackerFranchise
{
    private final String parentCo = "Blue Hole"; // "Bule Hole" is the name of parrent company.
    private ApplePacker packer;
    public ApplePacker8(int version) {
        packer = new ApplePacker8a(this.parentCo, 300);
    }
    public String parentCompany() { return packer.parentCompany(); }
    public String businessName()  { return packer.businessName(); }
    public void initialize()      { packer.initialize(); }
    public boolean receive(Collection<BagOfApples> bags) { return packer.receive(bags); }
    public Collection<AppleCarton> pack(Collection<AppleCarton> cartons) {
        return packer.pack(cartons);
    }
    
    private class ApplePacker8a extends ApplePacker
    {
        public ApplePacker8a(String parentCo, int inventorySize) {
            super(parentCo, "Blue Hole Gaming Center", inventorySize); // "Blue Hole Gaming Center" is the name of subsidiary company of Blue Hole.
            this.preferredSuppliers.add(Grower.RANDOM_REDS);
        }
        public void initialize() { }
        public Collection<AppleCarton> pack(Collection<AppleCarton> cartons) {
            for (AppleCarton carton : cartons)
            {
                if (this.inventory.count() < 10) this.restock();
                BagOfApples bag = inventory.oneVolLt(carton.remainingSpace());
                while (bag != null)
                {
                    if (!inventory.remove(bag)) return null;
                    if (!carton.add(bag)) return null;
                    bag = inventory.oneVolLt(carton.remainingSpace());
                }
                if (!carton.close()) return null;
            }
            return cartons;
        }
    }
}

*/

/*******************/
/* Apple Packer 37 */
/*******************/

class ApplePacker37 implements ApplePackerFranchise
{
    private final String parentCo = "The Supreme Pack";
    private ApplePacker packer;
    public ApplePacker37(int version) {
        packer = new ApplePacker37a(this.parentCo, 300);
    }
    public String parentCompany() { return packer.parentCompany(); }
    public String businessName()  { return packer.businessName(); }
    public void initialize()      { packer.initialize(); }
    public boolean receive(Collection<BagOfApples> bags) { return packer.receive(bags); }
    public Collection<AppleCarton> pack(Collection<AppleCarton> cartons) {
        return packer.pack(cartons);
    }
    
    private class ApplePacker37a extends ApplePacker
    {
        public ApplePacker37a(String parentCo, int inventorySize) {
            super(parentCo, "ApplePacker37a", inventorySize);
            this.preferredSuppliers.add(Grower.RANDOM_REDS);
        }
        public void initialize() { /* do nothing */ }
        public Collection<AppleCarton> pack(Collection<AppleCarton> cartons) {
            for (AppleCarton carton : cartons)
            {
                if (this.inventory.count() < 10) this.restock();
                BagOfApples bag = inventory.oneVolLt(carton.remainingSpace());
                while (bag != null)
                {
                    if (!inventory.remove(bag)) return null;
                    if (!carton.add(bag)) return null;
                    bag = inventory.oneVolLt(carton.remainingSpace());
                }
                if (!carton.close()) return null;
            }
            return cartons;
        }
    }
}

/********************/
/* Apple Packer 46  */
/********************/

/** The premise of our class is simply to utilize the inherit randomness of the procedure 
 * and then select the procedure that did it most efficently. This was achived by using the
 * already built in functions that are in the code and the basic premise of the default class.
 * The code uses the Lambda functions to find and get the greatest Value for each carton.
 * @authors  Ethan Bardon, Phillip Miller, Steaven Lin, Luke Monroe
 * @version 1.1
 * @since   2018-03-05
 */
class ApplePacker46 extends ApplePacker 
{
    public ApplePacker46(String parentCo)
    {
        this(parentCo, "4Mans");
    }
    public ApplePacker46(String parentCo, String businessName)
    {
        this(parentCo, businessName, 25);
    }
    public ApplePacker46(String parentCo, String businessName, int storageSpace)
    {
        super(parentCo, businessName, storageSpace);
    }
    public void initialize()
    {
        this.preferredSuppliers.add(Grower.APPLE_BEES);
        this.preferredSuppliers.add(Grower.FRIENDLY_FRUITS);
        this.restock();
    }
    public Collection<AppleCarton> pack(Collection<AppleCarton> cartons)
    {
        for (AppleCarton carton : cartons)
        {
            BagOfApples bag = inventory.oneVolLt(carton.remainingSpace());
            do
            {
                if (!inventory.remove(bag)) return null;
                if (!carton.add(bag)) return null;
                
                Collection<BagOfApples> oneVolLt = inventory.allVolLt(carton.remainingSpace());
                BagOfApples mostVal = Get.most(oneVolLt, Lamb.val, Lamb.gt); 
                bag = mostVal;
                
            } while (bag != null);
            if (!carton.close()) return null;
        }
        return cartons;
    }
}

/*****************/
/* ApplePacker42 */
/*****************/
/**
 * The packing stragedy of ApplePacker42a is simply put fruits inside bag when
 * ever there is space avalaible
 * Citation: ApplePacker99a originaly creat by Mr. Spurgeon.
 * Inspired (discuss with) by: Helen and Yang Yang
 * Helped by Mr. Spurgeon
 */ 
 
class ApplePacker42 implements ApplePackerFranchise
{
 private final String parentCo = "Speedy";
 private ApplePacker packer;
 public ApplePacker42(int version) {
  switch (version) {
   case 1:
    packer = new ApplePacker42a(this.parentCo, "Speedy Pack Inc.", 300);
    break;
   case 2:
    packer = new ApplePacker42a(this.parentCo, "BEST Pack", 300);
    break;
   case 3:
    packer = new ApplePacker42a(this.parentCo, "NOT BEST Pack", 300);
    break;
   case 4:
    packer = new ApplePacker42a(this.parentCo, "42 Pack", 300);
    break;
   case 5:
    packer = new ApplePacker42a(this.parentCo, "Some Pack Inc.", 300);
    break;
   default:
    packer = new ApplePacker42a(this.parentCo, "Speedy Pack Inc.", 300);
    break;
  }
 }
 public String parentCompany() { return packer.parentCompany(); }
 public String businessName()  { return packer.businessName(); }
 public void initialize()      { packer.initialize(); }
 public boolean receive(Collection<BagOfApples> bags) { return packer.receive(bags); }
 public Collection<AppleCarton> pack(Collection<AppleCarton> cartons) {
  return packer.pack(cartons);
 }
 private class ApplePacker42a extends ApplePacker
 {
  public ApplePacker42a(String parentCo, String businessName, int inventorySize) {
   super(parentCo, businessName, inventorySize);
   this.preferredSuppliers.add(Grower.APPLE_BEES);
  }
  public void initialize() { /* do nothing */ }
  public Collection<AppleCarton> pack(Collection<AppleCarton> cartons) {
   for (AppleCarton carton : cartons)
   {
    if (this.inventory.count() < 10) this.restock();
    BagOfApples bag = inventory.oneVolLt(carton.remainingSpace());
    while (bag != null)
    {
     if (!inventory.remove(bag)) return null;
     if (!carton.add(bag)) return null;
     bag = inventory.oneVolLt(carton.remainingSpace());
    }
    if (!carton.close()) return null;
   }
   return cartons;
  }
 }
}

/*****************/
/* ApplePacker11 */
/*****************/

//Jeffrey's dad helped a little
class ApplePacker11 extends ApplePacker
{
    public ApplePacker11(String parentCo)
    {
       this(parentCo, "Valley");
      
    }
    public ApplePacker11(String parentCo, String businessName)
    {
        this(parentCo, businessName, 25);
    }
    public ApplePacker11(String parentCo, String businessName, int storageSpace)
    {
        super(parentCo, businessName, storageSpace);
    }
    public void initialize()
    {
        this.preferredSuppliers.add(Grower.RANDOM_REDS);
        this.restock();
    }
    public Collection<AppleCarton> pack(Collection<AppleCarton> cartons)
    {
        for (AppleCarton carton : cartons)
        {
            BagOfApples bag = inventory.oneVolLt(carton.remainingSpace());
            while (bag != null)
            {
                if (!inventory.remove(bag)) return null;
                if (!carton.add(bag)) return null;
                bag = inventory.oneVolLt(carton.remainingSpace());
            }
            if (!carton.close()) return null;
        }
        return cartons;
    }
   
}