This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"plane" by Chris Lewis | |
The release number is 1. The story creation year is 2009. The story headline is "Plane: A Tale of Pride". The story genre is "Medieval Morality". The story description is "A story about love at 30 000 feet.". Use no scoring. | |
The Cabin is a room. "The cabin is a long thin corridor surrounding you, bright light piercing the tin can that is propelling you at 600 mph through the lower atmosphere. A putrid smell of various processed food stuffs mixes with the thin air. People in various states of personal detachment are to your left and right. Some are sleeping, some are watching 'Beverly Hills Chihuahua'. They are essentially zombies. | |
You wonder if zombies actually come alive on aeroplanes. Then they could be immortal humans, doomed to be locked in on an eternal long-haul flight. You ponder this possibility for some time. | |
To the south are the bathrooms. | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# encoding: utf-8 | |
""" | |
evaluations.py | |
Created by Chris Lewis on 2009-03-17. | |
Copyright (c) 2009 Regents of the University of California. | |
Released under a BSD license: | |
http://www.opensource.org/licenses/bsd-license.php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def describe(x: Any) = x match { | |
case 5 => "five" | |
case true => "truth" | |
case "hello" => "hi!" | |
case Nil => "the empty list" | |
case _ => "something else" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scala> def add(x: Any) = x match { | |
| case h :: t => h + add(t) | |
| case _ => 0 | |
| } | |
<console>:5: error: recursive method add needs result type | |
case h :: t => h + add(t) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object TwitterOpener { | |
def main(args:Array[String]) = { | |
val twitterURL = new URL("http://twitter.com/statuses/public_timeline.rss") | |
val xmlRss = XML.load(twitterURL.openStream()) | |
println(xmlRss) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rule "Reverse aliens if one reaches the edge of the screen" | |
when | |
$alien : AlienEntity() | |
exists (AlienEntity(x < 10) or AlienEntity(x > 750)) | |
then | |
$alien.setHorizontalMovement(-$alien.getHorizontalMovement()); | |
$alien.setY($alien.getY() + 10); | |
end | |
rule "Process bullets hitting aliens" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for (int p=0;p<entities.size();p++) { | |
for (int s=p+1;s<entities.size();s++) { | |
Entity me = (Entity) entities.get(p); | |
Entity him = (Entity) entities.get(s); | |
if (me.collidesWith(him)) { | |
me.collidedWith(him); | |
him.collidedWith(me); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#domain person(P). | |
citizen(P) :- born_in_usa(P). | |
citizen(P) :- not_born_in_usa(P), resident_usa(P), naturalized(P). | |
citizen(P) :- not_born_in_usa(P), mother(Y,P), citizen(Y), registered(P). | |
#hide mother(P, Y). | |
mother(mary, john). | |
#hide citizen(P). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#domain object(O), position(P). | |
#hide object(O). | |
at_position(O, P) :- translate(O, P). | |
at_position(O, ground) :- fall(O). | |
object(mario). | |
position(ground). | |
:- fall(O), translate(O, P). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% A script to show using lparse with optimize statements. Pipe into clasp for nicer output. | |
#hide cost(_,_). | |
#hide star(_,_). | |
#hide main_street(_). | |
% For some reason, lparse chokes on hotel(1..5). Enumerating them all works. | |
1 { hotel(1), hotel(2), hotel(3), hotel(4), hotel(5) } 1. | |
star(1,5). star(2,4). star(3,3). star(4,3). star(5,2). |
OlderNewer