[Home]BeerPoet

Robo Home | Changes | Preferences | AllPages

Showing revision 14
BeerPoet, by PEZ, is yet another implementation of the "99 bottles of beer" poem in a programming language. As of this writing there are 709 published implementations:

http://www.99-bottles-of-beer.net/

BeerPoet actually got added to the project site: http://www.99-bottles-of-beer.net/language-robocode-494.html Cool huh? -- PEZ

Great, I want to try it. Where can I download it?

http://www.robocoderepository.com/BotDetail.jsp?id=1480

How competitive is it?

Beats SittingDuck. In fact it's designed to beat SittingDuck. 99 SittingDucks to be precise. In that sense it's my first competetive Melee bot. =) While it drinks SittingDuck beer it sings a song that's written in the output window.

How does it move?

It doesn't.

How does it fire?

On sight, HeadOnTargeting.

Where did you get the name?

It seemed like an appropriate name

Can I use your code?

Sure: Here it is:
package wiki.beer;
import robocode.*;
import java.awt.geom.Point2D;

// BeerPoet, one way to go about writing the 99-bottles-of-beer poem.
// By Peter Strömberg, http://robowiki.net/?PEZ
// For more info on the poem: http://99-bottles-of-beer.ls-la.net/
//
// Run this robot in Robocode.
// Put it against 99 SittingDuck and open its output window.

public class BeerPoet extends AdvancedRobot {
    private boolean hasStarted;

    public void run() {
        turnGunRightRadians(Double.POSITIVE_INFINITY); 
    }

    public void onScannedRobot(ScannedRobotEvent e) {
        if (!hasStarted) {
            printBottles();
            hasStarted = true;
        }
        setFire(3);
        setTurnGunRightRadians(0 - getGunTurnRemainingRadians());
    }

    public void onRobotDeath(RobotDeathEvent e) {
        printBottles();
    }

    private void printBottles() {
        out.println(bottles());
        if (getOthers() > 0) {
            out.println("Take " + (getOthers() == 1 ? "it" : "one") +
                " down, and pass it around");
            }
        else {
            out.println("Now they are all gone");
        }
    }

    private String bottles() {
        return bottles(getOthers()) + " on the wall, " + bottles(getOthers());
    }

    private String bottles(int bottles) {
        return (bottles == 0 ? "No" : "" + bottles) +
            " bottle" + (bottles == 1 ? "" : "s") + " of beer";
    }
}

What's next for your robot?

Dunno. Maybe someone else could write a Teams solution to the problem? Or maybe a bear drinker that rams it's opponents to death and drives funnier and funnier?

Comments, questions, feedback:

Feel encouraged to post your variation of a beer poet here.

Hey! This is pretty cool! Maybe you should write one that shoots down 99xsample.Walls, this way, you can sing "99 Robocode bots on the wall" :-) --Dummy

Yes, but Walls is a pretty strong bot. I have yet to make a bot that I can trust takes down 99 Walls every time. Please try. =) -- PEZ

I think 99 walls would take each other out for you quite efficiently :p -- Kuuran

Maybe so, but the poet must outsurvive all 99 Walls. That's not easy I think. -- PEZ

Yeah, finding an escape angle which a bullet isn't traveling along would be rather difficult, and it's far less fun if they're dying too fast for him to do his poem properly. -- Kuuran

A question. When I first wrote the poet I wrote it without the hasStarted boolean thingy. I simply called printBottles() from the run method. But it didn't work. It seemed like the function wasn't called at all then. Someone knows why? -- PEZ

ROFL! This is hilarious. Man. I've been sitting here for a couple hours now hitting Random Page and reading whatever comes up. Maybe I should go to bed... -- Vuen

Update:

