Generate automatic movement
I am trying to generate an automatic movement for a soccer player. Trying to create the 8 possible cases that the player has, but when I am going to execute them, the player does not move, I do not know if I am calling the movement wrong or returning the movement wrong. Here is an image of how the court is:
package players;
public class SuJugador implements Player
public int move(int history, int player)
*
public static int casos(int $id,inthistory)
int Move= new int [2];
int x=history[history.length-1][0];
int y=history[history.length-1][1];
switch ($id)
case 1: x=history[history.length-1][0];
y=history[history.length-1][1];
Move[0]=x;
Move[1]=y-1;
break;
case 2: x=history[history.length-1][0];
y=history[history.length-1][1];
Move[0]=x+1;
Move[1]=y-1;
break;
case 3: x=history[history.length-1][0];
y=history[history.length-1][1];
Move[0]=x-1;
Move[1]=y-1;
break;
case 4: x=history[history.length-1][0];
y=history[history.length-1][1];
Move[0]=x;
Move[1]=y+1;
break;
case 5: x=history[history.length-1][0];
y=history[history.length-1][1];
Move[0]=x+1;
Move[1]=y;
break;
case 6: x=history[history.length-1][0];
y=history[history.length-1][1];
Move[0]=x-1;
Move[1]=y;
break;
case 7: x=history[history.length-1][0];
y=history[history.length-1][1];
Move[0]=x+1;
Move[1]=y+1;
break;
case 8: x=history[history.length-1][0];
y=history[history.length-1][1];
Move[0]=x-1;
Move[1]=y+1;
break;
return null;
public static boolean limit (int x, int y)
public static boolean validMove(int FutMov,inthistory)
if (history.length>1)
boolean permitex=false;
boolean permitey=false;
int Posx=history[history.length-1][0];
int Posy=history[history.length-1][1];
for (int i=0;i<history.length-1;i++)
if (history[i][0]== Posx)
if (history[i+1][0]== FutMov[0])
permitex =false;
else
permitex= true;
if (history[i][1]==Posy)
if (history[i+1][1]== FutMov[1])
permitey=false;
else
permitey= true;
return (permitey
return false;
}
java
add a comment |
I am trying to generate an automatic movement for a soccer player. Trying to create the 8 possible cases that the player has, but when I am going to execute them, the player does not move, I do not know if I am calling the movement wrong or returning the movement wrong. Here is an image of how the court is:
package players;
public class SuJugador implements Player
public int move(int history, int player)
*
public static int casos(int $id,inthistory)
int Move= new int [2];
int x=history[history.length-1][0];
int y=history[history.length-1][1];
switch ($id)
case 1: x=history[history.length-1][0];
y=history[history.length-1][1];
Move[0]=x;
Move[1]=y-1;
break;
case 2: x=history[history.length-1][0];
y=history[history.length-1][1];
Move[0]=x+1;
Move[1]=y-1;
break;
case 3: x=history[history.length-1][0];
y=history[history.length-1][1];
Move[0]=x-1;
Move[1]=y-1;
break;
case 4: x=history[history.length-1][0];
y=history[history.length-1][1];
Move[0]=x;
Move[1]=y+1;
break;
case 5: x=history[history.length-1][0];
y=history[history.length-1][1];
Move[0]=x+1;
Move[1]=y;
break;
case 6: x=history[history.length-1][0];
y=history[history.length-1][1];
Move[0]=x-1;
Move[1]=y;
break;
case 7: x=history[history.length-1][0];
y=history[history.length-1][1];
Move[0]=x+1;
Move[1]=y+1;
break;
case 8: x=history[history.length-1][0];
y=history[history.length-1][1];
Move[0]=x-1;
Move[1]=y+1;
break;
return null;
public static boolean limit (int x, int y)
public static boolean validMove(int FutMov,inthistory)
if (history.length>1)
boolean permitex=false;
boolean permitey=false;
int Posx=history[history.length-1][0];
int Posy=history[history.length-1][1];
for (int i=0;i<history.length-1;i++)
if (history[i][0]== Posx)
if (history[i+1][0]== FutMov[0])
permitex =false;
else
permitex= true;
if (history[i][1]==Posy)
if (history[i+1][1]== FutMov[1])
permitey=false;
else
permitey= true;
return (permitey
return false;
}
java
add a comment |
I am trying to generate an automatic movement for a soccer player. Trying to create the 8 possible cases that the player has, but when I am going to execute them, the player does not move, I do not know if I am calling the movement wrong or returning the movement wrong. Here is an image of how the court is:
package players;
public class SuJugador implements Player
public int move(int history, int player)
*
public static int casos(int $id,inthistory)
int Move= new int [2];
int x=history[history.length-1][0];
int y=history[history.length-1][1];
switch ($id)
case 1: x=history[history.length-1][0];
y=history[history.length-1][1];
Move[0]=x;
Move[1]=y-1;
break;
case 2: x=history[history.length-1][0];
y=history[history.length-1][1];
Move[0]=x+1;
Move[1]=y-1;
break;
case 3: x=history[history.length-1][0];
y=history[history.length-1][1];
Move[0]=x-1;
Move[1]=y-1;
break;
case 4: x=history[history.length-1][0];
y=history[history.length-1][1];
Move[0]=x;
Move[1]=y+1;
break;
case 5: x=history[history.length-1][0];
y=history[history.length-1][1];
Move[0]=x+1;
Move[1]=y;
break;
case 6: x=history[history.length-1][0];
y=history[history.length-1][1];
Move[0]=x-1;
Move[1]=y;
break;
case 7: x=history[history.length-1][0];
y=history[history.length-1][1];
Move[0]=x+1;
Move[1]=y+1;
break;
case 8: x=history[history.length-1][0];
y=history[history.length-1][1];
Move[0]=x-1;
Move[1]=y+1;
break;
return null;
public static boolean limit (int x, int y)
public static boolean validMove(int FutMov,inthistory)
if (history.length>1)
boolean permitex=false;
boolean permitey=false;
int Posx=history[history.length-1][0];
int Posy=history[history.length-1][1];
for (int i=0;i<history.length-1;i++)
if (history[i][0]== Posx)
if (history[i+1][0]== FutMov[0])
permitex =false;
else
permitex= true;
if (history[i][1]==Posy)
if (history[i+1][1]== FutMov[1])
permitey=false;
else
permitey= true;
return (permitey
return false;
}
java
I am trying to generate an automatic movement for a soccer player. Trying to create the 8 possible cases that the player has, but when I am going to execute them, the player does not move, I do not know if I am calling the movement wrong or returning the movement wrong. Here is an image of how the court is:
package players;
public class SuJugador implements Player
public int move(int history, int player)
*
public static int casos(int $id,inthistory)
int Move= new int [2];
int x=history[history.length-1][0];
int y=history[history.length-1][1];
switch ($id)
case 1: x=history[history.length-1][0];
y=history[history.length-1][1];
Move[0]=x;
Move[1]=y-1;
break;
case 2: x=history[history.length-1][0];
y=history[history.length-1][1];
Move[0]=x+1;
Move[1]=y-1;
break;
case 3: x=history[history.length-1][0];
y=history[history.length-1][1];
Move[0]=x-1;
Move[1]=y-1;
break;
case 4: x=history[history.length-1][0];
y=history[history.length-1][1];
Move[0]=x;
Move[1]=y+1;
break;
case 5: x=history[history.length-1][0];
y=history[history.length-1][1];
Move[0]=x+1;
Move[1]=y;
break;
case 6: x=history[history.length-1][0];
y=history[history.length-1][1];
Move[0]=x-1;
Move[1]=y;
break;
case 7: x=history[history.length-1][0];
y=history[history.length-1][1];
Move[0]=x+1;
Move[1]=y+1;
break;
case 8: x=history[history.length-1][0];
y=history[history.length-1][1];
Move[0]=x-1;
Move[1]=y+1;
break;
return null;
public static boolean limit (int x, int y)
public static boolean validMove(int FutMov,inthistory)
if (history.length>1)
boolean permitex=false;
boolean permitey=false;
int Posx=history[history.length-1][0];
int Posy=history[history.length-1][1];
for (int i=0;i<history.length-1;i++)
if (history[i][0]== Posx)
if (history[i+1][0]== FutMov[0])
permitex =false;
else
permitex= true;
if (history[i][1]==Posy)
if (history[i+1][1]== FutMov[1])
permitey=false;
else
permitey= true;
return (permitey
return false;
}
java
java
edited Nov 15 '18 at 7:14
Armali
7,7881238107
7,7881238107
asked Nov 15 '18 at 0:41
DefyDefy
1
1
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
I do not know if I am calling the movement wrong or returning the movement wrong.
Apparently, you forgot to return the move from your casos() function, which only does return null;.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53310875%2fgenerate-automatic-movement%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I do not know if I am calling the movement wrong or returning the movement wrong.
Apparently, you forgot to return the move from your casos() function, which only does return null;.
add a comment |
I do not know if I am calling the movement wrong or returning the movement wrong.
Apparently, you forgot to return the move from your casos() function, which only does return null;.
add a comment |
I do not know if I am calling the movement wrong or returning the movement wrong.
Apparently, you forgot to return the move from your casos() function, which only does return null;.
I do not know if I am calling the movement wrong or returning the movement wrong.
Apparently, you forgot to return the move from your casos() function, which only does return null;.
answered Nov 15 '18 at 7:17
ArmaliArmali
7,7881238107
7,7881238107
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53310875%2fgenerate-automatic-movement%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown