Giter VIP home page Giter VIP logo

percolation's Introduction

Percolation

My Forest Fire Modeling and Search Algorithms Project

A. Class and methods:

Forests of Certain Density

  • I modeled a forest as a two-dimensional list where each cell can either be occupied by a tree or empty.
  • For a value d (between 0.0 and 1.0), a forest has density d if each cell is a tree with probability d or empty with probability (1 - d).

Modeling the Spread of Fire

  • I modeled a forest fire by setting trees in the top row on fire.
  • Fire spreads to neighboring trees (left, right, up, or down).
  • A forest fire spreads if the fire makes it to the bottom row.

What I Implemented

  • I created a class Forest representing the forest.
  • The class has instance variables for the two-dimensional list of integers and two integers for the height and width of the grid.
  • __init__(): takes integers for width and height, and float d for density. Creates the two-dimensional list and sets each element to either 1 (contains tree) with probability d or 0 (empty) with probability (1 - d).
  • __str__(): returns string representation of the two-dimensional array.
  • depth_first_search(): returns true if fire spreads using depth first search.
  • breadth_first_search(): returns true if fire spreads using breadth first search.

B. Depth First Search and Breadth First Search Algorithms

Depth First Search (DFS)

  • I stored elements in a stack to expand one neighbor fully before moving onto the next.

Breadth First Search (BFS)

  • Similar to DFS but uses a queue instead of a stack.

percolation's People

Contributors

muskanf avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.