Giter Site home page Giter Site logo

slither's Introduction

  • Represtations/Notations used :

Positive edges- Edges which are part of the cycle.
Positive cell - Cell which is not a blank/space.

"+"	=> grid-node
"-|"	=> Positive-edges
"#"	=> empty cell
"*"	=> empty edge (non-filled edge)
  • Cell locations and reading input :

Numbering starts at 0.
triple : 11U =>  2; 11L =>  8; 11R => 10; 11D => 16
	 21U => 16; 21L => 23; 21R => 25; 21D => 32

nr : cell-row; nc: cell-col; NC: Total number of columns	
Cell number formulae: (2nr -1) * (2NC + 1) + 2nc
edge number formulae: (
  • Game-Play / Algo :

1.First check if the entered move is valid or not.
	Valid: 	Each grid-node can have 0/2 edges.
		Not redrawing the same input (Need to flip the edge selection-phase-2)
	
2.If valid: 
  • Game over check:

1-All cells have given number of adjacent edges
2-No grid-node have open edge (only 1 edge, it should have either 0/2 edges)
3-Form only 1 cylce

1.Each positive cell is stored in a hashmap with location as key and its number as value. Same cell location is inserted into a list(Incomplete cell list (ICL)).
  Whenever user enters a new triple we decrease that cell value by 1. When value becomes 0 we remove that cell from the ICL. When value becomes <0 or >0 we check for that cell in list and add if not present.  When ICL is empty it means cells-edges-constraint is satisfied. Proceed to check (2).

2.Maintain a hashmap for all the grid-nodes and no.of edges as value. Maintain all the grid-nodes with only 1 edge in a list. When this list is empty then all grid-nodes have either 0/2 edges. Proceed to check (3).

3.To check if only 1 cycle after game-over:	
	- Store all positive edges while user entering. 
	- Select any one edge among them and start navigating till you reach same edge. Then count the edges in this navigated cycle and total positive edges. If both are same then game-over.

slither's People

Contributors

jaideepb avatar

Watchers

James Cloos avatar  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.