Coding AI Game Through Java

Apr 10, 2015

The game has two players: x and o. The players take alternate turns, with player x moving first at the beginning of each game.

Player x starts at position (1,1) while o starts at (8,8).

Each turn, a player can move like a queen in chess (in any of the eight directions) as long as her path does not cross a square already filled in or occupied. After moving, the space vacated by the player is designated as filled and cannot be moved to again. Notice that only the space that was occupied is filled, not the entire path.

The game ends when one player can no longer move, leaving the other player as the winner.

The coordinate (1 1) indicates the top left hand side of the board.

The board is specified as a list of rows. Each row is a list of entries:

- is an empty square * is a filled in square x is the current position of the x player o is the current position of the o player

The board will always be 8 by 8.

Your player function should take in the parameters as described above and return a move as a list in the format (row column) within 1 minute. If you cannot move, return (nil nil). The Tournament Referees will check for this. If you return an illegal move, the other player (and the Tournament Referees) will detect it and you will lose.

Additionally if your time expires you will lose.

View Replies


ADVERTISEMENT

Game Coding - No Enclosing Instance Of Type Background Is Accessible

Dec 11, 2014

So I'm fairly new to java and have been learning game development. I've come across this error message on my StartingClass.java coding. Here is the Coding

@Override
public void start() {
bg1 = new Background(0,0); // This line is giving me the error!!!!!!!!!!!
bg2 = new Background(2160, 0);
hb = new Heliboy(340, 360);
hb2 = new Heliboy(700, 360);
robot = new Robot();

Thread thread = new Thread(this);
thread.start();

The error reads "No enclosing instance of type BackGround is accessible. Must qualify the allocation with an enclosing instance of type BackGround (e.g. x.new A() where x is an instance of BackGround)." Now I have seven classes in my in my games src folder and none of them but the StartingClass.java has the error. Once again I'm fairly new to java and have not benn able to fix it.

These are the classes{

BackGround.java
Enemy.java
Heliboy.java
package-info.java
Projectile.java
Robot.java
StartingClass.java ( errors in this class )
}

View Replies View Related

Java Coding For Block Division

Feb 7, 2014

I'm doing project in area of "Cryptography and Network security". I'm having a file with binary Unicode (mean file contain Unicode value of corresponding data (text file)), want to divide that as blocks with the size of 144bits.

View Replies View Related

Make A Circle With Java Coding

Aug 12, 2014

i want to make a circle with java coding.... i tried but i am grtting some error...

View Replies View Related

Java Coding For Constructors And Input

Oct 25, 2014

I was required to make a program that contains 3 data fields, 2 constructors, and 4 methods. I'm having a hell of a time trying to put some input into this, where the user would choose from 1 of the 3 data fields I made up for car prices and choose their vehicle. As far as the constructors go, I made a default one but I'm not sure on how to A) implement another constructor and how do I involve the input into this and C) where the methods go in that.

I'm thinking of putting the input first but that ruins my constructors? I realize I asked a lot, but this is an online class without a text, and I'm basically starving for knowledge. [code]

