Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Poll

If a forum project for a game or other utility would YOU help in programing it or in other ways?

Yes - help with Programing
2 (50%)
Yes - help with Other things
0 (0%)
Mabye
1 (25%)
No
1 (25%)

Total Members Voted: 3

Voting closed: January 07, 2015, 01:04:14 PM

Author Topic: Batch Project  (Read 7561 times)

0 Members and 1 Guest are viewing this topic.

shiverbob

    Topic Starter


    Beginner

    Thanked: 1
    • Yes
  • Computer: Specs
  • Experience: Experienced
  • OS: Windows XP
Batch Project
« on: January 04, 2015, 01:04:14 PM »
I would like to start a project that involves the forum community. Before I do this I would like to know if people would like do it and prove that I am not a total idiot. Thanks for Your time anyway tho!
Pff computers are easy, math is hard.

DaveLembke



    Sage
  • Thanked: 662
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 10
Re: Batch Project
« Reply #1 on: January 04, 2015, 02:09:34 PM »
Curious of what project ideas you have?

Lemonilla



    Apprentice

  • "Too sweet"
  • Thanked: 70
  • Computer: Specs
  • Experience: Experienced
  • OS: Windows 7
Re: Batch Project
« Reply #2 on: January 04, 2015, 03:05:51 PM »
Depends on what the project is. I for one don't have a lot I can contribute to a large scale project as it will most likely not be written in batch, and my grasp on python and java is not sufficient to contribute anything meaningful.
Quote from: patio
God Bless the DOS Helpers...
Quote
If it compiles, send the files.

Squashman



    Specialist
  • Thanked: 134
  • Experience: Experienced
  • OS: Other
Re: Batch Project
« Reply #3 on: January 04, 2015, 04:17:38 PM »
Not sure why you or anyone else would think you are an idiot. If you want to start a batch program just post your ideas and some code and I am sure a lot of people will contribute their two cents if it peaks their interest.

patio

  • Moderator


  • Genius
  • Maud' Dib
  • Thanked: 1769
    • Yes
  • Experience: Beginner
  • OS: Windows 7
Re: Batch Project
« Reply #4 on: January 04, 2015, 07:51:17 PM »
Why the Poll ? ?

Just curious...
" Anyone who goes to a psychiatrist should have his head examined. "

Calum

  • Moderator


  • Egghead

    Thanked: 238
    • Yes
    • Yes
  • Certifications: List
  • Computer: Specs
  • Experience: Beginner
  • OS: Other
Re: Batch Project
« Reply #5 on: January 05, 2015, 01:03:44 AM »

foxidrive



    Specialist
  • Thanked: 268
  • Experience: Experienced
  • OS: Windows 8
Re: Batch Project
« Reply #6 on: January 05, 2015, 11:25:32 AM »
If you want to start a batch program just post your ideas and some code and I am sure a lot of people will contribute their two cents if it peaks their interest.

Me agree. 

shiverbob

    Topic Starter


    Beginner

    Thanked: 1
    • Yes
  • Computer: Specs
  • Experience: Experienced
  • OS: Windows XP
Re: Batch Project
« Reply #7 on: January 06, 2015, 08:01:36 PM »
I don't why the poll, just guessed it would help some how. Anyway I didn't come into this with any ideas. But now since you mentioned it I thought of a few like, advance Calculator, a city builder, a space adventure, a batch file manager. An since this is the first really new thing I tried on this forum. Maybe these projects could be written in multiple languages, via C++, python and java. Plus if multiple people help, some people might not need to speed massive amounts of time. The code of these projects could range from 20 to 1000.

So that's all the questions I saw, but the reason I didn't post some code, was I didn't have any. Other people can come up with more ideas then I can. And If anyone wanders why, I am very bored after school and practice, so i want to help people and program random things.

Thanks for all the feedback anyway!,
Shiverbob
Pff computers are easy, math is hard.

Squashman



    Specialist
  • Thanked: 134
  • Experience: Experienced
  • OS: Other
Re: Batch Project
« Reply #8 on: January 06, 2015, 08:09:36 PM »
Maybe these projects could be written in multiple languages, via C++, python and java.
Then post in the Computer Programming forum category.

