-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
764 additions
and
2 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
""" | ||
This driver does not do any action. | ||
""" | ||
from rose.common import obstacles, actions # NOQA | ||
|
||
driver_name = "me" | ||
bad = [obstacles.BIKE, obstacles.BARRIER, obstacles.TRASH] | ||
good = [obstacles.WATER, obstacles.PENGUIN, obstacles.CRACK] | ||
better = [obstacles.PENGUIN, obstacles.CRACK] | ||
best = [obstacles.NONE, obstacles.PENGUIN] | ||
|
||
|
||
def betterlane(world, x, y, lane): | ||
obstacle = world.get((x, y - 1)) | ||
if lane == 0: | ||
if world.get((x - 1, y - 2)) in good and world.get((x - 1, y - 1)) in best and world.get( | ||
(x, y - 3)) != obstacles.PENGUIN: | ||
return actions.LEFT | ||
elif world.get((x + 1, y - 2)) in good and world.get((x + 1, y - 1)) in best and world.get( | ||
(x, y - 3)) != obstacles.PENGUIN: | ||
return actions.RIGHT | ||
elif world.get((x, y - 1)) in bad: | ||
for i in range(3, 6): | ||
if world.get((x - 1, y - i)) in good and world.get((x + 1, y - i)) != obstacles.PENGUIN: | ||
return actions.LEFT | ||
else: | ||
return actions.RIGHT | ||
else: | ||
return actions.NONE | ||
if lane == 1: | ||
if world.get((x - 1, y - 1)) in best and world.get((x, y - 2)) not in good: | ||
return actions.LEFT | ||
else: | ||
return actions.NONE | ||
if lane == 2: | ||
if world.get((x + 1, y - 1)) in best and world.get((x, y - 2)) not in good: | ||
return actions.RIGHT | ||
else: | ||
return actions.NONE | ||
|
||
|
||
def drive(world): | ||
x = world.car.x | ||
y = world.car.y | ||
obstacle = world.get((x, y - 1)) | ||
if x == 1 or x == 4: | ||
lane = 0 # 0=in middle, 1=in right, 2= in left | ||
elif x == 2 or x == 5: | ||
lane = 1 | ||
else: | ||
lane = 2 | ||
if obstacle == obstacles.PENGUIN: | ||
return actions.PICKUP | ||
if obstacle == obstacles.CRACK: | ||
if lane < 2 and world.get((x - 1, y - 2)) == obstacles.PENGUIN: | ||
return actions.LEFT | ||
elif lane % 2 == 0 and world.get((x + 1, y - 2)) in obstacles.PENGUIN: | ||
return actions.RIGHT | ||
else: | ||
return actions.JUMP | ||
if obstacle == obstacles.WATER: | ||
if lane < 2 and world.get((x - 1, y - 2)) in better: | ||
return actions.LEFT | ||
elif lane % 2 == 0 and world.get((x + 1, y - 2)) in better: | ||
return actions.RIGHT | ||
else: | ||
return actions.BRAKE | ||
|
||
if obstacle in bad: | ||
if lane == 0: | ||
return betterlane(world, x, y, lane) | ||
if lane == 1: | ||
return actions.LEFT | ||
if lane == 2: | ||
return actions.RIGHT | ||
return betterlane(world, x, y, lane) |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
body { | ||
font-family: sans-serif; | ||
background: #444; | ||
color: #ccc; | ||
margin: 0; | ||
} | ||
|
||
#content { | ||
margin: 0 auto; | ||
width: 910px; | ||
} | ||
|
||
#control { | ||
position: relative; | ||
margin: 10px 0; | ||
font-weight: bold; | ||
} | ||
|
||
#control button { | ||
font-family: helvetica, sans-serif; | ||
font-size: 20px; | ||
line-height: 24px; | ||
font-weight: bold; | ||
border: 1px solid #666; | ||
color: #ccc; | ||
background-color: #333; | ||
} | ||
|
||
#control button:disabled, #control button:disabled:hover { | ||
color: #666; | ||
background-color: #333; | ||
} | ||
|
||
#control button:hover { | ||
background-color: #222; | ||
} | ||
|
||
#start, #stop, #music_ctl { | ||
width: 120px; | ||
padding: 8px 24px; | ||
margin: 0; | ||
} | ||
|
||
#pausegame { | ||
width: 120px; | ||
padding: 8px 0px; | ||
margin: 0; | ||
} | ||
|
||
#rate_ctl { | ||
position: absolute; | ||
top: 0; | ||
right: 0; | ||
} | ||
|
||
#rate_ctl label { | ||
margin: 0 10px; | ||
} | ||
|
||
#rate_ctl .group { | ||
display: inline-block; | ||
font-size: 0; | ||
border: 1px solid #666; | ||
} | ||
|
||
#rate_ctl button { | ||
height: 40px; | ||
padding: 0; | ||
margin: 0; | ||
} | ||
|
||
#inc_rate, #dec_rate { | ||
width: 50px; | ||
border: 0; | ||
} | ||
|
||
#cur_rate { | ||
width: 120px; | ||
border-top: 0; | ||
border-bottom: 0; | ||
} | ||
|
||
#players { | ||
background-image: url('../res/dashboard/dashboard.png'); | ||
width: 910px; | ||
height: 150px; | ||
font-weight: bold; | ||
font-family: sans-serif; | ||
color: rgb(153, 153, 153); | ||
position: relative; | ||
} | ||
|
||
.player { | ||
width: 350px; | ||
height: 100px; | ||
top: 20px; | ||
position: absolute; | ||
} | ||
|
||
#left.player { | ||
left: 10px; | ||
} | ||
|
||
#right.player { | ||
right: 10px; | ||
} | ||
|
||
.player .name { | ||
font-size: 30px; | ||
width: 100%; | ||
height: 50px; | ||
text-align: center; | ||
position: absolute; | ||
overflow: hidden; | ||
top: 7px; | ||
} | ||
|
||
.score { | ||
width: 100%; | ||
text-align:center; | ||
position: absolute; | ||
font-size: 40px; | ||
top: 50px; | ||
} | ||
|
||
#time_left { | ||
width: 105px; | ||
font-size: 50px; | ||
text-align:center; | ||
position: absolute; | ||
top: 40px; | ||
left: 400px; | ||
} | ||
|
||
#game { | ||
border: 1px #666 solid; | ||
} |
Oops, something went wrong.