-
Notifications
You must be signed in to change notification settings - Fork 232
Update on input fixes #61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
FranciscoBoschetti
wants to merge
16
commits into
ntasfi:master
Choose a base branch
from
FranciscoBoschetti:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
5ed9710
Updated requirements and added test script
taeganwarren 2e552a4
This is a change
taeganwarren 31463ea
added tests for pong and raycastmaze
barnesjt f4264e2
fix: puckworld reward/ player drawing; pixelcopter obstacle placement…
JershCook 0bec046
Merge branch 'master' of https://github.com/se2-w19-group24/PyGame-Le…
JershCook 5c5e273
Merge pull request #1 from se2-w19-group24/p-rcm-test
barnesjt 3240069
Added param checking for raycastmaze.py, tests for it now pass
barnesjt 003cdb0
Assertions for value range of parameters inputs for pong.py added. On…
barnesjt 56748e6
Merge pull request #4 from se2-w19-group24/is2
barnesjt 37f782f
Changed pong collision to use pygame, removed unneeded code, commente…
barnesjt 24ad17f
Merge pull request #5 from se2-w19-group24/is3
barnesjt c216f0b
Update __init__.py
FranciscoBoschetti e5838d3
Merge pull request #1 from CiscoBoschetti/CiscoBoschetti-patch-1
FranciscoBoschetti c5c904e
Update __init__.py
FranciscoBoschetti 6fdd4f8
Merge pull request #2 from CiscoBoschetti/CiscoBoschetti-patch-2
FranciscoBoschetti 05fa154
Update __init__.py
FranciscoBoschetti File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
|
@@ -75,6 +75,9 @@ def __init__(self, | |
width=64, | ||
height=64): | ||
|
||
assert 0<width<2000 , "Invalid Width Size: "+str(width) | ||
assert 0<height<2000 , "Invalid Width Size: "+str(height) | ||
|
||
actions = { | ||
"up": K_w, | ||
"left": K_a, | ||
|
@@ -216,7 +219,7 @@ def init(self): | |
self.creeps = pygame.sprite.Group() | ||
self.creeps.add(self.good_creep) | ||
self.creeps.add(self.bad_creep) | ||
|
||
self.creeps.add(self.player) | ||
self.score = 0 | ||
self.ticks = 0 | ||
self.lives = -1 | ||
|
@@ -245,8 +248,7 @@ def step(self, dt): | |
reward = -dist_to_good | ||
if dist_to_bad < self.CREEP_BAD['radius_outer']: | ||
reward += 2.0 * \ | ||
(dist_to_bad - self.CREEP_BAD['radius_outer'] | ||
) / float(self.CREEP_BAD['radius_outer']) | ||
(dist_to_bad - self.CREEP_BAD['radius_outer']) | ||
|
||
self.score += reward | ||
|
||
|
@@ -261,7 +263,7 @@ def step(self, dt): | |
self.bad_creep.update(ndx, ndy, dt) | ||
self.good_creep.update(dt) | ||
|
||
self.player.draw(self.screen) | ||
#self.player.draw(self.screen) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this commented out? |
||
self.creeps.draw(self.screen) | ||
|
||
|
||
|
This file contains hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
mock==1.0.1 | ||
numpydoc | ||
Sphinx==1.2.3 | ||
sphinx_rtd_theme | ||
sphinx_rtd_theme |
This file contains hidden or 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 @@ | ||
pygame |
This file contains hidden or 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 hidden or 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,34 @@ | ||
from ple import PLE | ||
from ple.games.pong import Pong | ||
import pygame | ||
import time | ||
import sys | ||
|
||
game = Pong(width=300, height=200) | ||
|
||
p = PLE(game, fps=30, display_screen=True, force_fps=True) | ||
p.init() | ||
|
||
print(p.getActionSet()) | ||
|
||
nb_frames = 1000 | ||
action = None | ||
|
||
for f in range(nb_frames): | ||
if p.game_over(): | ||
p.reset_game() | ||
obs = p.getScreenRGB() | ||
events = pygame.event.get() | ||
for event in events: | ||
if event.type == pygame.QUIT: | ||
sys.exit() | ||
elif event.type == pygame.KEYDOWN: | ||
if event.key: | ||
action = event.key | ||
print(action) | ||
elif event.type == pygame.KEYUP: | ||
action = None | ||
p.act(action) | ||
time.sleep(.05) | ||
|
||
#This is a change |
This file contains hidden or 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,51 @@ | ||
#!/usr/bin/python | ||
from ple import PLE | ||
from ple.games.pong import Pong, Ball, Player | ||
import pygame, time, sys, pytest | ||
|
||
#This test passes if a positive difference in movement speed is detected | ||
def test_movement_up(): | ||
game=Pong() | ||
p=PLE(game, display_screen=True, fps=20, force_fps=1) | ||
p.init() | ||
time.sleep(.5) | ||
oldState=p.getGameState() | ||
p.act(game.actions["up"]) | ||
newState=p.getGameState() | ||
assert oldState["player_velocity"] > newState["player_velocity"] | ||
|
||
#This tests passes is a negative difference in movement speed is detected | ||
def test_movement_down(): | ||
game=Pong() | ||
p=PLE(game, display_screen=True, fps=20, force_fps=1) | ||
p.init() | ||
time.sleep(.5) | ||
oldState=p.getGameState() | ||
p.act(game.actions["down"]) | ||
newState=p.getGameState() | ||
assert oldState["player_velocity"] < newState["player_velocity"] | ||
|
||
#This test passes if an exception is thrown when a negative cpu speed is specified | ||
def test_negative_cpu_speed(): | ||
with pytest.raises(Exception): | ||
game=Pong(cpu_speed_ratio=-1) | ||
|
||
#This test passes if an exception is thrown when a negative player speed is specified | ||
def test_negative_player_speed(): | ||
with pytest.raises(Exception): | ||
game=Pong(players_speed_ratio=-1) | ||
|
||
#This test passes if an exception is thrown when a negative ball speed is specified | ||
def test_negative_ball_speed(): | ||
with pytest.raises(Exception): | ||
game=Pong(ball_speed_ratio=-1) | ||
|
||
#This test passes if an exception is thrown when a negative game size is specified | ||
def test_invalid_game_size(): | ||
with pytest.raises(Exception): | ||
game=Pong(width=-200, height=-200) | ||
|
||
#This test passes if an exception is thrown when a negative max score is specified | ||
def test_invalid_max_score(): | ||
with pytest.raises(Exception): | ||
game=Pong(MAX_SCORE=-1) |
This file contains hidden or 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,39 @@ | ||
#!/usr/bin/python | ||
from ple import PLE | ||
from ple.games.raycastmaze import RaycastMaze | ||
import pygame, time, sys, pytest | ||
|
||
#This test passes if an exception is thrown when a negative initial position is specified | ||
def test_oob_init_pos(): | ||
with pytest.raises(Exception): | ||
game=RaycastMaze(init_pos=(-1,-1)) | ||
|
||
#This test passes if an exception is thrown when the map size is below the minimum for the algorithm (5) | ||
def test_below_min_map_size(): | ||
with pytest.raises(Exception): | ||
game=RaycastMaze(map_size=3) | ||
|
||
#This test passes if an exception is thrown when a large map size is specified | ||
def test_beyond_max_map_size(): | ||
with pytest.raises(Exception): | ||
game=RaycastMaze(map_size=400) | ||
|
||
#This test passes if an exception is thrown when a negative move speed is specified | ||
def test_negative_move_speed(): | ||
with pytest.raises(Exception): | ||
game=RaycastMaze(move_speed=-1) | ||
|
||
#This test passes if an exception is thrown when a negative turn speed is specified | ||
def test_negative_turn_speed(): | ||
with pytest.raises(Exception): | ||
game=RaycastMaze(turn_speed=-1) | ||
|
||
#This test passes if an exception is thrown when a non-usefully large turn speed is specified | ||
def test_beyond_max_turn_speed(): | ||
with pytest.raises(Exception): | ||
game=RaycastMaze(turn_speed=400) | ||
|
||
#This test passes if an exception is thrown when a negative window size is specified | ||
def test_negative_game_size(): | ||
with pytest.raises(Exception): | ||
game=RaycastMaze(width=-100,height=-100) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you verify that this does not slow down the step speed? I believe using this function was slower.