I am very bored after school and practice
Then help out on multiple forums.  There are tons of them out there.  I probably post on about 6 different forums.

Lemonilla



    Apprentice

  • "Too sweet"
  • Thanked: 70
  • Computer: Specs
  • Experience: Experienced
  • OS: Windows 7
Re: Batch Project
« Reply #9 on: January 07, 2015, 06:50:19 PM »
a space adventure

Here's a start.  I don't think I commented everything, but you should be able to figure it out.  Every file other than launcher.bat should be in a folder named "bin".  The files with names like this "filename." have no extension and shouldn't be saved with one.  They are simply text files, but I was lazy and decided I didn't want to write .txt every time I used them.  Post if I missed a file.

Code: (launcher.bat) [Select]
:: Launches the game.  Displays the controls found
:: in the controls file.

@echo off

cd bin
for /f "delims=" %%A in (controls) do set %%A

echo.
echo.controls
echo.
echo.  %move_+_y_theta% = + y theta
echo.  %move_-_y_theta% = - y theta
echo.  %move_+_x_theta% = + x theta
echo.  %move_-_x_theta% = - x theta
echo.  %move_+_vel% = + vel
echo.  %move_-_vel% = - vel
echo.  %move_ping% = ping
echo.  %move_quit% = quit
echo.
pause

call master.bat

====================BIN====================

Code: (cont.bat) [Select]
:: Waits for user input and writes it to the cmd file.
:: Closes upon finding the contr file, created by cmd.bat
:: when the exit command is found.

setlocal enableDelayedExpansion
for /f %%a in ('copy /Z "%~dpf0" nul') do set "CR=%%a"
set "key="
for /l %%. in () do (
set "key="
for /f "delims=" %%A in ('xcopy /w %~f0 %~f0 2^>nul') do if not defined key set "key=%%A"
set key=!key:~-1!
echo !key!>cmd
if exist contr exit
)
Code: (com.bat) [Select]
:: Checks file cmd generated by cont.bat for which command to execute
:: and then executes that command.  Uses values in controls file for
:: key to commnand bindings.

setlocal EnableDelayedExpansion

set /p cmd=<cmd
set /p pos_x=<pos_x
set /p pos_y=<pos_y
set /p pos_z=<pos_z
set /p vel=<vel
set /p theta_y=<theta_y
set /p theta_x=<theta_x
for /f "delims=" %%A in (controls) do set %%A

if "%cmd%"=="." goto :end

if /i "%cmd%"=="%move_+_y_theta%" (
set /a theta_y+=%delta_theta%
echo !theta_y!>theta_y
)
if /i "%cmd%"=="%move_-_y_theta%" (
set /a theta_y-=%delta_theta%
echo !theta_y!>theta_y
)
if /i "%cmd%"=="%move_+_x_theta%" (
set /a theta_x+=%delta_theta%
echo !theta_x!>theta_x
)
if /i "%cmd%"=="%move_-_x_theta%" (
set /a theta_x-=%delta_theta%
echo !theta_x!>theta_x
)
if /i "%cmd%"=="%move_+_vel%" (
set /a vel+=1
echo !vel!>vel
)
if /i "%cmd%"=="%move_-_vel%" (
set /a vel-=1
echo !vel!>vel
)
if /i "%cmd%"=="%move_ping%" call ping.bat
if /i "%cmd%"=="%move_quit%" (
echo .>contr
timout /t 1 /nobreak >nul
exit
)

echo .>cmd

:end
Code: (disp.bat) [Select]

REM load data
set /p pos_x=<pos_x
set /p pos_y=<pos_y
set /p pos_z=<pos_z
set /p vel=<vel
set /p theta_y=<theta_y
set /p theta_x=<theta_x
set /p turn=<turn
for /f "delims=" %%A in (settings) do set %%A


