'can anyone find out why only the x axis is working?

i was trying give my own take at makeing some sort of "wave function colapse", it seems to work on the x axis but i dont know whats the problem with the y one.

def colapseMap(map):

    for y in range(len(map)):
        for x in range(len(map)):

            up = map[(y-1)%len(map)][x%len(map)]
            upPosibilities = []
            for i in range(len(up)): upPosibilities += posibleNextState(up[i], initialEntropy)

            down = map[(y+1)%len(map)][x%len(map)]
            downPosibilities = []
            for i in range(len(down)): downPosibilities += posibleNextState(down[i], initialEntropy)

            left = map[y%len(map)][(x-1)%len(map)]
            leftPosibilities = []
            for i in range(len(left)): leftPosibilities += posibleNextState(left[i], initialEntropy)

            right = map[y%len(map)][(x+1)%len(map)]
            rightPosibilities = []
            for i in range(len(right)): rightPosibilities += posibleNextState(right[i], initialEntropy)

            accpns = list(set(list(set(list(set(upPosibilities).intersection(downPosibilities))).intersection(leftPosibilities))).intersection(rightPosibilities)) #adjacent cells comun posible next states
            map[y][x] = [accpns[randrange(len(accpns))]]

    return map

it was suposed to output something kid of like this:

[0] [1] [1] [1] [1] [2] [3] [2] [2] [1]
[1] [2] [1] [1] [0] [1] [2] [2] [3] [2]
[1] [2] [2] [1] [1] [1] [2] [3] [3] [2]
[2] [3] [3] [2] [2] [2] [3] [3] [4] [3]
[3] [3] [4] [3] [3] [2] [3] [4] [4] [4]
[4] [4] [5] [4] [4] [3] [3] [4] [5] [4]
[3] [4] [5] [5] [5] [4] [4] [4] [4] [3]
[2] [3] [4] [4] [4] [4] [4] [3] [3] [2]
[2] [3] [3] [3] [3] [2] [3] [2] [2] [1]
[1] [2] [3] [2] [1] [2] [3] [2] [1] [0]

but it does this instead:

[0] [1] [1] [0] [1] [2] [3] [2] [2] [1]
[0] [1] [1] [0] [1] [2] [3] [2] [2] [1]
[0] [1] [1] [0] [1] [2] [3] [2] [2] [1]
[0] [1] [1] [0] [1] [2] [3] [2] [2] [1]
[0] [1] [1] [0] [1] [2] [3] [2] [2] [1]
[0] [1] [1] [0] [1] [2] [3] [2] [2] [1]
[0] [1] [1] [0] [1] [2] [3] [2] [2] [1]
[0] [1] [1] [0] [1] [2] [3] [2] [2] [1]
[0] [1] [1] [0] [1] [2] [3] [2] [2] [1]
[0] [1] [1] [0] [1] [2] [3] [2] [2] [1]


Solution 1:[1]

You should try this jQuery Code and PHP Code by replacing them in your code section, It will definitely work for you:

<script type="text/javascript">
    function loginSubmitFormData() {
    var loginemail = $("#loginemail").val();
    var loginpassword = $("#loginpassword").val();
    var source = $("#source").val();
    $.post("authlogin.php", { loginemail: loginemail, loginpassword: loginpassword },
       function(data) {
         var data = jQuery.parseJSON( data );
         console.log(data);
         $('#loginresults').html(data.message);
         if(data.redirect_url){
            window.location.href = data.redirect_url;
         }
         $('#loginmyForm')[0].reset();
       });
}
</script>

<?php
    session_start();
    include 'config/info.php';

    // get the details from form 
    $email=$_POST['loginemail'];
    $password = stripslashes($_REQUEST['loginpassword']);
    $password = mysqli_real_escape_string($conn,$password);

    $sql="SELECT * FROM user_info WHERE email='".$email."'";
    $result = mysqli_query($conn,$sql);
    $Countrow = mysqli_num_rows($result);
    if ($Countrow == 1) {
        $fetchrow = mysqli_fetch_assoc($result);  
        $loginpassword = $fetchrow['password'];

        // Verify the password here
        if (password_verify($password, $loginpassword)) {
            $_SESSION['email'] = $email;
            //setcookie('username', $adminID, time() + (86400 * 30), "/"); 
            $date = date('Y-m-d H:i:s');
            $ActivityStmt = "INSERT INTO login_activity (`email`, `last_login`, `browser`, `os`, `ip_address`) VALUES('".$email."', '".$date."', '".$gen_userBrowser."', '".$gen_userOS."', '".$gen_userIP."')";
            $ActivityResult = mysqli_query($conn, $ActivityStmt);

            $message = 'Login Successfully!';
            
            $response = array(
                'message' => $message,
                'redirect_url' => 'https://www.example.com',
            );
            
            exit();
        }
        else{
            $message = 'Incorrect Password';
            $response = array(
                'message' => $message
            );
            exit();
        }
    }
    else{
        $message = 'User does not exit';
        $response = array(
            'message' => $message,
        );
        exit();
    }
    
    echo json_encode( $response);
    ?>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1