Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

trémaux’ method java

Trémaux method Java
-helps you to solve a Labyrinth
-there are two kind of Fields:
	-Ways (there are two walls and just two free fields (one where you came from and one where you will go to)
    -Crossings (there are at least three open ways) you have to mark the way where you came from and where you will go to)
 -if a path has two or more marks do not cross it

-Let´s Go:
> if there are two walls and two open ways, choose the way you didn´t came from
> if there are are at least three open ways:
 > mark the direction wehre you came from
  > if you never visited the crossing before choose one of the paths and mark it too
  > if you visited the place before (there allready is a mark in at least one direction (not counting the one you just put behind you)) go back and mark the way again
   > if you visited the place before and behind you allready are two marks choose one of the paths with the smallest number of marks (0 or 1)
   > if there are two or more marks or walls in every direction you just walked through the whole labyrinth

-the labyrinth is a twodimensional Array
-at a crossing you will scan the diffrent directions (left, ahead, right, back), so you will need a second system based on compass directions to change the coordinates
	-For Example: Laby[y][x]
    
    			  North = 1; East = 2; South = 3; West = 4;
    			  startDirection = 3;	                                N
                  if you move right: direction = direction + 1         ###
                  if you move left: direction = direction - 1         W# #E
                  if you move forward: direction stays the same        ###
                  if you turn around: direction = direction + 2         S
                  	if direction = 5: direction = 1 //in case you want to turn from South to North
                    if direction = 6: direction = 2 //in case you want to turn from West to East
                  
                  if direction = 1: changePosition: y + 1 (go one field up(North))
                  if direction = 2: changePosition: x + 1 (go one field right(East))
                  if direction = 3: changePosition: y - 1 (go one field down(South))
                  if direction = 4: changePosition: x - 1 (go one field left(West))
                  
//If I could help you, I would appreciate a little donation                  
Comment

PREVIOUS NEXT
Code Example
Java :: how to find the size of table in java 
Java :: fail if condition not met in java if condition 
Java :: how to refresh activity intent in android 
Java :: luckperms api get usser by uuid 
Java :: Algorithms - decision 
Java :: what is this code (long millis=System.currentTimeMillis(); java.sql.Date date=new java.sql.Date(millis); 
Java :: Java @Target 
Java :: detect view in scrollview android 
Java :: spring boot rest api 
Java :: how to configure multiple database in spring boot based for uat and dev environment 
Java :: example of throws clause in method 
Java :: setCookie("showPopupBannerBeta", 1, 1 
Java :: find the length of jtextfeild in java 
Java :: Double matrix 
Java :: kakao tech tcp close_wati 
Java :: change activity main drawer items text color android 
Java :: java default constructor 
Java :: how to set edittext color in android 
Java :: arraylist add method 
Java :: arraylist contains doc 
Java :: java tutorialspoint 
Java :: composite design pattern 
Java :: Exception in Application start method java.lang.reflect.InvocationTargetException 
Java :: Java if Keyword 
Java :: how to convert integer to list in python 
Java :: why does the ribbon dependency crush my app 
Sql :: mysql create user 
Sql :: loading local data is disabled mysql 
Sql :: doublon sql 
Sql :: get tables in database sql 
ADD CONTENT
Topic
Content
Source link
Name
9+2 =