Skip to content

Commit

Permalink
Merge pull request #31 from Kautenja/fix_control_bug
Browse files Browse the repository at this point in the history
Fix control bug
  • Loading branch information
Kautenja authored Aug 12, 2018
2 parents de05792 + a69b8db commit 1dfb6ae
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
12 changes: 9 additions & 3 deletions nes_py/laines/include/joypad.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,16 @@ class Joypad {

public:

/// Initialize a new joypad instance
Joypad() { };
/// Initialize a new joy-pad instance
Joypad() {
for (int i = 0; i < sizeof(joypad_buttons); i++) {
joypad_buttons[i] = 0;
joypad_bits[i] = 0;
}
strobe = false;
};

/// Initialize a new joypad as a copy of another
/// Initialize a new joy-pad as a copy of another
Joypad(Joypad* joypad) {
std::copy(
std::begin(joypad->joypad_buttons),
Expand Down
17 changes: 11 additions & 6 deletions nes_py/tests/test_nes_env.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Test cases for the NESEnv class."""
from unittest import TestCase
from PIL import Image
# from PIL import Image


class ShouldImportNESEnv(TestCase):
Expand All @@ -25,12 +25,18 @@ def test(self):
self.assertRaises(ValueError, NESEnv, path)


class ShouldRaiseValueErrorOnNonexistentFile(TestCase):
def test(self):
from ..nes_env import NESEnv
self.assertRaises(ValueError, NESEnv, 'not_a_file.nes')


class ShouldRaiseValueErrorOnNoniNES_ROMPath(TestCase):
def test(self):
import os
from ..nes_env import NESEnv
path = os.path.join(os.path.dirname(__file__), 'games/blank')
self.assertRaises(ValueError, NESEnv, 'not_a_file.nes')
self.assertRaises(ValueError, NESEnv, path)


class ShouldRaiseValueErrorOnInvalidiNES_ROMPath(TestCase):
Expand All @@ -56,7 +62,6 @@ def create_smb1_instance():
"""Return a new SMB1 instance."""
import os
from ..nes_env import NESEnv
import gym
path = os.path.join(os.path.dirname(__file__), 'games/smb1.nes')
return NESEnv(path)

Expand All @@ -75,7 +80,7 @@ def test(self):
import numpy as np
env = create_smb1_instance()
done = True
for i in range(500):
for _ in range(500):
if done:
# reset the environment and check the output value
state = env.reset()
Expand Down Expand Up @@ -106,7 +111,7 @@ def test(self):
done = True
env = create_smb1_instance()

for i in range(250):
for _ in range(250):
if done:
state = env.reset()
done = False
Expand All @@ -116,7 +121,7 @@ def test(self):
# Image.fromarray(backup).save('state.png')
env._backup()

for i in range(250):
for _ in range(250):
if done:
state = env.reset()
done = False
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def README():

setup(
name='nes_py',
version='0.10.0',
version='0.10.1',
description='An NES Emulator and OpenAI Gym interface',
long_description=README(),
long_description_content_type='text/markdown',
Expand Down

0 comments on commit 1dfb6ae

Please sign in to comment.