Showing posts with label mi. Show all posts
Showing posts with label mi. Show all posts

Friday, 6 May 2011

C Four, miGame, Part 5

So I was getting a bit frustrated at this AI, I made that I could beat every time... Had a look online at the solution Wikipedia was talking about. This. Shat my pants looking at the amount of information this things goes through. Some guy actually spend 40,000 hours calculating all the possible positions on the board and creating a txt file that holds all these and the transitions between them.

This is tl;dr.

4,531,985,219,092 different possible combinations of moves. That's quite a lot.

So this project seems to be a bit beyond what I was looking to do... I have a pretty average working AI now though. Wont release it just yet though. [Stop timer 201105061934]. Might work on this again later.

Random unrelated image:

I got a job making a website, which is great for University as I need work hours to graduate, but terrible for the guy who hired me because I have NO experience in html or css or php. Should be fun. Will have a play with this blogs design as well. I do quite like it how it is though. We will see.

Will end up something like this:

C Four, miGame, Part 4

Problem Encountered!!!



Something is wrong with the way I am calculating the 'best move'. My plan was to have every winning option score a number of points equal to the number of free spaces on the board.

So let's say it finds a spot where it can win with 3 empty spaces on the board. This spot has a score of 3. In reality the numbers end up much much larger due to the recursion as it finds multiple winning options from the same initial move.



I tried to have an opponent winning make a negative score, as in you don't want to go there. But this ended up with the effect of 'the opponent can win here so I better not block his win'. Stupid...

Tried changing this to increasing the number but then that doesn't work as well as I had hoped either.

Going to get rid of the how many spaces left option and instead will take into account the number of recursive calls to get to this point. I think I'm going to try put the negative thing back in and then have it decide which to choose based on the number furthest from zero (absolute value).

Also had some trouble with stack overflows so have had to limit the number of recursions. At the moment 7 steps in seems enough. Bear in mind that for every step it create another 7 boards. So this gets quite big quite fast.



tl:dr: I have no idea what I am doing at this point and am trying random things until I get something about right.

C Four, miGame, Part 3

Got back from hospital. Turns out the stone was 8mm. But had it blasted and feeling fine now.

I have little to no memory of how to make a C program. Lol...



Because I am using my old code this is going to be a very very poor example of good programming. I've noticed so so many little tweeks I could make. Blarg I haven't even started and I'm disliking C again... Such a tedious language. Luckily the two methods I'm going to use from the old program are set up well enough that I won't need to change anything.



First step: Create a new file for AI code.
From what I can find anywhere it is the same as in Java. Just do it. Examples didn't have 'include' or some other way for it to tell what file it is coming from so that makes things a bit easier. Except every method



Second Step: Allow AI's in the program.
I'm sure there is a much better way to do this but I'm going to hard code in an array of size two with either an h or a c to determine if the player is computer or human. Then add a check in the main loop and if it is a 'c' then call the computer MakeMove method.



Crap it's taken me 30 minutes to get the compiler to work again... Completely forgot everything. Now that I that done I can actually write some code. Woo!



Third Step: Write some code.
Create the AI using recursion to find the best possible move and go there. This is the fun part. Each time the computer is to make a move it will create a copy of the board and make it choose the first column then make the opponent go in the first column and so on and so forth until that column is full, then it moves to the next column and alternatively fills that. As soon as a win is detected the number of empty spaces on the board is the amount of points that win is worth. Then it starts again but places the its first move in the second column and then opponent in the first and it in the first. And so on and so on. This sounds like terrible way to do this. But computers are fast.To those that do program I'm going to be using recursion and so this SHOULD involve minimal code on my part. Which is the plan.

Going to start this now. [Start timer] 201105061147
[Pause timer] 201105061316
[Back again] 201105061650

Tuesday, 8 March 2011

miTanks, Part 10

It's not working... I've been trying different ways to get the game to draw to screen though I just don't have it working yet. Fixed a couple minor bugs, as I hadn't moved everything across from the PC version.