public class Vehicle{
int truck;
int car;
int van;

[code]....

View Replies View Related

How To Read USB Signal Values Through Java Coding

Apr 15, 2014

how to read a usb signal values through java coding

View Replies View Related

Coding A Coinage

Sep 26, 2014

Listed below is the program I put together for class. I followed all of the instructions ....

import java.util.Scanner;
public class coinageJones{
int quarter = 0;
int dime = 0;
int nickel = 0;
int penny = 0;
int current = 0;
int original = 0;
int remainder1 = 0;
int remainder2 = 0;
int remainder3 = 0;
int remainder4 = 0;

[code]...

View Replies View Related

What Is The Coding For Udp Port Scanning

Feb 3, 2014

what is the coding for udp port scanning?

View Replies View Related

Avoid Deadlock While Coding

Jul 25, 2014

is it possible to avoid deadlock while coding..

View Replies View Related

Coding Own Classes - If Condition?

Jun 9, 2014

public int getIndexOfAMonster(String nameToGet){
int retValue = -1; //default is not found
for (int i = 0; i <= numberOfMonsters - 1; i++)
if (monsters[i].getName().equals(nameToGet))
retValue = i;
return retValue;
}

1.What does the if-condition do?If the name of a monster in the array is equal to the name stored in the variable, return the monster's assigned value.

2.What does the for loop do? The loop condition simply loops through the whole arraylists. (In other words, it simply checks each Monster contained in the lists).

3.Assuming that the driver code compiles, explain what it’s use is? If the name of the monster is the same as the variable passed unto this method, return the number assigned to that Monster.

View Replies View Related

Eclipse - Coding Multiple If / Else Statements

Apr 22, 2015

What I am attempting to program is a simple Boss battle. I would like the user to have 2 options (for now): Run, or Attack. I got the portion completed and working, but once I tried to implement the Run feature (the way that it's supposed to work is you can either attack OR run), both Attack and Run will happen. Also, for some reason, the running always fails (it will always return the else statement, then move onto the attack.) Here's my code:

import java.util.*;
public class AdvancedBossBattle {
public static void main (String[] args) {
Scanner scan = new Scanner (System.in);
Random gen = new Random();
int bosshp, bossdmg, playerhp, playerdmg, runChance;
String answer;
bosshp = 100;

[Code] ....

View Replies View Related

Electric Bandit Machine Coding

Jan 8, 2015

I am required to create an electronic bandit machine that can display all images and buttons, user can input money, random display of images, machine stop when money runs out, user can put money in and start again and also a display of winnings. So far The user can input money and this is added to their bank however when the spin button is clicked no shapes appear despite their being a selection of images. My code is below.

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import java.util.*;
import javax.swing.Timer;

[code]....

View Replies View Related

Sieve Coding Not Pairing In Output

Apr 1, 2015

When I compile the code, it goes through fine in the compiler. However after entering the boundaries for the lower an upper it doesn't produce the prime pairs between the two boundaries that the user sets. I have tried changing some of my integers that i initialized no luck. I looked at the last section of public void showPrimes() . However I can't seem to see where it has gone wrong there. I have included the entire code, plus the section again that I think is wrong. I have also posted the final output of what it looks like and what else should be included to make it easier to see what I am missing. Basically it keeps giving me zero primes even when the boundary is 100 and 200, or so and so forth.

import java.util.Scanner;
public class kbeaudry_xSieve
{
public static void main (String args[]){
kbeaudry_xSieve i = new kbeaudry_xSieve();
}
boolean primes[] = new boolean [50001];
int upper;
int lower;

[code]....

This is what i get when I actually run the program. However in the section where I have added *****, this is where it should put the prime pairs in.

Please enter a lower boundary and an upper boundary and I will print all of the sexy prime pairs between those boundaries.
Please enter the lower boundary (between 1 and 50000): 200
Please enter the upper boundary (between 1 and 50000): 600

There were 0 sexy pairs displayed between 200 and 600.. I am still working on another code for my that I had issues with, however I had to go out of the country for a few days to take care of some work.

View Replies View Related

Coding A Robot To Follow A Line In Eclipse?

Mar 11, 2014

I have a serious issue with getting this robot to follow a line?

View Replies View Related

Fading Trail And Random Movement Coding?

Oct 30, 2014

I need the following key controlled ellipse to leave a trail behind that vanishes after 10 frames. Also, I need to create a random moving ellipse not related to the preexisting one. How to separate the two ellipses ...

Current code:

boolean left, right, backward, forward;
boolean SPEED;
 PVector pos = new PVector(680, 400);
 void setup() {
size (680,400);
fill (0 ,0,0);
frameRate(100);
noCursor();

[Code] .....

View Replies View Related

Coding Multiple-choice List Dialogs

May 15, 2014

// create an AlertDialog Builder and set the dialog's title
AlertDialog.Builder regionsBuilder = new AlertDialog.Builder(this);
regionsBuilder.setTitle(R.string.regions);
// replace _ with space in region names for display purposes
String[] displayNames = new String[regionNames.length];
for (int i = 0; i < regionNames.length; ++i)

[Code] ....

From the code above, An alertdialog would pop up prompting the user to select a region (from a list). the user will then be allowed to select multiple choices accordingly. If I choose to select anything, the app crashes. How to mitigate this problem?

I know that I have to use a conditional check like if (isChecked){}; but I don't know how to do it. I want it to pop up a dialog box when none is checked prompting them that they should select atleast one.

View Replies View Related

Servlets :: Unable To Provide Name To Downloaded Files In JSP Coding

Mar 25, 2014

I wrote a code to download a zip file in jsp, but it is not working as expected, when i execute this following program i am able to download file with "download_all.jsp" name, but now original download file (/tmp/Download_All/1244687508907.Zip). The download_all.jsp is my jsp name which is having the following code. Here is the code snippet:

try {
String filename = "/tmp/Download_All/1244687508907.Zip";
if(request.getParameter("filepath")!=null){
filename=request.getParameter("filepath");
}
// set the http content type to "APPLICATION/OCTET-STREAM
response.setContentType("APPLICATION/OCTET-STREAM");

[code]....

View Replies View Related

Developing UNO Game In Java

May 11, 2014

I am new to java, i can develop basic java programs but am not really good at it. How should i pursue and how should i start. I know the game rules.Do i need to learn swings for the same?

View Replies View Related

Developing UNO Game In Java?

May 11, 2014

i can develop basic java programs but am not really good at it.I have been given this assignment of developing UNO game in java and have been given 10 days. How should i pursue and how should i start.I know the game rules.Do i need to learn swings for the same?

View Replies View Related

Java Game Creation

Jan 26, 2015

I am creating a simple tiled minecraft like game in java, but i dont know how to make the game loop.Here is the source:

package net.pltformgame.main;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JFrame;
public class main extends JFrame implements KeyListener {

[code]...

I really dont know how i make the jump or the game loop.

View Replies View Related

Java Game Health

Jan 20, 2015

I'm building this custom project in stages, and I'm having difficulty getting the health of the player and the enemy to change. Upon compiling, I'll select weapon 1, then choose action 1 (basic attack), and the health of both the player and the enemy will stay at 15 and 10.There are no errors when compiling.

import java.util.Scanner;
public class CustomProject
{
public static void main(String[]args) {
Scanner sc = new Scanner(System.in);
it hp = 0;
int potionsleft = 0;
int choice1 = 0;
int weapon = 0;
int enemy1hp = 10;
//int newenemy1hp = 0;

[code]....

View Replies View Related

Java Matching Game

Apr 14, 2015

I'm working on a Java matching game and I'm having a hard time wrapping my mind around it. What I'm having trouble with is how exactly to create an array so that my squares have random values. Then how do I get it to reveal and compare those values by clicking on two of them? Here is what I have so far:

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

[code]....

View Replies View Related

Tiled Based Map Game In Java

May 10, 2014

I'm trying to create a tile based map JPanel but all I get is a white screen. I'm fairly new to the Java Swing and AWT package so I've been watching tutorials on YouTube so learn as much as I can.

I've got three classes: Window.java which includes the Main method, Panel.java which is the JPanel and Tile.java to draw all the images into an array.

Window.java:

import javax.swing.JFrame;
public class Window extends JFrame {
public Window() {
setTitle("Project");
setSize(500, 400);

[Code] .....

I've checked through everything and still cannot find what I'm doing wrong. I did try different codes but I just got errors instead.

View Replies View Related

How To Improve Battleship Game Java

Dec 3, 2014

I have an battleship program that I would like to improve in performance. I know that using certain algorithms it can be improve however I am beginner in Java. I would like any recommendations and or hint in how to improve this game. The are 5 ships per game and the computers plays 10000. I just want to sink all ships in as many shots as possible.

Main class

package solution;
import battleship.BattleShip;
import java.awt.Point;
import java.util.List;

[Code] .....

View Replies View Related

Make A Connect 4 Game With Java

Nov 17, 2014

I have to make the connect 4 game be connect 3. Ive edited a code but I the math is over my head. These loop methods check the ways someone can win.

for (int j=0;j<7;j+=2)//need to change
{
if ((f[i][j+1] != " ")
&& (f[i][j+3] != " ")
&& (f[i][j+5] != " ")
&& (f[i][j+7] != " ")
&& ((f[i][j+1] == f[i][j+3])
&& (f[i][j+3] == f[i][j+5])
&& (f[i][j+5] == f[i][j+7])))
//end of loop

[code]....

View Replies View Related

Java Game Export Error

May 8, 2014

So I am creating a game in Java, the game works fine when I run it in Eclipse but when I export it it does not draw anything on the screen.

I added a try and catch for nullpointerexceptions but the game does not throw any nullpointerexceptions.

What is the problem?

The game seems to be finding all the images & resources since it does not throw any NullPointerExceptions...

View Replies View Related







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