Skip to content

BrainTeazer/bug-world

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

README for Bug World

BugWorld is an environment of two swarms of bugs, where the goal of the bugs is to collect the most food and bring it back to their base. This is an implementation of the game using HTML, CSS, and Javascript. This project aims to implement an assembler to parse bug instructions, a GUI for the simulator, and the actual simulator itself.

Libraries / Frameworks / Environments

Getting Started

Prerequisites

Please install npm to use the testing framework Jest.

Installation


git Clone

# Clone the repository
## (via HTTPS)
git clone https://github.com/BrainTeazer/bug-world.git 


# Move to the directory
cd bug-world/src/

Inside bug-world/src/, open start.html in your browser.

clabsql

You can directly access the website here. (Note: you need to use Constructor VPN, or be on university premises)

Usage


Valid files to upload are in bug-world/input_files/ with the naming scheme valid-*.world. Invalid files have the naming scheme invalid-*.world. Currently, the bug assemblers are not functional so there is a placeholder bug.buggy file as well.

To continue to simulation.html, all files must be uploaded and the world map must be valid. The same file can be uploaded for both bug files.

Note: The end of game page cannot be accessed directly via the UI of the website currently. You can access it by opening bug-world/src/end.html in your browser OR by using the clabsql link here

Testing

First go to bug-world/ and run:

npm install

Then to run the test cases go to bug-world/ and run:

npm test

File Structure

bug-world/
 ┣ input_files/
 ┃ ┣ bug.buggy
 ┃ ┣ invalid-1.world
 ┃ ┣ invalid-2.world
 ┃ ┣ invalid-3.world
 ┃ ┣ invalid-4.world
 ┃ ┣ valid-1.world
 ┃ ┣ valid-2.world
 ┃ ┣ valid-3.world
 ┃ ┗ valid-4.world
 ┣ scripts/
 ┃ ┣ bug_assembler/
 ┃ ┃ ┣ instructions/
 ┃ ┃ ┃ ┣ Direction.js
 ┃ ┃ ┃ ┣ Drop.js
 ┃ ┃ ┃ ┣ Flip.js
 ┃ ┃ ┃ ┣ Label.js
 ┃ ┃ ┃ ┣ Mark.js
 ┃ ┃ ┃ ┣ Move.js
 ┃ ┃ ┃ ┣ PickUp.js
 ┃ ┃ ┃ ┣ Sense.js
 ┃ ┃ ┃ ┣ Turn.js
 ┃ ┃ ┃ ┗ Unmark.js
 ┃ ┃ ┣ Assembler.js
 ┃ ┃ ┣ CellDirection.js
 ┃ ┃ ┣ Condition.js
 ┃ ┃ ┣ Direction.js
 ┃ ┃ ┣ Grammar.js
 ┃ ┃ ┗ peg-0.10.0.min.js
 ┃ ┣ game_logic/
 ┃ ┃ ┣ Bug.js
 ┃ ┃ ┣ BugBrain.js
 ┃ ┃ ┣ BugCondition.js
 ┃ ┃ ┣ Color.js
 ┃ ┃ ┣ Position.js
 ┃ ┃ ┣ World.js
 ┃ ┃ ┗ WorldCell.js
 ┃ ┣ simulator/
 ┃ ┃ ┣ Engine.js
 ┃ ┃ ┣ GUI.js
 ┃ ┃ ┣ Simulator.js
 ┃ ┃ ┗ Tournament.js
 ┃ ┣ CreateWorldMap.js
 ┃ ┣ Files.js
 ┃ ┣ PageSwitch.js
 ┃ ┣ ParseWorldMap.js
 ┃ ┗ simulation.js
 ┣ src/
 ┃ ┣ end.html
 ┃ ┣ simulation.html
 ┃ ┗ start.html
 ┣ styles/
 ┃ ┣ simulation.css
 ┃ ┗ style.css
 ┣ test/
 ┃ ┣ Bug.test.js
 ┃ ┣ ParseWorldMap.test.js
 ┃ ┣ Position.test.js
 ┃ ┗ WorldCell.test.js
 ┣ README.md
 ┣ package-lock.json
 ┗ package.json

Sprint Progress

  1. Created functional welcome page
  2. Created functional end of game page
  3. Created settings page, homepage, change settings page, and a functional quit game page
  4. Created enumerations:
  • CellDirection
  • Direction
  • Condition
  • Color
  • BugCondition
  1. Implemented Position class:

    • Constructor
  2. Implemented WorldCell class:

    • Constructor
    • isObstructed()
    • isOccupied()
    • isFriendlyBase(color)
    • isEnemyBase(color)
    • isFriendlyMarker(color, position)
    • isEnemyMarker(color, position)
    • cellMatches(position, bugCondition, color)
    • setFood(amt)
    • setBug(bug)
    • clearMarker(color, position)
    • setMarker(color, position)
    • getBug(bug)
    • getFood()
    • removeBug()
    • toString()
  3. Partially implemented World class:

    • Constructor
    • isObstructedAt(pos)
    • setFoodAt(pos, amt)
    • setBugAt(pos, bug)
    • cellAt(pos)
    • getFoodAt(pos)
    • getBugAt(pos)
    • removeBugAt(pos)
  4. Partially implemented Bug class:

    • Constructor
    • getPosition()
    • toString()
  5. Created Assembler class with a stub assemble(file) function

  6. Implemented BugBrain class

    • Constructor
    • getNextInstruction
  7. Partially implemented GUI class

    • Constructor
    • setIterationsNumber(num)
    • setOptions(bool)
    • getIterationsNumber()
  8. Implemented Simulator classes constructor

  9. Implemented file upload and ability to file parse (all on client-side)

  10. Partially implemented parsing of world map file (.world file)

    • Checks for closed border
    • Checks that both swarms are present
    • Checks for valid characters
    • Checks for valid dimensions
    • Checks for valid map file length that corresponds to given dimensions
  11. Implemented creation of map on the web page using a World object created after parsing the world map file (each cell is uniquely colored based on the cell type)

  12. Documentation / Comments for each function implemented

  13. Added test cases for:

    • parseMapFile(mapFile) (location: bug-world/scripts/ParseWorldMap.js)
    • Methods in WorldCell.js (location: bug-world/scripts/game_logic/WorldCell.js)
    • Methods inBug.js (location: bug-world/scripts/game_logic/Bug.js)
    • Methods in Position.js (location: bug-world/scripts/game_logic/Position.js)
  14. Added type checking for various methods in:

    • World.js
    • WorldCell.js
    • Position.js
    • Bug.js
    • BugBrain.js
  15. Created files for all classes in UML diagram.

About

BugWorld is a simulation game.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published