1st: wiki.beer.BeerPoet 1.0	175738	49000	8910	98228	19600	0	0	9	0	0
2nd: sample.SittingDuck (5)	36650	36650	0	0	0	0	0	0	0	0
3rd: sample.SittingDuck (52)	34000	34000	0	0	0	0	0	0	1	1
5th: sample.SittingDuck (21)	33250	33250	0	0	0	0	0	1	0	1
5th: sample.SittingDuck (23)	33250	33250	0	0	0	0	0	0	0	0
6th: sample.SittingDuck (20)	31950	31950	0	0	0	0	0	1	1	0
7th: sample.SittingDuck (7)	31450	31450	0	0	0	0	0	0	0	0
8th: sample.SittingDuck (69)	30450	30450	0	0	0	0	0	0	0	0
10th: sample.SittingDuck (31)	30150	30150	0	0	0	0	0	0	0	0
10th: sample.SittingDuck (74)	30150	30150	0	0	0	0	0	0	0	0
11th: sample.SittingDuck (11)	29750	29750	0	0	0	0	0	0	0	0
12th: sample.SittingDuck (41)	29700	29700	0	0	0	0	0	0	0	0
13th: sample.SittingDuck (32)	29650	29650	0	0	0	0	0	0	0	0
14th: sample.SittingDuck (96)	29200	29200	0	0	0	0	0	0	0	0
15th: sample.SittingDuck (77)	29050	29050	0	0	0	0	0	0	0	0
16th: sample.SittingDuck (75)	29000	29000	0	0	0	0	0	0	0	0
17th: sample.SittingDuck (10)	28950	28950	0	0	0	0	0	0	0	0
18th: sample.SittingDuck (38)	28800	28800	0	0	0	0	0	0	0	0
19th: sample.SittingDuck (25)	28700	28700	0	0	0	0	0	0	0	0
20th: sample.SittingDuck (35)	28650	28650	0	0	0	0	0	0	0	1
21st: sample.SittingDuck (49)	28250	28250	0	0	0	0	0	0	0	0
22nd: sample.SittingDuck (89)	28200	28200	0	0	0	0	0	0	0	0
23rd: sample.SittingDuck (33)	28150	28150	0	0	0	0	0	0	0	0
24th: sample.SittingDuck (88)	28100	28100	0	0	0	0	0	0	0	0
25th: sample.SittingDuck (18)	27950	27950	0	0	0	0	0	0	0	0
26th: sample.SittingDuck (48)	27900	27900	0	0	0	0	0	0	1	1
27th: sample.SittingDuck (66)	27800	27800	0	0	0	0	0	0	0	0
28th: sample.SittingDuck (53)	27600	27600	0	0	0	0	0	0	0	0
29th: sample.SittingDuck (78)	27050	27050	0	0	0	0	0	0	1	0
30th: sample.SittingDuck (84)	26900	26900	0	0	0	0	0	0	0	0
31st: sample.SittingDuck (39)	26650	26650	0	0	0	0	0	0	1	0
32nd: sample.SittingDuck (70)	26550	26550	0	0	0	0	0	0	0	0
33rd: sample.SittingDuck (95)	26500	26500	0	0	0	0	0	0	0	0
35th: sample.SittingDuck (28)	26350	26350	0	0	0	0	0	0	0	0
35th: sample.SittingDuck (83)	26350	26350	0	0	0	0	0	0	0	1
36th: sample.SittingDuck (42)	26250	26250	0	0	0	0	0	0	0	0
38th: sample.SittingDuck (4)	26150	26150	0	0	0	0	0	0	0	0
38th: sample.SittingDuck (91)	26150	26150	0	0	0	0	0	0	0	0
39th: sample.SittingDuck (58)	26000	26000	0	0	0	0	0	0	0	0
40th: sample.SittingDuck (62)	25800	25800	0	0	0	0	0	0	0	0
42nd: sample.SittingDuck (26)	25750	25750	0	0	0	0	0	1	0	0
42nd: sample.SittingDuck (57)	25750	25750	0	0	0	0	0	0	0	0
43rd: sample.SittingDuck (59)	25650	25650	0	0	0	0	0	0	0	0
44th: sample.SittingDuck (98)	25550	25550	0	0	0	0	0	0	0	0
46th: sample.SittingDuck (34)	25350	25350	0	0	0	0	0	0	0	0
46th: sample.SittingDuck (55)	25350	25350	0	0	0	0	0	0	0	1
47th: sample.SittingDuck (6)	25250	25250	0	0	0	0	0	0	0	0
49th: sample.SittingDuck (37)	25000	25000	0	0	0	0	0	0	0	0
49th: sample.SittingDuck (85)	25000	25000	0	0	0	0	0	0	1	0
50th: sample.SittingDuck (76)	24650	24650	0	0	0	0	0	0	0	0
51st: sample.SittingDuck (1)	24500	24500	0	0	0	0	0	0	0	0
52nd: sample.SittingDuck (90)	24100	24100	0	0	0	0	0	0	0	0
53rd: sample.SittingDuck (44)	24050	24050	0	0	0	0	0	0	0	0
54th: sample.SittingDuck (46)	23950	23950	0	0	0	0	0	0	0	0
55th: sample.SittingDuck (15)	23900	23900	0	0	0	0	0	0	0	0
57th: sample.SittingDuck (22)	23850	23850	0	0	0	0	0	0	0	0
57th: sample.SittingDuck (36)	23850	23850	0	0	0	0	0	0	0	0
58th: sample.SittingDuck (80)	23750	23750	0	0	0	0	0	0	0	0
59th: sample.SittingDuck (61)	23650	23650	0	0	0	0	0	0	0	0
60th: sample.SittingDuck (65)	23550	23550	0	0	0	0	0	0	0	0
64th: sample.SittingDuck (17)	23500	23500	0	0	0	0	0	0	1	0
64th: sample.SittingDuck (67)	23500	23500	0	0	0	0	0	0	0	0
64th: sample.SittingDuck (86)	23500	23500	0	0	0	0	0	0	0	0
64th: sample.SittingDuck (92)	23500	23500	0	0	0	0	0	0	0	0
65th: sample.SittingDuck (3)	23450	23450	0	0	0	0	0	0	0	1
66th: sample.SittingDuck (14)	23400	23400	0	0	0	0	0	0	0	1
69th: sample.SittingDuck (8)	23350	23350	0	0	0	0	0	0	0	0
69th: sample.SittingDuck (27)	23350	23350	0	0	0	0	0	0	0	0
69th: sample.SittingDuck (50)	23350	23350	0	0	0	0	0	0	0	0
70th: sample.SittingDuck (54)	23250	23250	0	0	0	0	0	0	0	0
71st: sample.SittingDuck (71)	22900	22900	0	0	0	0	0	0	0	0
72nd: sample.SittingDuck (79)	22600	22600	0	0	0	0	0	0	0	0
73rd: sample.SittingDuck (60)	22550	22550	0	0	0	0	0	0	0	0
74th: sample.SittingDuck (73)	22350	22350	0	0	0	0	0	0	1	0
75th: sample.SittingDuck (81)	22250	22250	0	0	0	0	0	0	0	0
77th: sample.SittingDuck (43)	22200	22200	0	0	0	0	0	0	0	0
77th: sample.SittingDuck (51)	22200	22200	0	0	0	0	0	0	0	0
78th: sample.SittingDuck (24)	21950	21950	0	0	0	0	0	0	1	0
80th: sample.SittingDuck (45)	21450	21450	0	0	0	0	0	0	0	0
80th: sample.SittingDuck (94)	21450	21450	0	0	0	0	0	0	0	0
81st: sample.SittingDuck (16)	21100	21100	0	0	0	0	0	0	0	0
82nd: sample.SittingDuck (12)	20900	20900	0	0	0	0	0	0	0	0
83rd: sample.SittingDuck (87)	20650	20650	0	0	0	0	0	0	0	0
84th: sample.SittingDuck (93)	20500	20500	0	0	0	0	0	0	0	0
86th: sample.SittingDuck (47)	20300	20300	0	0	0	0	0	0	0	0
86th: sample.SittingDuck (56)	20300	20300	0	0	0	0	0	0	0	0
87th: sample.SittingDuck (97)	18550	18550	0	0	0	0	0	0	0	0
88th: sample.SittingDuck (72)	18450	18450	0	0	0	0	0	0	0	0
89th: sample.SittingDuck (19)	18150	18150	0	0	0	0	0	0	0	0
90th: sample.SittingDuck (99)	17950	17950	0	0	0	0	0	0	0	0
91st: sample.SittingDuck (13)	17650	17650	0	0	0	0	0	0	0	1
92nd: sample.SittingDuck (63)	17250	17250	0	0	0	0	0	0	0	0
93rd: sample.SittingDuck (82)	17150	17150	0	0	0	0	0	0	0	0
94th: sample.SittingDuck (29)	16850	16850	0	0	0	0	0	0	0	0
95th: sample.SittingDuck (40)	16750	16750	0	0	0	0	0	0	0	0
96th: sample.SittingDuck (68)	15700	15700	0	0	0	0	0	0	0	0
97th: sample.SittingDuck (64)	15150	15150	0	0	0	0	0	0	0	0
98th: sample.SittingDuck (2)	13550	13550	0	0	0	0	0	0	0	0
99th: sample.SittingDuck (9)	13350	13350	0	0	0	0	0	0	0	0
100th: sample.SittingDuck (30)	13200	13200	0	0	0	0	0	0	0	0

Just thought I'd mention. Delete this if you like :). Anybody see any of their lucky numbers? -- Vuen

What is it showing? Doesn't the poet win all the rounds? I must admit I never really tried it with 99 bottles, just 5 or 6 or so... Shame on me. -- PEZ

Lol, it's not really showing anything. I was just bored at the time, so I felt like showing the scores. Heh... */me slaps himself* -- Vuen


Robo Home | Changes | Preferences | AllPages
Edit revision 14 of this page | View other revisions | View current revision
Edited June 14, 2005 9:47 EST by PEZ (diff)
Search: