Skip to content

Commit

Permalink
Merge branch 'release-1.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
gregcorbett committed Nov 3, 2017
2 parents 08eea8f + aa99235 commit 1e5986d
Show file tree
Hide file tree
Showing 23 changed files with 957 additions and 90 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,23 @@ img/UV/
img/UV/*
img/SKA/
img/SKA/*
img/DataHunt/
img/DataHunt/*
img/GAIA/
img/GAIA/*

logo.png

scenarios/UV.scibot
scenarios/SKA.scibot
scenarios/Default.scibot
scenarios/DataHunt.scibot
scenarios/GAIA.scibot

scenarioWriters/ScenarioWriterUV.py
scenarioWriters/ScenarioWriterSKA.py
scenarioWriters/ScenarioWriterDataHunt.py
scenarioWriters/ScenarioWriterGAIA.py

scenarios.zip

Expand Down
32 changes: 32 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
language: python
python:
- "3.4"
- "nightly"
matrix:
allow_failures:
- python: "nightly"
fast_finish: true

# Route build to container-based infrastructure
sudo: false

# Cache the dependencies installed by pip
cache: pip
# Avoid pip log from affecting cache
before_cache: rm -fv ~/.cache/pip/log/debug.log

# Install defaults to "pip install -r requirements.txt"

# Commands that prepare things for the test
before_script:
- export PYTHONPATH=$PYTHONPATH:`pwd -P`

# The coveralls module on PyPI (1.1) doesn't report branch coverage to
# Coveralls, but should in the next release (1.2)
script: coverage run --branch --source=src -m unittest2 discover --buffer

after_success: coveralls

# Prevent 'Video not initialized' errors
env:
SDL_VIDEODRIVER: "dummy"
14 changes: 14 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
========== Version 1.1.0 ==========

New Features and Minor Changes:

- Add a Stop Button that behaves like the BeeBot Stop Button

Patches, Bug Fixes and Documentation Changes:

- Change the Board class to throw exceptions rather than exiting on a size mismatch
- Add Travis CI testing and coverage monitoring
- Replace the text on Buttons with arrows
- Change the default scenario license to reflect the new main repository
- Add an example ScenarioWriter and a README explaining how to use it
- Tweak logo position for narrower scenarios
19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
# SciBot
[![Build Status](https://travis-ci.org/stfc/SciBot.svg?branch=develop)](https://travis-ci.org/stfc/SciBot)
[![Coverage Status](https://coveralls.io/repos/github/stfc/SciBot/badge.svg?branch=develop)](https://coveralls.io/github/stfc/SciBot?branch=develop)

contact: scibot-dev@googlegroups.com

##Users
1. Go to https://github.com/gregcorbett/SciBot/releases/latest
## Users
1. Go to https://github.com/stfc/SciBot/releases/latest
2. Download runSciBot.exe and scenarios.zip into the same place
3. Unzip scenarios.zip
3. Run the .exe file (by double clicking it.)

##Developers
## Developers

Download the soucre.zip, unzip it and navigate to the source code directory
If you wish to develop for SciBot, clone the repository and create a feature branch off of develop. Once your feature is ready, make a Pull Request back into develop.

###Requirements for building and developing SciBot
### Requirements for building and developing SciBot

Microsoft installers have been linked for each requirement for easy of installation.
Microsoft installers have been linked for each requirement for ease of installation.

1. Python, 3.4 or higher (https://www.python.org/downloads/)
* exact version used in testing ( https://www.python.org/ftp/python/3.4.3/python-3.4.3.msi)
Expand All @@ -22,11 +25,11 @@ Microsoft installers have been linked for each requirement for easy of installat
3. py2exe 0.9.2.2 (https://pypi.python.org/pypi/py2exe/)
* exact version used in testing (https://pypi.python.org/packages/any/p/py2exe/py2exe-0.9.2.2.win32.exe)

###Building the exe file
### Building the exe file

After the requirements above are met, open a command line and navigate to the unzipped directory.

Run `python setup.py py2exe`.

##Image Sources
## Image Sources
SciBot image sourced from: https://www.tes.co.uk/teaching-resource/bee-bot-sequence-powerpoint-6415227
5 changes: 5 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pygame
# Dependencies for testing
unittest2
coveralls
mock
87 changes: 87 additions & 0 deletions scenarioWriters/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Creating a new scenario
1. Choose a scenario name. It will be referred to below as `<name>`.

2. Copy `scenarioWriters/scenarioWriterBlank.py` to `scenarioWriters/scenarioWriter<name>.py`

3. At Line 10 onward, add the following:
```
# Initialises a new scenario object and sets the scenario name.
scenario = Scenario('<name>')
```

* Decide how big you want each square to be, in terms of pixels. If you already have a `BeeBot` image (or `Obstacle` images/`Goal` images), your squares should be the same size as this. Add the following code, but replace `n` with your number.
```
# The size of an individual square.
scenario.set_board_step(n)
```

* Decide how many squares you want your map to be. If you already have a background image, this will dictate the height and width. Add the following code, but replace `x` and `y` with your width and height in terms of squares.
```
# Sets the width of the map in terms of squares.
scenario.set_logical_width(x)
# Sets the height of the map in terms of squares.
scenario.set_logical_height(y)
```

* Decide where you want your `BeeBot` to start. Add the following code, replacing `x, y` with your starting co-ordinates.
```
# Sets the bee bot starting square.
scenario.set_beebot_start_position(x, y)
```

* Set your `BeeBot` sprite, it needs to be the same size as your squares. Add the following code, but replace `<sprite>` with the file path of your image.
```
# Set the BeeBot sprite.
scenario.set_beebot_sprite('<sprite>')
```

* You will need to tell the program which way you’re `BeeBot` sprite is facing, where 'UP' is `Heading.NORTH`. Add the following code, but replace <heading> with your heading.
```
# Sets the BeeBots starting direction, where "UP" is Heading.NORTH.
# (other options are Heading.EAST, Heading.SOUTH and Heading.WEST)
scenario.set_beebot_heading(<heading>)
```

* Set the background image. Add the following code, but replace <background> with the file path of your image.
```
# Sets the image on the map.
scenario.set_background('<background>')
```

* If the image has no grid, one can be added by adding the following code and replacing `(R, G, B)` with your chosen RGB colour.
```
scenario.set_border_colour((R, G, B))
```

* Obstacles, squares to avoid, need to be defined separately. To add an `Obstacle`, add the following code, but replace `x, y` with your `Obstacle` location.
To add an `Obstacle` with an image, replace `x, y` with your `Obstacle` location and the file path of the image e.g. `(1, 2, './img/Default/obstacle1.jpg')`
```
# This line adds an obstacle.
scenario.add_obstacle(x, y)
```

* Goals, squares to reach, need to be defined separately also. To add a `Goal`, add the following code, but replace `x, y` with your `Goal` location.
To add a `Goal` with an image, replace `x, y` with your `Goal` location and the file path of the image e.g. `(1, 2, './img/Default/goal1.jpg')`
```
# This line adds a goal.
scenario.add_goal(x, y)
```

* You can decide whether you want your goals to be completed in the order added, or in any order. Add one of the following blocks of code.
```
# This method means the goals must be met in the order added.
scenario.set_ordered_goals(True)
```
or
```
# This method means the goals can be met in any order.
scenario.set_ordered_goals(False)
```

* You'll need to set a sprite for when your BeeBot crashes. Add the following code, but replace `path` with the file path of the image.
```
# Sets the sprite to be displayed when the robot crashes
scenario.set_beebot_fail_sprite('path')
```

4. Finally, run `python scenarioWriters/ScenarioWriter<name>.py` to generate your `.scitbot` file.
35 changes: 35 additions & 0 deletions scenarioWriters/ScenarioWriterBlank.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""This file writes a new scibot file."""

from src.Scenario import Scenario
from src.BeeBot import Heading


def main():
"""Write a scibot file."""
# Add commands below

# Copy the LICENSE from below into the Scenario
scenario.set_license(LICENSE)

# Writes the scibot file
scenario.write_to_file()

# Alter this to credit image sources
LICENSE = """
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
The full version of this license can be found here.
https://github.com/stfc/SciBot/blob/master/LICENSE
BeeBot image source.
https://www.tes.co.uk/teaching-resource/bee-bot-sequence-powerpoint-6415227
"""

if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion scenarioWriters/ScenarioWriterDefault.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def main():
of this license document, but changing it is not allowed.
The full version of this license can be found here.
https://github.com/gregcorbett/SciBot/blob/master/LICENSE
https://github.com/stfc/SciBot/blob/master/LICENSE
BeeBot image source.
https://www.tes.co.uk/teaching-resource/bee-bot-sequence-powerpoint-6415227
Expand Down
Binary file modified scenarios/Default.scibot
Binary file not shown.
13 changes: 8 additions & 5 deletions src/BeeBot.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ def __init__(self, scenario):

# Store MOVE_BEEBOT_* events here.
self.memory = []
self.index = 0

self.running = False

def move(self, event):
"""Move the BeeBot."""
Expand All @@ -77,11 +80,11 @@ def add_to_memory(self, event):
self.memory.append(event)

def push_out_memory(self):
"""Act out the instructions in the BeeBot's "memory"."""
for instruction in self.memory:
# we use pygame's event queue because we need to check
# it regularly to prevent the game from crashing.
pygame.event.post(instruction)
"""Act out one instruciton in the BeeBot's "memory"."""
# If memory is not empty
if self.memory != []:
pygame.event.post(self.memory[self.index])
self.index += 1

def clear_memory(self):
"""Clear the BeeBot's "memory"."""
Expand Down
36 changes: 20 additions & 16 deletions src/Board.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,31 +28,35 @@ def __init__(self, scenario):

# Need to check the Board pixel height matches the image pixel height
if self.board_height != self.background_image.get_height():
print("Error 1: board height does not match image height")
print("Board Height = ", self.board_height)
print("Image Height = ", self.background_image.get_height())
exit()
raise ValueError(("Error 1: board height does "
"not match image height.\n"
"Board Height = %s\n"
"Image Height = %s"
% (self.board_height,
self.background_image.get_height())))

# Need to check the Board pixel width matches the image pixel width
if self.board_width != self.background_image.get_width():
print("Error 2: board width does not match image width")
print("Board Width = ", self.board_width)
print("Image Width = ", self.background_image.get_width())
exit()
raise ValueError(("Error 2: board width does "
"not match image width.\n"
"Board Width = %s\n"
"Image Width = %s"
% (self.board_width,
self.background_image.get_width())))

# Need to check the pixel height is a multiple of step
if self.board_height % self.step != 0:
print("Error 3: height % step != 0")
print("Height = ", self.board_height)
print("Step = ", self.step)
exit()
raise ValueError(("Error 3: height mod step != 0.\n"
"Height = %s\n"
"Step = %s" % (self.board_height,
self.step)))

# Need to check the pixel height is a multiple of step
if self.board_width % self.step != 0:
print("Error 4: width % step != 0")
print("Width = ", self.board_width)
print("Step = ", self.step)
exit()
raise ValueError(("Error 4: width mod step != 0.\n"
"Width = %s\n"
"Step = %s" % (self.board_width,
self.step)))

def display(self, screen):
"""Display the board on screen."""
Expand Down
Loading

0 comments on commit 1e5986d

Please sign in to comment.