Rock-Paper-Scissors Algorithm - Code A Java Class That Plays ?

Dec 5, 2011

I have an assignment to code a java class that plays rock, paper, or scissors. The class can access the history of past gestures played by both itself and its opponent, but nothing else. The class will be played against others in 10,000 matches and the winner will be determined via round robin format. Other than using a greedy algorithm to determine statistically the best choice from prior gestures and basic pattern recognition I have no decent ideas.

View 6 Replies


ADVERTISEMENT

If Paper - If Else Rock - Else Scissors?

Apr 12, 2011

I have been working on a "Rock Paper Scissors" game to see if I understand the basics of JavaScript. It all works well until I get to the if statement from lines 30 to 71 in the `fight()`: I have adjusted the reply variable to indicate how it may be "if'ing" through. It seems to be returning the default value of every sub "if" in the overall "if". Am I using the wrong variable for the secondary condition maybe?

Code HTML4Strict:

View 1 Replies View Related

HTML Rock Paper Scissors Game?

May 8, 2011

I'm writing a JavaScript application that would prompt the user for a number between 0 and 2, generate a random number for the computer, then take that input and display two images (in this case two hands making rock, paper, or scissor symbols at each other) using an array, and displaying text indicating a win, draw, or loss. I'm having a lot of problems getting this to work as I am new to JavaScript and am wondering if anyone could help me fix this problem. I just want the input from the prompt AND the random number to translate to what in the array should be displayed and what text is then shown at the bottom.

[Code]..

View 3 Replies View Related

Game - Rock Paper Scissors - Make The Playagain Function Work

Apr 24, 2010

I have written a game of rock, paper, scissors. There are two things I would like to do here:

1. Make the playagain function work. I would like to have a variable start out as 'y', then be redefined as either 'y' or 'n' when the prompt occurs. If this is not possible, any other way to make this work would be welcome.

2. Use <div> tags and CSS to make .swf's appear and disappear accordingly.

EX: I say scissors, Computer says paper. An swf is played of scissors beating paper. When the anim is over, it disappears, and the game continues.

The Code:

Code:

View 3 Replies View Related

Remove String From My Rock - Paper Scissor Java Game?

Oct 18, 2011

First of all, I wanna make my code using (while loop, do while loop, int, double, if, else, else if, Math.random, Scanner-- not string or boolean).

-Actually the game goes like, after the user and the computer has has selections it is gonna be displayed and then tell who wins and who does not--I dont know how to do it.

- When user presses 4, the the computer tells wins, loses and ties. This happens to me after two tries, wheteher i press 4 or not.(actully its |y/n| in mine and i want to change it to just 4 to quit).

-The user is only allowed numbers from 1 to 4, but apparently, i add any number and it works.

-My code gos like this:

View 2 Replies View Related

Variable Assignments In Rock - Paper - Scissor Game

Apr 4, 2009

I am having a very hard time with this game. i can get the userChoice image to display, and the computerChoice image to display, but i cannot get the checkWinLoseTie() function to work. but i am unsure WHY it isnt working. are my arguments wrong (i know there is something wrong, but cannot get it right!), are the variables even getting assigned a value?

I keep getting the message "you lost" which means that the rest of the stuff is not running!

Here is my code:

This is my other code (ive been trying to get either or to work! cant figure out which one woudl be best)

View 1 Replies View Related

Recommended Algorithm To Obfuscate Code?

Oct 20, 2009

I want obsfucate and compress the code for my website (HTML, CSS but especially Javascript). Are there any industry standard algorithms that are recommended?

View 5 Replies View Related

Calling A Java Class From Within Javascript

Aug 23, 2006

Can you call a java class from within a javascript?

View 1 Replies View Related

Getting A Code To Open A Java Alert On Another Website?

Apr 14, 2011

My website was recently ftp hacked and a file inserted into it - js.php - which seems to be some sort of advertising spam programme. Having spotted the file I have renamed it to hide it but lots of other sites are still referring into my site looking for this php file. What I would like to do is to *just* open a java alert box on the referring sites to alert the users that the site has been hacked and that they should notify the webmaster so that he can fix his site.The line referring into my site is -