if not exist last goto :disp
for /f "delims=" %%A in (last) do set l_%%A
if "%pos_x: =%"=="%l_pos_x: =%" (
if "%pos_y: =%"=="%l_pos_y: =%" (
if "%pos_z: =%"=="%l_pos_z: =%" (
if "%vel: =%"=="%l_vel: =%" (
if "%theta_x: =%"=="%l_theta_x: =%" (
if "%theta_y: =%"=="%l_theta_y: =%" (
if not "%display%"=="1" goto :end
))))))
:disp
cls
echo.
echo.  Possition: [%pos_x: =%],[%pos_y: =%],[%pos_z: =%]
echo.  Direction: y [%theta_y: =%], x [%theta_x: =%]
echo.  Velocity : [%vel: =%]
echo.
if "%display%"=="1" (
if exist v_grav type v_grav
echo.
)
:end
Code: (grav.bat) [Select]
:: apply gravity by calling grav.vbs

set /p pos_x=<pos_x
set /p pos_y=<pos_y
set /p pos_z=<pos_z
for /f "delims=" %%A in (settings) do set %%A

cscript //nologo grav.vbs "%cd%\planets" %pos_x% %pos_y% %pos_z% "%cd%" "%wvec_lim%" 1>v_grav
Code: (controls.) [Select]
move_+_y_theta=w
move_-_y_theta=s
move_+_x_theta=d
move_-_x_theta=a
move_+_vel=o
move_-_vel=l
move_ping=p
move_quit=t
diplay_ex=g
Code: (land.bat) [Select]
:: Displays crash information and
:: calls reset for a new game.

set /p planet=<crashrep
for /f "tokens=1-4 delims=," %%A in (planets) do (
if "%%D"=="%planet%" (
echo %%A >pos_x
echo %%B >pos_y
echo %%C >pos_z
)
)

if /i "%planet%"=="earth" call win.bat
call disp.bat

echo You've landed on %planet%
echo.
echo Press G to explore. . .

:l
if exist cmd set /p cmd=<cmd
if /i not "%cmd%"=="g" goto :l
echo .>cmd

call planet.bat
Code: (master.bat) [Select]
:: The master file that calls all other components.
:: Loops forever, always reading the cmd file for
:: commands to execute.

@echo off
if exist last del last
if exist contr del contr
if exist turn set /p turn=<turn
if "%~1"=="l" goto :l

start /b cmd /c cont.bat 2>nul 1>&2
cmd /c ^""%~f0" l ^"
rem ^<nul
exit /b 0


:l

REM setup Var
set cmd=.
if exist cmd (
set /p cmd=<cmd
) else (
echo . >cmd
)

REM Start moving
call mov.bat

REM read commands
call com.bat

REM start view
call disp.bat

REM apply gravity
call grav.bat

REM check crash
call chkcrsh.bat

REM wait
timeout /t 1 /nobreak >nul

goto :l
Code: (mov.bat) [Select]
:: Changes ship position through the use of pt.vbs

set /p pos_x=<pos_x
set /p pos_y=<pos_y
set /p pos_z=<pos_z
set /p vel=<vel
set /p theta_y=<theta_y
set /p theta_x=<theta_x

cscript //nologo pt.vbs "%vel%" "%theta_x%" "%theta_y%" "%cd%\Pos_x" "%cd%\Pos_y" "%cd%\Pos_z" "%pos_x%" "%pos_y%" "%pos_z%"
Code: (planet.bat) [Select]
:: Displays information on current planet you are on.
:: Also allows for takeoff.

set /p pos_x=<pos_x
set /p pos_y=<pos_y
set /p pos_z=<pos_z
set /p vel=<vel
set /p theta_y=<theta_y
set /p theta_x=<theta_x
set /p planet=<crashrep

:: chart planet on map
echo %planet% >chart


call disp.bat
type "..\desc\%planet%"
echo.
echo.
echo Press G to leave planet. . .

:l
if exist cmd set /p cmd=<cmd
if /i not "%cmd%"=="g" goto :l
echo .>cmd

set /a pos_x+=5
set /a pos_y+=5
set /a pos_z+=5

rem echo 1 >vel
echo %pos_x% >pos_x
echo %pos_y% >pos_y
echo %pos_z% >pos_z

