Here is a couple things everyone should know how to do from the command line.
To get the command line, click on the start button, then in the search bar type cmd and press enter.
To change the location.
Command: cd path
e.g.: cd C:\Windows\system32
Change your password without knowing the old one.
Location: C:\Windows\system32
Command is: net user user_name new_password
e.g.: net user Milk Password01
Only catch is you have to already be logged in. Good to change a friends password if they leave their computer on. Would be lols.
Format hard drive.
Warning: Don't run this!!!
Location: anywhere in any drive
Command: del drive *.* /s /q
e.g.: del C:\ *.* /s /q
This silently deletes every file in every folder on your directory without asking "Are you sure?"
Pretty dangerous couple of characters.
Works great if you are on a flash drive. Deletes all the hidden files and meta-data as well. So it is very efficient.
Get your IP address.
Location: anywhere
Command: ipconfig
Gives you a whole bunch of information, very handy for LANs and setting up your minecraft server.
Print a tree.
Location: anywhere
Command: tree
Lost a folder? Set the location to a starting point and use the tree command. This prints out everything in the folder and folders below that, so that you can find something. It's fantastic.
These are only a couple cool looking things you can use in command line. They are only a very small part of what you can do. But this should be enough to impress your friends. Everyone knows that command line pulls the chicks.
Showing posts with label command line. Show all posts
Showing posts with label command line. Show all posts
Sunday, 8 May 2011
Friday, 6 May 2011
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
[Pause timer] 201105061316
[Back again] 201105061650
Tuesday, 18 January 2011
C Four, Connect Four, miGame
I'm taking a break from miTanks for a while. Here's one of my first ever programs.
I spend alot of my time in lectures at University playing Connect Four on a piece of paper against friends. This is the best paper game we could come up with. Turn based, so could simply pass notes or signal which column to drop in. And there was no need for an eraser; imaging trying to play chess with a pen.
At the time we were learning C programming and had to come up with some simple program to prove we learnt something in the course. Alot of people went with a Facebook similar 'What animal are you?' kind of game. Boring!
It took about 2-3 hours. Remember this was my first C program I created purely by myself, aside from Visual Basic and MicroWorlds (if that even counts).
Code:
#define _CRT_SECURE_NO_DEPRECATE
#include <stdio.h>
//C(onnect) Four
//Created by: Milk
//Date of final build: 19/10/09
//Height of each line
#define LINE_HEIGHT 6
#define LINE_WIDTH 7
void DrawBoard(int grid[LINE_HEIGHT][LINE_WIDTH]);
int CalculateWin(int grid[LINE_HEIGHT][LINE_WIDTH], int player);
int ValidInput(int input, int grid[LINE_HEIGHT][LINE_WIDTH]);
int main(void)
{
//Plays connect four
int grid[LINE_HEIGHT][LINE_WIDTH] = {0};
int gameOver = 0;
int input = 0;
int player = 1;
char inputValid;
int i;
//Draw the intitial board (empty)
DrawBoard(grid);
while (gameOver == 0 && (grid[LINE_HEIGHT - 1][0] == 0 || grid[LINE_HEIGHT - 1][1] == 0 || grid[LINE_HEIGHT - 1][2] == 0 || grid[LINE_HEIGHT - 1][3] == 0 || grid[LINE_HEIGHT - 1][4] == 0 || grid[LINE_HEIGHT - 1][5] == 0 || grid[LINE_HEIGHT - 1][6] == 0)) {
//Get input from user
input = 0;
printf("\nWhere would you like to go, player %d?\n", player);
scanf("%d", &input);
//Decide if input is a valid move
inputValid = ValidInput(input, grid);
//If input is not valid prompt for a valid move
while (inputValid == 0) {
printf("Please choose a valid position: ");
scanf("%d", &input);
inputValid = ValidInput(input, grid);
}
//Add input to grid
for (i = 0; i < LINE_WIDTH; i++) {
if (grid[i][input - 1] == 0) {
grid[i][input - 1] = player;
break;
}
}
//Draw the board
DrawBoard(grid);
//Calculate if there is a win
gameOver = CalculateWin(grid, player);
//Set the next players turn
if (player == 1) {
player = 2;
} else {
player = 1;
}
}
//Print winner
if (gameOver == 0) {
printf("\n\nThere are no more available moves!\nIt's a draw\n");
} else {
printf("\n\nCongratulations player %d!\nYou won\n", gameOver);
}
return 0;
}
void DrawBoard(int grid[LINE_HEIGHT][LINE_WIDTH])
{
//Draws the board
int i, j;
printf("\n\n\n\n\n");
for (i = LINE_HEIGHT - 1; i >= 0; i--) {
printf("\nI");
for (j = 0; j < LINE_WIDTH; j++) {
if (grid[i][j] == 0) {
printf(" I");
} else if (grid[i][j] == 1) {
printf(" X I");
} else {
printf(" O I");
}
}
}
printf("\n__1___2___3___4___5___6___7__");
return;
}
int ValidInput(int input, int grid[LINE_HEIGHT][LINE_WIDTH])
{
//Calculate if input is valid
if (input < 0 || input > 8 || grid[LINE_HEIGHT - 1][input - 1] != 0) {
return 0;
} else {
return 1;
}
}
int CalculateWin(int grid[LINE_HEIGHT][LINE_WIDTH], int player)
{
int i, j;
//Calculate if there is a win on the horizontal
for (j = 0; j < LINE_WIDTH - 3; j++) {
for (i = 0; i < LINE_HEIGHT; i++) {
if (grid[i][j] == grid[i][j + 1] && grid[i][j] == grid[i][j + 2] && grid[i][j] == grid[i][j + 3] && grid[i][j] != 0) {
return player;
}
}
}
//Calculate if there is a vertical win
for (i = 0; i < LINE_HEIGHT - 3; i++) {
for (j = 0; j < LINE_WIDTH; j++) {
if (grid[i][j] == grid[i + 1][j] && grid[i][j] == grid[i + 2][j] && grid[i][j] == grid[i + 3][j] && grid[i][j] != 0) {
return player;
}
}
}
//Calculate if there is a diagonal up-right win
for (i = 0; i < LINE_HEIGHT - 3; i++) {
for (j = 0; j < LINE_WIDTH - 3; j++) {
if (grid[i][j] == grid[i + 1][j + 1] && grid[i][j] == grid[i + 2][j + 2] && grid[i][j] == grid[i + 3][j + 3] && grid[i][j] != 0) {
return player;
}
}
}
//Calculate if there is a diagonal up-left win
for (i = 0; i < LINE_HEIGHT - 3; i++) {
for (j = LINE_WIDTH - 1; j >= 0; j--) {
if (grid[i][j] == grid[i + 1][j - 1] && grid[i][j] == grid[i + 2][j - 2] && grid[i][j] == grid[i + 3][j - 3] && grid[i][j] != 0) {
return player;
}
}
}
//No win
return 0;
}
When compiled the exe file is only 56.0KiB. So it's pretty much always on my USB drive now.
And here it is:
http://rapidshare.com/files/443141503/Connect4.txt
I don't think rapidshare likes exe files so once you download just change the file extension (txt) to exe, and it will work. Give it a go.
Looking back at this code there is not actually too many things I would do differently. Would've been a nice OO exercise though.
If anyone wants to give me a game just tell me your starting move. Let's play. Lol
Cheers,
Milk
I spend alot of my time in lectures at University playing Connect Four on a piece of paper against friends. This is the best paper game we could come up with. Turn based, so could simply pass notes or signal which column to drop in. And there was no need for an eraser; imaging trying to play chess with a pen.
At the time we were learning C programming and had to come up with some simple program to prove we learnt something in the course. Alot of people went with a Facebook similar 'What animal are you?' kind of game. Boring!
It took about 2-3 hours. Remember this was my first C program I created purely by myself, aside from Visual Basic and MicroWorlds (if that even counts).
Code:
#define _CRT_SECURE_NO_DEPRECATE
#include <stdio.h>
//C(onnect) Four
//Created by: Milk
//Date of final build: 19/10/09
//Height of each line
#define LINE_HEIGHT 6
#define LINE_WIDTH 7
void DrawBoard(int grid[LINE_HEIGHT][LINE_WIDTH]);
int CalculateWin(int grid[LINE_HEIGHT][LINE_WIDTH], int player);
int ValidInput(int input, int grid[LINE_HEIGHT][LINE_WIDTH]);
int main(void)
{
//Plays connect four
int grid[LINE_HEIGHT][LINE_WIDTH] = {0};
int gameOver = 0;
int input = 0;
int player = 1;
char inputValid;
int i;
//Draw the intitial board (empty)
DrawBoard(grid);
while (gameOver == 0 && (grid[LINE_HEIGHT - 1][0] == 0 || grid[LINE_HEIGHT - 1][1] == 0 || grid[LINE_HEIGHT - 1][2] == 0 || grid[LINE_HEIGHT - 1][3] == 0 || grid[LINE_HEIGHT - 1][4] == 0 || grid[LINE_HEIGHT - 1][5] == 0 || grid[LINE_HEIGHT - 1][6] == 0)) {
//Get input from user
input = 0;
printf("\nWhere would you like to go, player %d?\n", player);
scanf("%d", &input);
//Decide if input is a valid move
inputValid = ValidInput(input, grid);
//If input is not valid prompt for a valid move
while (inputValid == 0) {
printf("Please choose a valid position: ");
scanf("%d", &input);
inputValid = ValidInput(input, grid);
}
//Add input to grid
for (i = 0; i < LINE_WIDTH; i++) {
if (grid[i][input - 1] == 0) {
grid[i][input - 1] = player;
break;
}
}
//Draw the board
DrawBoard(grid);
//Calculate if there is a win
gameOver = CalculateWin(grid, player);
//Set the next players turn
if (player == 1) {
player = 2;
} else {
player = 1;
}
}
//Print winner
if (gameOver == 0) {
printf("\n\nThere are no more available moves!\nIt's a draw\n");
} else {
printf("\n\nCongratulations player %d!\nYou won\n", gameOver);
}
return 0;
}
void DrawBoard(int grid[LINE_HEIGHT][LINE_WIDTH])
{
//Draws the board
int i, j;
printf("\n\n\n\n\n");
for (i = LINE_HEIGHT - 1; i >= 0; i--) {
printf("\nI");
for (j = 0; j < LINE_WIDTH; j++) {
if (grid[i][j] == 0) {
printf(" I");
} else if (grid[i][j] == 1) {
printf(" X I");
} else {
printf(" O I");
}
}
}
printf("\n__1___2___3___4___5___6___7__");
return;
}
int ValidInput(int input, int grid[LINE_HEIGHT][LINE_WIDTH])
{
//Calculate if input is valid
if (input < 0 || input > 8 || grid[LINE_HEIGHT - 1][input - 1] != 0) {
return 0;
} else {
return 1;
}
}
int CalculateWin(int grid[LINE_HEIGHT][LINE_WIDTH], int player)
{
int i, j;
//Calculate if there is a win on the horizontal
for (j = 0; j < LINE_WIDTH - 3; j++) {
for (i = 0; i < LINE_HEIGHT; i++) {
if (grid[i][j] == grid[i][j + 1] && grid[i][j] == grid[i][j + 2] && grid[i][j] == grid[i][j + 3] && grid[i][j] != 0) {
return player;
}
}
}
//Calculate if there is a vertical win
for (i = 0; i < LINE_HEIGHT - 3; i++) {
for (j = 0; j < LINE_WIDTH; j++) {
if (grid[i][j] == grid[i + 1][j] && grid[i][j] == grid[i + 2][j] && grid[i][j] == grid[i + 3][j] && grid[i][j] != 0) {
return player;
}
}
}
//Calculate if there is a diagonal up-right win
for (i = 0; i < LINE_HEIGHT - 3; i++) {
for (j = 0; j < LINE_WIDTH - 3; j++) {
if (grid[i][j] == grid[i + 1][j + 1] && grid[i][j] == grid[i + 2][j + 2] && grid[i][j] == grid[i + 3][j + 3] && grid[i][j] != 0) {
return player;
}
}
}
//Calculate if there is a diagonal up-left win
for (i = 0; i < LINE_HEIGHT - 3; i++) {
for (j = LINE_WIDTH - 1; j >= 0; j--) {
if (grid[i][j] == grid[i + 1][j - 1] && grid[i][j] == grid[i + 2][j - 2] && grid[i][j] == grid[i + 3][j - 3] && grid[i][j] != 0) {
return player;
}
}
}
//No win
return 0;
}
When compiled the exe file is only 56.0KiB. So it's pretty much always on my USB drive now.
And here it is:
http://rapidshare.com/files/443141503/Connect4.txt
I don't think rapidshare likes exe files so once you download just change the file extension (txt) to exe, and it will work. Give it a go.
Looking back at this code there is not actually too many things I would do differently. Would've been a nice OO exercise though.
If anyone wants to give me a game just tell me your starting move. Let's play. Lol
Cheers,
Milk
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.
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.
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.
Labels:
beta,
Code,
command line,
generators,
jar,
java,
mi,
runnable,
screenshot,
tank,
tanks,
test,
upload
Thursday, 23 December 2010
Christmas Computer
So Christmas is coming up, and what better gift to receive then a new computer. Well I'm quite poor so rather then buying a new computer to give away, my mum decided we should format one of the old computers she has lying around. After all, they would only use the computer for the internet and Word.
Issue 0:
Find a screen that works, keyboard and mouse.
SOLVED
Issue 1:
Current OS Windows Vista Enterprise has expired. Enter product key. Cannot access command line, or anything helpful from here. Nothing helpful in the BIOS either. Must find a way to format the drive.
Attempt 0:
Luckily we had an old Windows XP Professional disk lying around. Put that in, goes half through through the install process and then decides it can't read the disk.
Due to the current OS being a later version it appears that the 'upgrade' is unable to go through. Error message only says please insert disk. Hmmm...
Attempt 1:
Luckily we also had a Windows 7 upgrade. Unfortunately the computer doesn't meet the system requirements. Which seem to be a huge step up from Vista. Not too surprising. The main reason people didn't like Vista was because their computers were good enough to run it properly. Somehow, this disk allowed us to get to the command line. Strange but we'll go with it.
SOLVED got to command line.
Issue 2:
Turns out the 20Gb harddrive is partitioned into 2 parts. Not helpful. I only want one clear partition.
Part 0:
Format C:, then format D:. That worked fine. Now finding some way to get rid of the partition.
Part 1:
Found a command DiskPart. Within this you are able to view each harddrive and the partitions etc.
SOLVED
DiskPart also has a clean command that zeroes the entire disk. I'll remember this.
Issue 3:
Now we need an OS to put on it.
Attempt 0:
Try that Windows XP disk again.
No luck. Must be a disk error.
Attempt 1:
Download Ubuntu 10.10.
Burn iso image to CD-RW using Windows 7 image burner. Very handy.
Boot from CD.
Now I'm in a bash command line.
After spending an hour on two on google searching this problem, I've found two solutions.
Unfortunately both of these require booting from disk and using bash from there.
As my problem is the disk command line, this isn't going to help. A lot of basic commands aren't found; sudo being one of them. This leaves me with very few options.
Attempt 2:
Download Ubuntu 9.04.
Burn image to disk.
Boot from disk.
Success!
Change some setting and clicked install.
Ubuntu is now formatting your harddrive... Well that's convenient.
SOLVED as an added bonus, Ubuntu comes with Open Writer. Sweet.
[Last edit: 201012231820]
Issue 0:
Find a screen that works, keyboard and mouse.
SOLVED
Issue 1:
Current OS Windows Vista Enterprise has expired. Enter product key. Cannot access command line, or anything helpful from here. Nothing helpful in the BIOS either. Must find a way to format the drive.
Attempt 0:
Luckily we had an old Windows XP Professional disk lying around. Put that in, goes half through through the install process and then decides it can't read the disk.
Due to the current OS being a later version it appears that the 'upgrade' is unable to go through. Error message only says please insert disk. Hmmm...
Attempt 1:
Luckily we also had a Windows 7 upgrade. Unfortunately the computer doesn't meet the system requirements. Which seem to be a huge step up from Vista. Not too surprising. The main reason people didn't like Vista was because their computers were good enough to run it properly. Somehow, this disk allowed us to get to the command line. Strange but we'll go with it.
SOLVED got to command line.
Issue 2:
Turns out the 20Gb harddrive is partitioned into 2 parts. Not helpful. I only want one clear partition.
Part 0:
Format C:, then format D:. That worked fine. Now finding some way to get rid of the partition.
Part 1:
Found a command DiskPart. Within this you are able to view each harddrive and the partitions etc.
>DiskPart
>list drive
'all drives are listed'
>select drive 0
>list partition
'all partitions listed, the C: of 8Gb (partition 0) and D: of 10Gb (partition 1).'
>select partition 1
'partition 1 selected'
>delete partition
>list partition
'now only the C: drive is shown of 8Gb. Where did my 10Gb go? Oh crap.'
--Restart computer.--
>DiskPart
>select drive 0
>list partition
'C: (partition 0) is now 18Gb. Phew...'SOLVED
DiskPart also has a clean command that zeroes the entire disk. I'll remember this.
Issue 3:
Now we need an OS to put on it.
Attempt 0:
Try that Windows XP disk again.
No luck. Must be a disk error.
Attempt 1:
Download Ubuntu 10.10.
Burn iso image to CD-RW using Windows 7 image burner. Very handy.
Boot from CD.
No init found. Try passing init= bootarg.
BusyBox v1.15.3 (Ubuntu 1:1.15.3-1ubuntu5) built-in shell (ash)
Enter 'help for a list of built-in commands.Now I'm in a bash command line.
After spending an hour on two on google searching this problem, I've found two solutions.
Unfortunately both of these require booting from disk and using bash from there.
As my problem is the disk command line, this isn't going to help. A lot of basic commands aren't found; sudo being one of them. This leaves me with very few options.
Attempt 2:
Download Ubuntu 9.04.
Burn image to disk.
Boot from disk.
Success!
Change some setting and clicked install.
Ubuntu is now formatting your harddrive... Well that's convenient.
SOLVED as an added bonus, Ubuntu comes with Open Writer. Sweet.
[Last edit: 201012231820]
Labels:
boot,
command line,
diskpart,
dos,
format,
formatting,
install,
linux,
partition,
unpartition,
vista,
windows,
xp
Subscribe to:
Posts (Atom)