<script type="text/javascript" src="http://www.mysite.com/js.php"></script>

Is this something simple to do?

View 3 Replies View Related

Place Java Code In An External File - .js

Nov 9, 2011

Can you place java code in an external javascript file (.js).

For example can I do the following in my xx.js file.

Can I do the above?

Another question ...I know <% %> is to execute java code inside html. But what does <%-- - -%> mean?

View 3 Replies View Related

Code Comparison Chart By Using JAVA Or Any Kind Of Scripts?

Mar 31, 2010

Have a question regarding the comparison function on the At & t website URL...The site allows you to select different types of phones then generate a comparison chart based on your selection. I need to construct a similar comparison chart, but have no idea how to start the coding process.

View 1 Replies View Related

JQuery :: Generate Dynamic Html Code Via Java Serlvets?

Aug 11, 2010

I want to generate dynamic html code via java serlvets.from the class LightServlet

public void getAllLights(HttpServletRequest request,
HttpServletResponse response) throws IOException,
NumberFormatException, InvalidSyntaxException {

[code]....

I think, the problems should be in the jQuery code, because it works with normal strings without any html tags.

View 5 Replies View Related

Java Applet Development - Code To Check Whether JRE Is Installed On Client Machine?

Aug 19, 2009

Java Applet Development - JavaScript code to check whether JRE is installed on client machine.

View 4 Replies View Related

Algorithm

May 6, 2005

i am trying to store some shopping cart details in a cookie. I have been able to do that but i want to now retrieve the values and put them in a shopping cart table. An example of the cookie file is

Product1=value,Quantity1=value,Price1=value,Extras1=value;
Product2=value,Quantity2=value,Price2=value,Extras2=value;

I have been able to retrieve the 2 cookies

cookieArray = document.cookie.split("; ")
for(i=0; i<cookieArray.length ; i++)
{
document.write(cookieArray[i] +"<br>")
}

But now for each Product i want to retrieve the 4 values. Can anyoine help me with this or suggest a better way to achieve the same thing.

View 7 Replies View Related

JQuery :: No Action While Animation Plays?

Sep 12, 2010

Im making a web site, which i click on a link and i do some animation. What i want to do is when i click in other link while the animation of the first that i clicked is playing, the action of this new link (click) do not fire ... how can i do this ?

View 1 Replies View Related

Rock And Hard Place - To Swf Object

Aug 30, 2009

If this issue is a JavaScript syntax issue, then I just know you'll spot it.

Context: swfObject2 dynamic embedding.. so the swf object is not written into the code that's sent to the browser. (The swf is there on the resulting page in the browser; doing it's thang just dandy and waiting for further instruction from user action). Function in swf "functInSWF" registered using ExternalInterface.callback(); (I'm working in AS2).

So... javascript:

Code:

The message I'm getting in the debugger is: "TypeError: Result of expression 'thisMovie("someSWF").functInSWF' [undefined] is not a function"... so I'm presuming nothing is being sent to the swf and therefore this is a JavaScript issue I need to track down.

I've tried (what's not recommended) getElementById with the same result.

View 1 Replies View Related

Optimizing String Shortening Algorithm?

Aug 16, 2010

I've written a function that "condenses" a string if it is too long.

