Monthly Archives: April 2013

Hurling Simulation Engine Update

I have continued work on my Hurling match engine over the last few days and have made some good progress. I have added more factors in to affect the overall simulation of events in a match. A teams attack and opponents defence now play a factor into scoring points and goals. Teams can also perform defensive plays which are affected by their defence. A goalie gets factored into the goal probability now.

teamOneTotalProb = 1.8 + ((teamOneAtk - teamTwoDef)/100) + ((teamOneAtk - teamTwoDef - teamTwo.getGoalKeeper())/100) + (teamOneDef/1000)
+ teamOnePointMod + teamOneGoalMod + teamOneDefMod - (2 * teamTwoDefMod);
teamOnePoint = 0.8 + ((teamOneAtk - teamTwoDef)/100) + teamOnePointMod - teamTwoDefMod;
teamOneGoal = teamOnePoint + 0.04 + ((teamOneAtk - teamTwoDef - teamTwo.getGoalKeeper())/100) + teamOneGoalMod - teamTwoDefMod;
teamOneDefence = teamOneGoal + 0.2 + (teamOneDef/1000) + teamOneDefMod;

Another large addition is the use of tactics for a team. There are 5 tactics to choose from: Attacking, Defensive, Long Ball, Short passing or Take points. They are designated as a single character at the start of a teamsheet and read in with the players. Each tactic counters two and is countered by two so it creates a nice rock paper scissors strategy. The bonus for countering your opponent is an increase to the teams probability of having an “event”. Each tactic also has an effect on the team depending on the strategy. They are laid out below.

Tactic Counters Countered By Bonus Minus
Attacking Defensive, Take Points Short Pass, Long Ball points, goals defence
Defensive Long Ball, Short Pass Take Points, Attacking Defence Points, goals
Long Ball Attacking, Short Pass Defensive, Take Point Goals Points
Short Pass Attacking, Take Points Defensive, Long Ball Possession None
Take Points Defensive, Long Ball Attacking, Short Pass Points Goals

Frees have also been added in as a subset of scoring. Now after its calculate that it was a score it then checks whether that score was a free or not. A free is always scored by the designated free taker who is written on the teamsheet aswell under the tactic.

if(event < teamOnePoint)
					{
						int free = (int)(Math.random() * 4);

						if(free > 0)
						{
							p = teamOne.getPlayers().get(playerEvent(teamOne, 37, 71, 91, 99)).getName();
							comment = commentary.getPointCom(p, teamOne);
						}
						else
						{
							p = teamOne.getFreeTaker().getName();
							comment = commentary.getFreeCom(p, teamTwo);
						}

						pointsOne++;
						score = true;
					}

Commentary lines look like this before being read in. <name> is replace by the player performing the action and <other> is a relevant other player involved in the play.

 

<name> hits it past the goalie and into the back of the net.
<name> catches the ball, turns and scores a goal.
The ball is picked up by the sideline by <name> he solos past two men and hits it past the goalie.
The sliotar is rifled past the goalie by <name>.
The ball is fumbled by the goalie and <name> pulls on it.
A good ball into the corner to <name> leads to a good shot past the goalie.
The ball is caught by <other> and he lays it off to <name> who scores a goal.
A fast pull by <name> and its a goal.
<other> breaks the high ball for <name> who hits it past the keeper.
A lucky break falls to <name> and he finishes the goal.

Tagged , , ,

WikiWar

WikiWar Download
WikiWar is now finished and is available to download on the app store. I have also had my code interview for the app with my lecturer and received an A1 for the project. I am very happy with how the project has turned out and this post is going to talk about the final game and what I worked on.

The purpose of the game is to use Wikipedia to get from one page to another. You are rated by speed or skill depending on the game mode you chose. The game modes are:

wikiwar1
Standard
: Get from a set start to a set end point and you are rated on how few clicks you use

Timed: Similar to standard but with different presets and you are rated on how fast you complete the levle

Random: Gets a random starting point from Wikipedia (it can be ANYTHING) and picks from a large random list of preset pages as your end

Multiplayer: Pass-and-Play between two people. One chooses the start and the other chooses the end. The winner is whoever uses fewer clicks

The variety of modes adds lots of different ways to play and keeps people interested longer.

While playing there are a few things that the player can do. They can read through the Wikipedia page looking for a relevant link on the webview. They also can click the question mark at the top to remind themself of where they are trying to get to. For a faster game you can use the search feature which allows you to search for a word on the page that you feel may help you complete the level.
wikiwar5