When running I follow the debug and step through the program. Turns out the game runs perfectly, that is the game constructs and plays out completely with two random computer players, except it never draws to the screen. Thought the onDraw(Canvas canvas) method would be called automatically every couple of milliseconds. Turns out no. So, I need a way to get the canvas (i.e. the screen) so that I can call the method myself. Working on it...

If anyone knows how android views work, let me know...

As for sounds, I have this site that generates old school game noises. So I'll probably use that for my sounds. Means I don't have to search for people to make decent sounds. Lol. Sorry to those of you that did help with that. There just weren't enough to continue with them.

So the site looks like this:



Here is the link. Will probably be my one stop shop for sounds in the future. Check it out.

My roommate made me a little icon for the game as well. His tanks looks better than the little ones I made in the last post. So may end up replacing them with copies of his. I'll post the icon when I have my computer again.

Cheers,
Milk

Saturday, 5 March 2011

miTanks, Part 9

That's right! miTanks is back. After a very very long break I've got motivated to finish it. Or at least get it on the platform it was originally for. Haven't really had much commitment from Foo, which is both our faults really. I'm not the best teacher and he has little / no coding experience. And lobbing him with graphics was not the best move.

Sorry to everyone that doesn't have an Android, but you can still enjoy my struggle with xml and the Android graphics classes... And the PC version will still have the same look and feel as the Android version, with the obvious touch-screen exception.

Can't remember if I've said already or not but this is a fantastic, simple example of how to make a game on Android. The game is open source so I'm basing the majority of figuring out how to do graphics on this. For those of you know don't know software programming is basically: "Learn the basics; google the rest."


Image courtesy of xkcd.

I think I have a pretty good idea of what I need to do now. The tanks are going to look something like this:
 

And the turrets are just going to be a black smooth edged square, pointing at whatever angle they need to. The ground is either going to be a solid colour or each pixel will be 1 of three colours. This will depend on how much time it takes up to search and utilise a very very large 2D colour array.

I'll be using the sky square (not a box, it's 2D) Foo created earlier, because it is awesome. This will be the background of most of the levels. Might end up overlaying some objects like a building or something.




What else? Damage isn't quite right. The tank only takes damage if the very centre is hit. Not a major flaw but not very ascetically pleasing.

I'll get to work on this all tonight and post something on Monday(?) about what I have done.

Links to the other miTanks posts:
Part 1, The Plan
Part 2, Initial Concept
Part 3, Object Oriented Design + Update
Part 4, Sound Request + Update
Part 5, First Screenshots
Part 6, Ground Types
Part 7, Weapons + Ground Dynamics
Part 8, Initial Release

The last one contains the initial release for PC. Have a look at that if you haven't already. Just renamed all my posts... I had two part 4's AND 2 part 6's. That's just bad...

And as always suggestions are always appreciated.

Cheers,
Milk

Tuesday, 22 February 2011

miAlchemy

So Foo showed me this free game on Android called Alchemy. It's pretty simple. You start off with the four basic elements; earth, fire, water, and air. Then you drag one on another and make something else. e.g. earth + water = swamp, fire + air = energy, energy + swamp = life. There are 360 elements to unlock in the free version.



Being a coder I thought that it seemed pretty simple to make. So, I made miAlchemy (original, I know). Now it doesn't look as awesome as the Android one, and it's for computer instead. It's written in Python; like the last few projects I've put up here.



The way it figures out which elements exist allows for drop in add-ons. That way you can simply add a file into the elements folder and BAM! it's in the game. Images can be changed just as easily.

Mine also allows more then 2 things to be combined at a time. So something like: earth + air + fire + water = life, is possible.

My version has:
Earth
Air
Water
Fire
Alcohol

Put some suggestions in the comments and I'll add it to the game. If it's not obvious, let me know how to make it.

When I get some more elements into the game I'll package it up and release it for you guys.
If you want to do some 40x40 images would be good too.

Thursday, 17 February 2011

miMTGCrawler

So as per my previous post, I have written a very simple program to show me the value of Magic Cards. All you do is run the program and type in the name of the card. Then it prints out the value of the card for each version it is in. In addition it also saves and formats the printed bits in a txt file, which is compatable with spreadsheet software. See images below.