del crashrep
Code: (planets.) [Select]
0,0,0,0,0,0,0,0, How to read: x,y,z,name,danger,grav,bound_sun_name
0,0,0,0,0,0,0,0,   danger 0 = can't land, 1 = can safely land, 2 = crash
0,0,0,0,0,0,0,0,   bound_sun_name=0 if self bound
0,0,0,0,0,0,0,0,   smaller the grav the harder the pull
0,0,0,0,0,0,0,0, 1 pt ~ 100,000 miles
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0, Sol System
0,0,0,0,0,0,0,0,
390000,470000,-38000,Sol,2,1,0
390000,470360,-37900,Mercury,1,50,Sol
390600,470070,-38100,Venus,1,30,Sol
390629,469700,-38070,Earth,1,10,Sol
388584,470000,-38030,Mars,1,10,Sol
394000,470836,-37970,Jupiter,0,5,Sol
381118,469990,-38000,Saturn,0,7,Sol
372136,469900,-37920,Uranus,0,20,Sol
390000,442012,-38000,Neptune,0,20,Sol
426662,470000,-40000,Pluto,1,100,Sol
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0, Elbei/Ambon System
0,0,0,0,0,0,0,0,
-950,-950,11,Elbei/Ambon,0,0,0
-1000,-1000,10,Elbei,2,2,Elbei/Ambon
-900,-900,12,Ambon,2,2,Elbei/Ambon
10,10,100,Abron,1,10,Elbei/Ambon
-150,-150,50,Upien,0,15,Elbei/Ambon
Code: (grav.vbs) [Select]
' grav "%cd%\planets" %pos_x% %pos_y% %pos_z% "%cd%" %wvec_lim%
'
' Applies gravity for each planet withing range.  Uses wvec_lim variable
' from files settings to determine range.  if dis/grav < wvrc_lim then
' gravity is applied. Value of grav is taken from file settings as well.

dim x,y,z,working_x,working_y,working_z,dis,wvec,vec_x,vec_y,vec_z,x1,y1,z1,grav,wvec_lim,planets,name
dim file,fso,listFile,line,arrline
file=Wscript.Arguments(0)
x=Wscript.Arguments(1)
y=Wscript.Arguments(2)
z=Wscript.Arguments(3)
cd1=Wscript.Arguments(4)
wvec_lim=CSng(Wscript.Arguments(5))
vec_x=0
vec_y=0
vec_z=0


' Loop through planets list
Set fso = CreateObject("Scripting.FileSystemObject")
Set listFile = fso.OpenTextFile(file)
do while not listFile.AtEndOfStream
line =  listFile.ReadLine()


' setup variables
arrline=Split(line,",")
working_x=arrline(0)
working_y=arrline(1)
working_z=arrline(2)
name=arrline(3)
grav=arrline(5)

' Ignore all planets with 0 gravity
' These are comments in the file
If grav <> 0 Then

'find distance
dis=Sqr((x-working_x)*(x-working_x)+(y-working_y)*(y-working_y)+(z-working_z)*(z-working_z))
wvec=dis/grav

Wscript.echo name &" | "& round(wvec,2)


'determine adding
If wvec < wvec_lim Then

' Find Vector length
if dis=0 then dis=.0000001
x1=round(((working_x-x)/dis/grav),2)
y1=round(((working_y-y)/dis/grav),2)
z1=round(((working_z-z)/dis/grav),2)

' Display Data
Wscript.echo " "&x1&" "&y1&" "&z1

' Add vector length to sum
vec_x=vec_x+x1
vec_y=vec_y+y1
vec_z=vec_z+z1

End If
End If
Loop

' Make corrections on possition
x=x+vec_x
y=y+vec_y
z=z+vec_z

' Write to Files
set objFSO=CreateObject("Scripting.FileSystemObject")
outFile=cd & "pos_x"
Set objFile = objFSO.CreateTextFile(outFile,True)
objFile.Write x & vbCrLf
objFile.Close

outFile=cd & "pos_y"
Set objFile = objFSO.CreateTextFile(outFile,True)
objFile.Write y & vbCrLf
objFile.Close

outFile=cd & "pos_z"
Set objFile = objFSO.CreateTextFile(outFile,True)
objFile.Write z & vbCrLf
objFile.Close
Code: (pt.vbs) [Select]
' cscript //nologo pt.vbs "%vel%" "%theta_x%" "%theta_y%" "%cd%\Pos_x" "%cd%\Pos_y" "%cd%\Pos_z" "%pos_x%" "%pos_y%" "%pos_z%"
'
' x = vel * cos(theta_x) * cos(theta_y)
' y = vel * cos(theta_x) * sin(theta_y)
' z = vel * sin(theta_x)
'
' Changes the position of the ship by using theta_x, theta_y, and vel to
' determine the end point of that movement.  Is applied before gravity.