My main work was focused on the modes themselves. I started off by making the basic game activity and created the Standard mode. The menu and game activity were used by others to make the random mode and timed modes. They used the template and added in the appropriate code. I also worked on the multiplayer mode (previous post on this). I also worked on creating the win screen and displaying the stars to rate your performance.
wikiwar2 wikiwar3wikiwar4

Tagged , , ,

Hurling Simulation Engine

I have started on a new project to do in my spare time. Its based around two things I really enjoy, Hurling and sports simulation games. I have started writing an engine to simulate hurling matches and give out scores, stats and match reports. I started by looking at results over the last two years for matches to try get various stats such as goals per game and points per game. I then broke it into steps, first getting the right number of scores, then scores per team, then goals and points per team. Right now I am simulating results quite similar to real results.

The program takes in teamsheets from textfiles with the players listed in position. Each player has 4 ratings, goalie, defence, pass and attack, on a 1 to 20 scale. These determine how good each is in each position. Player abilities affect the overall team performance and the likelihood of each scoring. I am currently trying to alter the probabilities further so that the overall attacking skill affects the scores of a team as does the defence.

I also can read commentary in from textfiles and with some manipulation can output the action just performed. All these are put together and outputted to another file.

Sample Teamsheet
GK,GKA1,7,2,1,1
FB,FBA1,1,8,3,2
FB,FBA2,1,9,1,2
FB,FBA3,1,7,1,2
HB,HBA1,1,8,3,2
HB,HBA2,1,8,4,2
HB,HBA3,1,7,5,2
MF,MFA1,1,5,8,3
MF,MFA2,1,4,9,5
HF,HFA1,1,2,7,7
HF,HFA2,1,3,5,8
HF,HFA3,1,2,6,8
FF,FFA1,1,1,1,9
FF,FFA2,1,1,3,7
FF,FFA3,1,2,3,9

Sample Match Report

MIN) 0 The ball is sent over the bar by HFA1.
0-1 TO 0-0
MIN) 2 MFA1 picks up the sliotar and hits it over the bar.
0-2 TO 0-0
MIN) 7 WIDE
MIN) 9 The ball is sent over the bar by FFB2.
0-2 TO 0-1
MIN) 12 The ball is sent over the bar by MFB1.
0-2 TO 0-2
MIN) 13 FFB2 picks up the sliotar and hits it over the bar.
0-2 TO 0-3
MIN) 14 FFB3 catches the ball, turns and scores a goal.
0-2 TO 1-3
MIN) 17 MFA2 picks up the sliotar and hits it over the bar.
0-3 TO 1-3

 

Tagged , , ,

Wikiwar Complete

WikiWar Download

We have finished the project and I am quite pleased with the result. I may do a further write up on the complete app but for now here is a link to download and try it yourself.

 

Tagged , , ,

WikiWar: Multiplayer

I have been working on a multiplayer mode for the app WikiWar. We decided that a “pass and play” mode could be added into the game quite easily. Its base is still the same as a normal mode but there is some more stuff added. Before the game starts each player will get to select a wikipedia page from a lot of options. Player One will select the starting point and Player Two will select the end point. The game will then start.

First Player One will play through the game. When they reach the end point, the game will reset and Player Two will get to play through the game. A Popup box appears informing Player One to hand over the device. Each score is saved and then checks which is higher. The Activity that runs when a game ends now will display the winner.

private void showPopUp() {

AlertDialog.Builder helpBuilder = new AlertDialog.Builder(this);
helpBuilder.setTitle("Round Over");
helpBuilder.setMessage("Pass the device to Player Two");
helpBuilder.setPositiveButton("Ok",
new DialogInterface.OnClickListener() {

public void onClick(DialogInterface dialog, int which) {
stack.clear();
stack.push(startPoint);

loadWebView();
}
});

// Remember, create doesn't show the dialog
AlertDialog helpDialog = helpBuilder.create();
helpDialog.show();
}

 

if(url.equals(endPoint))
			{
				if(playerOne)
				{
					playerOne = false;
					countP1 = count;
					count = 0;
					current = startPoint;
					showPopUp();
				}
				else
				{
					String winner;
					countText.setText("You win");
					countP2 = count;
					if(countP1 > countP2)
					{
						winner = "Player One";
					}
					else if (countP2 > countP1)
					{
						winner = "Player Two";
					} else
					{
						winner = "NO ONE!! It's a draw!";
					}

					Intent intent = new Intent(MultiActivity.this, WinActivity.class);
					intent.putExtra("winner", winner);
					intent.putExtra("single", false);
					System.out.println("Working4");
	        		startActivity(intent);
				}

			}
Tagged , , ,