Simply type in the card you are looking for and press enter.


That is then saved here.


Which you can then import...



Here!


It also takes into account cards that do not exist. But not half typed. i.e. If I typed 'myr' it would return everything with myr in the title... No really worth fixing. More the error / aid of the website it's searching.

[Small error fixed: 'Mirrodin Besieged Singles' was picked up from the ads on the side bar. Now the first category is correct. I'm not replacing the screenshots though. You get the picture. (Spot the pun)]

Code below:

#!C:/Program Files/Python/Python 2.7

import urllib

print "miMTGCrawler version 0.1"

f = open('cardList.txt', 'a')

# The below URL is the link to a card. The card name is appended, also '+' replaces ' '. Case is irrelevent.
# e.g. 'Myr Enforcer' = 'Myr+Enforcer'
# Searches the website starcitygames.com for the information.
scLink = 'http://sales.starcitygames.com/search.php?substring='

while(True):
    print "Please enter card name: "
    card = raw_input()
    if card == 'q':
        break
   
    #Builds the URL for the card.
    cardLink = scLink + card.replace(' ', '+')
    page = urllib.urlopen(cardLink).read()
   
    # Search for the category. e.g. 'Mirridon'
    categoryString = 'http://sales.starcitygames.com//category.php?cat='
   
    # Jumps to the first listing.
    pos = page.find('tooltip')
       
    pos = page.find(categoryString, pos)
    # Loops through this process until there are no more valid categories on the page.
    while (pos != -1):
        pos = page.find('>', pos) + 1
        # This will build a string for the Card and it's categories and values of the listing found.
        cardString = card + '\t' + page[pos : page.find('<', pos)] + '\t'
        pos = page.find('">$', pos)
        # Checks to see if a price was found following the category.
        if pos == -1:
            print 'There is no such card: ' + card
            break
        cardString = cardString + page[page.find('$', pos) : page.find('</td>', pos)]
        print cardString + '\n'
        f.write(cardString + '\n')
        # Look for the next category.
        pos = page.find(categoryString, pos)

      

Monday, 24 January 2011

It's my birthday soon! Small update and a little bit about myself.

Going to be 20. Woo! That should be fun. Not really doing anything too exciting. Oh! I am going to Fiji for my girlfriends 21st in February. That should be fun too. Unless I die from the heat...

Sorry I haven't done any work on Tanks since the first release. I will get back to it at some point as I actually want it on my phone. Would be nice when going to job interviews. "Well you can see some of the work I have done here." That would be awesome.

I've run out of decent previous projects to put up here too so everything should be new content. Except there is another game I half made, (actually it's at about the same point as the tanks game is now) where you have to get to the door. There are some glitches I haven't fixed and alot of people don't like the unique control system. I'll put some shots and maybe the executable online for that one aswell. It is about as complicated as Tanks so you might not see any code for it. Simply due to the amount of code.

What else? University is starting in the end of February, so expect alot of content about that. Looking for a house, which means I will be poor. But that should be fun. I do like a challenge. Been going for runs, which is always a good thing. But the weather hasn't helped. See this here.

And a picture for my brother:
[spoiler]
[/spoiler]


That's about it.
Cheers,

Wednesday, 12 January 2011

miTanks, Part 8, Initial Release!!!

Added another ground type, gravel. But thats about it.


The ground is randomly up and down, but never so high that you can't climb it. I think it's the most realistic ground I have made. Suprisingly easy as well.

Ok guys. I'm running out of ideas. Foo's to get to work on having the menu up and running. I'll going to get to work on some of the inside bits.

I really want to make a release for you guys. What I'm going to do is find a way to put up a .jar file. Because the program has no real visual output, I'll leave you instructions on how to run it through the command line. This will allow you to see what I see. Playable, but in no way is it finished.

Download Link:
http://rapidshare.com/files/442108182/miTanks.jar

How to use:
Download the jar file and place it somewhere on your computer.
Right-click on the file and click 'Properties'.
Copy the location of the file.

Open the command line. (Windows > Search > "cmd").
Type "cd [location in full]" and press enter.
Type "java -jar miTanks.jar" and press enter.

This will open the game.

Notes:
The ground is gravel and there are 3 players (2 human controlled and a computer controlled). The first player is the blue one, he is human controlled. The second is red, and is also human controlled. The last is still red, but he is a computer player that randomly picks a direction, power and fires.
If I get some comments, I'll upload versions with a certain amount of what players and what ground etc.
The angle works like this: 0 is straight up, -90 is left, 90 is right.
Power goes between 0 and 100.
Your power and angle will be displayed in the command line.
Your life comes up here as well as you get damaged.
And some other crap. Sorry I'm still using these tracers so that's why they are still there.
Once you win you will have to close and open again. Just press up when in the command line then Enter.
Controls:
w = increase power
s = decrease power
a = decrease angle
d = increase angle
z = move left
x = move right
q = previous weapon
e = next weapon
Enter = fire

Please leave a comment! Chances are, there will be some issues with this.

Tuesday, 11 January 2011

miTanks, Part 7

A little more progress and some more screenshots.

Had a game against my brother yesterday. Found a couple bugs, but it was still playable. The first most obvious bug is that bullets would explode halfway through some walls. This was due to the movement calculations. They were somewhat refined though needed to be more so with the bullets jumping instead of moving through every pixel in their path. Took some thinking but I figured out to solve that.

Also I made the first tank blue and all the others red. A quick fix so I could tell which was the first. Also made it playable for two people. Eventually colours will be selected on start up.


The ground now falls nicely into place if a shot blows up the ground beneath it. Only one line added so this may be a temp fix. Seems to be good for the game needs though. I was too slow with taking the screen shots but the ground falls line by line. Looks ok. Will make it even smoother later on.


Found an issue with falling as well. When you fall it moves you according to gravity. Though you can still move back and forth between the fall movements. If I implement an automatic redraw of the canvas, this shouldn't be an issue. Unfortunately that would ruin how I'm doing my other calculations, so that may have to wait. I'm sure there is another way to resolve this.


Added a laser beam. Fires in a straight line destroying all the ground in it's path. Damn I missed him.


You can kinda see the ground adjustment here. Got a screenshot about halfway through it.


I'm having a meeting with Foo about the game tomorrow. Now that I have alot of the game done, he can get started on creating the game view for Android. Hopefully he has a better idea about how to do this then I do.

By the way, all these screens are from the PC version. Don't worry. I will release it for you all.

Cheers,
Milk

Friday, 7 January 2011

miTanks, Part 5

Here's a some pics of what I've got so far for testing.


Support for an arbitrary amount of players. They are actually all human controlled at the moment.



In this one you can see the error with damage. You can see it has broken one line correctly. But hasn't done the others.


 If anyone can help me with code formatting on here let me know. Here's a screen of it. Lol.




ground is a 2d array of size game_width x game_height. All the others should be self explanatory.
When it prints we see:


Destroy: -5, 0
Destroy: -4, 0
Destroy: -3, 0
Destroy: -2, 0
Destroy: -1, 0
Destroy: 0, 0
Destroy: 1, 0
Destroy: 2, 0
Destroy: 3, 0
Destroy: 4, 0
Destroy: 5, 0

So for every x, y = 0. But why! Should be something like. x = -5, y = 0; x = -4, y = 1; ...

[Edit: Found it!!

Not sure why I was scaling y by the bullet location... Removed this.bullet_x and this.bullet_y in the y calculation and it works. Too easy. Doesn't even look that circular... How to fix that?

]

Just an update

Got a booger app on my android. It's sweet as. This phone of so awesome.

Also I've made some good progress porting the tanks game to work on the pc. Have some working very poor graphics. Will upload a pic once I get to my home computer.

There were a lot of problems with the damage calculations. Most of out works now. Still need sounds for the game though.
Published with Blogger-droid v1.6.5

Wednesday, 5 January 2011

miTanks, Part 4

Happy New Year!

Hope everyone's holidays are going well. Nothing too exciting going on in mine. Had a nice few days off work for drinks and general relaxation. Didn't do too much on the tanks game but thought I should update what has been happening. Foo is currently on holidays afk so not much in the lines of GUI completed.

Sorry I don't have many pictures for this project. As the GUI is last on the TODO list, this will come when the app is in the testing phase. I'll get some code up here later on for you all aswell. As this uses Java classes the code is spread across multiple files. I'll upload any interesting code I make though. Have a couple little bits in mind for later on.

Completed:
More of the inner workings are completed for in game.
The game physics work.
(better now)
Simple flat terrain completed.
Support for differing gravity, wind and landscape. (three landscapes have been added, one fully completed)
Support for random terrain generator. (included in landscape)
Support for multiple weapons, including weapon movement and collision calculations.
One weapon implemented. (fully implemented, including circular proximity damage)
Multiple matches in a game. (support for)
Game cycle. (may need to be editted once visuals and sounds are added.)

Still to do:
Getting input. Once input can be received the usage is already implemented.
Tank movement.
Display. Location calculations implemented. Just need to know how to put an image on the screen.
AI calculations, of differing skill levels.
Perfect AI, should be easy to do.
Absolutely useless AI, is even easier.
Realistic AI is somewhat harder. Shouldn't take too long. I'd just fudge some numbers from the perfect AI.
Defensive weaponry support. Shields and such.

NOTE TO FOLLOWERS:
I'm going to need some sound effects for this game. Such as a tank moving sound, bullet fire sound, bullet fall, explosion, and probably some others. If you can link me some sounds you've made I'll give them a listen and add the best ones into the game.

Saturday, 1 January 2011

miTanks, Part 3

As neither me or Foo know how to successfully draw to the screen, we thought we'd make it as easy as we could. Firstly the game will be the size of the screen. This will remove the need for scrolling. The battlefield size will be in relation to some fixed variables, so can be easily changed at will. The game will be completely in landscape view.

Foo agreed to do the visual side of the application. Considering the amount of lower-level coding Foo has actually done, and the combined skills we possess for graphics, this looks like the hardest part. Seemingly working from scratch, the progress on this is slow. So far there is nothing to show.

Done so far:
Did a quick class diagram for the actual game.

























Most of the inner workings are completed for in game.
The game physics work, (untested).
Simple flat terrain completed.
Support for differing gravity, wind and landscape.
Support for random terrain generator.
Support for multiple weapons, including weapon movement and collision calculations.
One weapon implemented.
Multiple matches in a game.

Still to do:
Getting input. Once input can be received the usage is already implemented.
Tank movement.
Display. Location calculations implemented. Just need to know how to put an image on the screen.
The game cycle. This will be very easy. Just need to actually do it.
AI calculations, of differing skill levels.
Perfect AI, should be easy to do.
Absolutely useless AI, is even easier.
Realistic AI is somewhat harder. Shouldn't take too long. I'd just fudge some numbers from the perfect AI.
Defensive weaponry support. Shields and such.

Things YOU think I should add:
Leave a comment. Tell me what you would like to see.

Friday, 31 December 2010

miTanks, Part 2

Something I've missed:
Android apps are written in Java plus some xml for view layouts etc.

I have started drawing up a rough class diagram for the game and started to think about how to implement destructible terrain. As we want a clean fall animation for the ground when a piece is broken below, I am currently thinking about having the entire game screen as a 3d boolean array. Animations with this will be incredably easy. Hopefully this won't be too much to process every turn.

Some minor code has been written to help visualise the working of the tank class. As this is early on in the process it is likely to be rearranged quite regularly, due to the nature of eXtreme Programming.

I will try to have the game run on both the Android and a computer. This will help for initial game development as testing on the Android Virtual Device is time consuming. Also when the game is complete I will release a run-able jar file so everyone on here can play the game.

Most likely won't be doing small releases as we go, due to the size of the app. When it is actually playable it will almost be finished. Just bug fixes, extra weapons and smoothing out code after the app works.

Here are some initial concept shots by Foo.
Initial Concept Screenshot
Second Concept Screenshot


Sky

Tree

Concept Tank 1