dim x,y,z,vel,xTheta,yTheta,cd1,cd2,cd3,px,py,pz,log,pi
vel = Wscript.Arguments(0)
xTheta = Wscript.Arguments(1)
yTheta = Wscript.Arguments(2)
cd1 = Wscript.Arguments(3)
cd2 = Wscript.Arguments(4)
cd3 = Wscript.Arguments(5)
px = Wscript.Arguments(6)
py = Wscript.Arguments(7)
pz = Wscript.Arguments(8)
pi = 4 * ATN(1)

' convert degree's to radians
xTheta = xTheta * pi / 180
yTheta = yTheta * pi / 180


x = round((vel*cos(yTheta)*cos(xTheta)),2)+px
z = round((vel*cos(yTheta)*sin(xTheta)),2)+pz
y = round((vel*sin(yTheta)),2)+py


set objFSO=CreateObject("Scripting.FileSystemObject")
outFile=cd1
Set objFile = objFSO.CreateTextFile(outFile,True)
objFile.Write x & vbCrLf
objFile.Close

outFile=cd2
Set objFile = objFSO.CreateTextFile(outFile,True)
objFile.Write y & vbCrLf
objFile.Close

outFile=cd3
Set objFile = objFSO.CreateTextFile(outFile,True)
objFile.Write z & vbCrLf
objFile.Close
Code: (reset.bat) [Select]
:: Resets the game.  Does not call any other functions.

if exist contr del contr
if exist last del last
if exist turn del turn
if exist cmd del cmd
if exist crashrep del crashrep

echo 0 >pos_x
echo 0 >pos_y
echo 0 >pos_z
echo 0 >vel
echo 0 >theta_x
echo 0 >theta_y
echo 0 >turn
:: echo delta_theta=10 >settings
:: echo delay=50 >>settings
:: echo grav=1 >>settings
echo vel=0 >last
echo .>cmd
Code: (settings.) [Select]
delta_theta=10
delay=50
display=1
wvec_lim=2
crash=1
Code: (chkcrsh.vbs) [Select]
' chkcrsh.vbs "%cd%" %pos_x% %pos_y% %pos_z% "%cd%\planets" "%cd%\crashrep"
'
' Checks for possition conflict between ship and the planets found in the planets file.

dim x,y,z,working_x,working_y,working_z,cd,errorlevel,file,arrline,cd1,lastX,lastY,lastZ,working_name,line,listFile

errorlevel=0
cd=Wscript.Arguments(0)
x=round(Wscript.Arguments(1),0)
y=round(Wscript.Arguments(2),0)
z=round(Wscript.Arguments(3),0)
file=Wscript.Arguments(4)
cd1=Wscript.Arguments(5)

Set fso = CreateObject("Scripting.FileSystemObject")
Set listFile = fso.OpenTextFile(file)
do until listFile.AtEndOfStream
line = listFile.ReadLine()

'setup variables
arrline=Split(line,",")
working_x=round(arrline(0),0)
working_y=round(arrline(1),0)
working_z=round(arrline(2),0)
working_name=arrline(3)
working_dang=arrline(4)

if x=working_x then
if y=working_y then
if z=working_z then
if working_dang <> 0 Then
set objFSO=CreateObject("Scripting.FileSystemObject")
outFile=cd1
Set objFile = objFSO.CreateTextFile(outFile,True)
objFile.Write working_name & vbCrLf
objFile.Close
end if
end if
end if
end if
loop
Code: (com.bat) [Select]
:: Checks file cmd generated by cont.bat for which command to execute
:: and then executes that command.  Uses values in controls file for
:: key to commnand bindings.

setlocal EnableDelayedExpansion

set /p cmd=<cmd
set /p pos_x=<pos_x
set /p pos_y=<pos_y
set /p pos_z=<pos_z
set /p vel=<vel
set /p theta_y=<theta_y
set /p theta_x=<theta_x
for /f "delims=" %%A in (controls) do set %%A

if "%cmd%"=="." goto :end

if /i "%cmd%"=="%move_+_y_theta%" (
set /a theta_y+=%delta_theta%
echo !theta_y!>theta_y
)
if /i "%cmd%"=="%move_-_y_theta%" (
set /a theta_y-=%delta_theta%
echo !theta_y!>theta_y
)
if /i "%cmd%"=="%move_+_x_theta%" (
set /a theta_x+=%delta_theta%
echo !theta_x!>theta_x
)
if /i "%cmd%"=="%move_-_x_theta%" (
set /a theta_x-=%delta_theta%
echo !theta_x!>theta_x
)
if /i "%cmd%"=="%move_+_vel%" (
set /a vel+=1
echo !vel!>vel
)
if /i "%cmd%"=="%move_-_vel%" (
set /a vel-=1
echo !vel!>vel
)
if /i "%cmd%"=="%move_ping%" call ping.bat
if /i "%cmd%"=="%move_quit%" (
echo .>contr
timout /t 1 /nobreak >nul
exit
)

echo .>cmd

:end
Code: (chkcrsh.bat) [Select]
:: Checks for a conflict in possition with ship and any planets
:: calls upon chkcrsh.vbs for math and comparison.

set crashrep=
set /p pos_x=<pos_x
set /p pos_y=<pos_y
set /p pos_z=<pos_z
set /p vel=<vel

cscript //nologo chkcrsh.vbs "%cd%" %pos_x% %pos_y% %pos_z% "%cd%\planets" "%cd%\crashrep"


REM for after planet based movement is possable
if exist crashrep if %vel% GTR 0 call crash.bat
if exist crashrep if %vel% EQU 0 call land.bat

*I used dbenham's snake game to write cont.bat, he gets all credit for the controls input technique.
Quote from: patio
God Bless the DOS Helpers...
Quote
If it compiles, send the files.

foxidrive



    Specialist
  • Thanked: 268
  • Experience: Experienced
  • OS: Windows 8
Re: Batch Project
« Reply #10 on: January 07, 2015, 09:23:27 PM »
Here's a start.    Post if I missed a file.

Just a suggestion:

It would aid people to get this, with no typos and saving errors, if you could attach a zip file with the entire shebang.


Lemonilla



    Apprentice

  • "Too sweet"
  • Thanked: 70
  • Computer: Specs
  • Experience: Experienced
  • OS: Windows 7
Re: Batch Project
« Reply #11 on: January 08, 2015, 08:11:52 AM »
Just a suggestion:

It would aid people to get this, with no typos and saving errors, if you could attach a zip file with the entire shebang.
>.< Now I feel stupid.  Here's the file.

[attachment deleted by admin to conserve space]
Quote from: patio
God Bless the DOS Helpers...
Quote
If it compiles, send the files.

camerongray



    Expert
  • Thanked: 306
    • Yes
    • Cameron Gray - The Random Rambings of a Computer Geek
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Mac OS
Re: Batch Project
« Reply #12 on: January 08, 2015, 09:36:15 AM »
If you want to properly collaborate on a project together, use a hosted version control system such as Github.  It will make managing changes and who did what much easier than copying and pasting code in a forum post.  Each person can then fork the repo, make the changes they want and then submit a pull request.

Lemonilla



    Apprentice

  • "Too sweet"
  • Thanked: 70
  • Computer: Specs
  • Experience: Experienced
  • OS: Windows 7
Re: Batch Project
« Reply #13 on: January 09, 2015, 07:06:26 PM »
Well, never (successfully) used github before, but here it is.  I plan on continuing this alone anyway and should probably get into the habit of backing my stuff up more often.
Quote from: patio
God Bless the DOS Helpers...
Quote
If it compiles, send the files.

camerongray



    Expert
  • Thanked: 306
    • Yes
    • Cameron Gray - The Random Rambings of a Computer Geek
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Mac OS
Re: Batch Project
« Reply #14 on: January 16, 2015, 06:49:00 PM »
Looking good so far!  Just remember, commit little, commit often.

Github is also great since if you end up going for a job that will involve some sort of programming, it can act as a CV of sorts.