function shortenMsg(msg,maxLen){
if (msg.length > maxLen){
var over = msg.length - maxLen, // amount that needs to be trimmed

[Code]....

Each of the methods 1-3 is the amount that that specific method can trim from the string. I'd like to be able to trim as little as possible.

For example, if the string needs 5 characters to be trimmed, and method1 can trim 8 characters, but method3 can trim 6, then method3 should be used. If none of the methods can individually trim the string enough, then I'd like the optimal combination of the methods that will get the job done.

I can't figure out what sort of code structure I need for this (besides a ton of if/else statements). Maybe an array that contains each of the methods, arranged in increasing order....?

View 10 Replies View Related

What Is The Algorithm To Compute The Factorisation Of An Integer?

Oct 30, 2006

I need some ideas on how to compute the factorisation of a non-zero integer?

For example:

if the user input is 8, its factorisation is 1 * 2 * 2 * 2;
if the user input is -300, its factorisation is -1 * 2 * 2 * 3 * 5 * 5

Does anyone know?

View 3 Replies View Related

Algorithm To Calculate Mortgage Payments..

Nov 2, 2004

Does anybody know of an algorithm to calculate mortgage payments? e.g.

Amount: 100,000
Interest Rate: 4.5%
Term: 25 Years

Monthly Payments: x

I've looked at other js scripts to do this but it seems alot more involved then I thought, and because they use non descriptive variable names I can't work any of them out..

View 1 Replies View Related

HTML5 Video & JS - Only Audio Plays?

Nov 23, 2011

I worked on this website :[URL]and cannot find out why it does not work in IE while it works in other browsers. The small video does not play while the sound does. As far as I can see it works fine in FF and Chrome.

View 1 Replies View Related

Algorithm Only Finds Vertical Path?

Jan 19, 2010

I recently started on an browser based MMORPG, I just found 1 major issue.I'm using these libraries

JS A* Algoritm ( http://devpro.it/code/137.html )
Jquery ( http://www.jquery.com/ )
Jquery UI (http://ui.jquery.com/ )

So I'm using a little piece of JavaScript code in which im accessing the AStar function. The downside is, the AStar algorithm only finds vertical tiles. (See screenshots below)

function mapmouse (obj) {
//Get the coordinates
coords = obj.id.split('_');

[code]....

If you choose a non-vertical path, var path gives an empty array (path.length = 0 )If I choose a vertical path, it's working as intended.

As you can see with this little test here, the AStar function itself is working properly (the libs.js is used by both the game and the example)[URL]

View 1 Replies View Related

XSPF Web Music Player Plays Song Twice

Dec 16, 2009

I am using XSPF Web Music Player slim, and whenever I put it into a web page and play it using Google Chrome or Safari the song starts playing twice. When i press the pause button one instance of the song keeps playing while the other keep going without any control over it. This only happen on Google Chrome and Safari on both Windows and Macs so I think it is a problem with the player and WebKit.

I am not using play-list file because the player is only playing one song so I used some parameters somewhere for the player making it so I did not need a play-list file. I also wanted it to play automatically so included a parameter for that. This is my code:

<object type="application/x-shockwave-flash" width="720" height="30" data="xspf_player.swf?song_url=song.mp3&song_title=Song Name&autoplay=1">
<param name="movie" value="xspf_player.swf?song_url=song.mp3&song_title=Song Name&autoplay=1" />
<param name="wmode" value="transparent" />
</object>

I have the autoplay=1 so it will play automatically. When I take this away it only play one instance of the song but requires manual play. So you have to push the "play" button. How do I fix it so it does not play the song twice on Chrome and Safari?

View 1 Replies View Related

Javascript And Printing On Paper?

Mar 3, 2006

I want to print tables on a regular printer with A4 paper. How do I send data to the printer? And is there a processor for sending html to the printer that the printer understands.

One solution is to open a new window with the javascript and execute a php script that generates tables on that page and then just executes the browsers print version.

However, that is not what I want. I want it to send data to the printer without having to ask the user of permission. Any solution?

View 3 Replies View Related

Highlight Word In Html File On Which Audio Plays?

Jul 11, 2011

I am developing application in java. here wat i have to do is to highlight words in html file. ie) i have one html file and same content in audio file. when i open the html file audio should play n it should highlight the word in html file on which audio plays. for eg) i have html file with content " hello world". i have same audio file saying "hello world". now when i open html file and click audio, and if audio says hello, hello should highlight in html file, then audio says world, world should highlight in html file. how to do this.

View 1 Replies View Related

Make A Script That Speaks Then Plays Music When Its Finished

Jan 24, 2010

I am trying to make a script that speaks then plays music when its finished, below is my script. The trouble is its just a script file there is not html or anything meaning its opened with Windows Script Host.

[Code]...

View 12 Replies View Related

Print Out Datagrid To Paper Using Web Control?

Jul 27, 2005

how to print out datagrid to paper using web control? i am using asp.net in vb.net.... is it need to use javascript to write at the html part? i need to know the print function.

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved