Programming Interoffice Memorandum Question

Description

4 attachmentsSlide 1 of 4attachment_1attachment_1attachment_2attachment_2attachment_3attachment_3attachment_4attachment_4

Unformatted Attachment Preview

Contents
Overall Report Format ………………………………………………………………………………………………………………… 2
Project 1: Run the OpenCV circle detection code……………………………………………………………………………. 3
Aim ………………………………………………………………………………………………………………………………………. 3
Expected content of the Project 1 section of your report ………………………………………………………………. 3
The Circle Detection Code……………………………………………………………………………………………………….. 3
Project 2: Your Bot!……………………………………………………………………………………………………………………. 4
Review ………………………………………………………………………………………………………………………………….. 4
Create your first Robocode Bot ………………………………………………………………………………………………… 4
Learning Simulations ………………………………………………………………………………………………………………. 5
Overall Report Format
File name should follow the guide in the Syllabus and be submitted as a PDF. The format should
make us of the MEMO format, including all proper content of the header and requested Sections.
Specifically, make use of the LaTeX memo template available in the LaTeX module in
CANVAS. The Body of your memo should address the following learning outcomes:







Python scripting
Python code troubleshooting
Python based image analysis algorithms
Working with directories when coding
Creation of a Java based package
Serious gas simulations
Conceptualization of code-based outcomes given game constraints
Project 1: Run the OpenCV circle detection code
Aim You should be able to run the circle detection algorithm provided to show detected circles
in an image. For this, please run the detection algorithm on 1 image and present the results. This
assignment will require code editing and problem solving to achieve the desired outcome, do
NOT expect the copy paste to work “out of the box”, and as such begin attempting the
assignment early!
Expected content of the Project 1 section of your report
1. The image you have decided to try to detect circles in, DO NOT USE project 1’s image,
it should be your own. This image should be pasted into the report and MUST include a
figure caption that briefly describes what is in the image and what you expect the
algorithm to detect.
2. A COPY-PASTE AND SCREENSHOT of your final code including lines where you call
and import your desired image file, if you are worried about showing computer paths you
should put the image file in the same folder as the script or in a subdirectory of this same
folder, that way you do not need to reference a full file path.
3. The image with detected circles overlayed, this can either be a screenshot of the code
running or an output file pasted into the report. The script is currently set to show the
image but not save it, if you want to use the save option then you will should reference
OpenCV’s documentation. This MUST also include a figure caption that describes what
was actually detected, and how it differed from your expectations in (1).
Extra Credit: +10pts, use your circle detection algorithm on a photo of a coin that you can find
the diameter of, detect its radius and attempt to find a conversion value of pixels (the output of
the algorithm) and physical length (the known radius of the coin). This should include:



The image of the coin with a circle overlay
The printout of the radius value of this circle in pixels
The conversion factor found in units of mm/pixel
The Circle Detection Code
Code source: https://www.geeksforgeeks.org/circle-detection-using-opencv-python/
import cv2
import numpy as np
# Read image.
img = cv2.imread(‘eyes.jpg’, cv2.IMREAD_COLOR)
# Convert to grayscale.
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# Blur using 3 * 3 kernel.
gray_blurred = cv2.blur(gray, (3, 3))
# Apply Hough transform on the blurred image.
detected_circles = cv2.HoughCircles(gray_blurred, cv2.HOUGH_GRADIENT,
1, 20, param1 = 50, param2 = 30, minRadius = 1, maxRadius = 40)
# Draw circles that are detected.
if detected_circles is not None:
# Convert the circle parameters a, b and r to integers.
detected_circles = np.uint16(np.around(detected_circles))
for pt in detected_circles[0, :]:
a, b, r = pt[0], pt[1], pt[2]
# Draw the circumference of the circle.
cv2.circle(img, (a, b), r, (0, 255, 0), 2)
# Draw a small circle (of radius 1) to show the center.
cv2.circle(img, (a, b), 1, (0, 0, 255), 3)
cv2.imshow(“Detected Circle”, img)
cv2.waitKey(0)
Project 2: Your Bot!
Review
To date you have: 1) installed the capability of your computer to work with Java (a high-level,
class-based, object-oriented programming language), 2) installed a software program that makes
use of java for a serious game (Robocode), 3) set up simulations with Robocode, and 4) learned
how to move ‘bot’ packages into Robocode for setting up a serious game simulation. Next you
will create your own ‘bot’ for simulations in a Robocode environment.
Create your first Robocode Bot
1. Set up your first bot by following the basic Robocode Wiki instructions (a separate .pdf file:
1stBot.pdf is also available in Canvas):
https://robowiki.net/wiki/Robocode/My_First_Robot
Learning Simulations
Part of coding and improving upon computer code is to observe how code performs. The
following points allow you to test your newly created bot against existing programs. By
observing better and worse performing code, you should be able to conceptualize coding that
would improve performance of your own bot. The following exercises provide for metrics in an
to an observational environment.
2. Test your bot against the sample robot ‘Sitting Duck’, take a screen shot of the results (10
battles – example below). NOTE: your bot should win this battle, if it doesn’t, there is a
problem!
3. Run a simulation with 8 to 10 different bots (not including your own). Take a screen shot of
the results (10 battles – example below).
4. Run a simulation with the four worst performing bots from 3., with your bot. Take a screen
shot of the results (10 battles – example below).
5. Run a simulation with the four next best performing bots from 3., with your bot. Take a
screen shot of the results (10 battles).
6. From 4. And 5. Did other bots perform better than yours? If so, list their name(s) and
describe the behaviors, actions, and apparent strategy that led them to win.
7. Recall that the three fundamental aspects of your bot comprise: a) radar, b) movement, and c)
targeting. What type of behavior could you implement with your bot that would improve its
results? Did you notice if any of the other bots could be used to help develop your own
strategy? Describe a strategy you could use to improve your bot. Be descriptive, reference the
fundamental aspects and how you would change them.
Your First Robot
https://robowiki.net/wiki/Robocode/My_First_Robot
Getting started
Ready to create your first robot? I hope you’ll find that it’s easy, straightforward, fun, and addictive!
Robocode ships with a number of sample robots that you can look at for ideas, and to see how
things work. You can use the Robot Editor to look at all of them.
In this section, we’ll use the Robot Editor to create your very own, brand-new robot.
The Robot Editor
The new-robot dialog
The first step is to open up the Robot Editor. From the main Robocode screen, click on
the Robot menu, then select Source Editor.
Your First Robot
https://robowiki.net/wiki/Robocode/My_First_Robot
When the editor window comes up, click on the File menu, then select New Robot.
In the dialogs that follow, type in a name for your robot, and enter your initials.
Voila! You now see the code for your own robot.
A new robot
Editing your new robot
This is what you should be looking at:
1 package pkg;
2
3 import robocode.*;
4
5 public class YourRobotNameHere extends Robot {
6
public void run() {
7
while (true) {
8
ahead(100);
Your First Robot
9
10
11
12
13
14
15
16
17
18 }
https://robowiki.net/wiki/Robocode/My_First_Robot
turnGunRight(360);
back(100);
turnGunRight(360);
}
}
public void onScannedRobot(ScannedRobotEvent e) {
fire(1);
}
We’re only concerned with lines 8-11 and 16 here… you won’t need to change anything else. Not
that much, right?
By the way, if you’re really concerned about the rest of it, here it is:

import robocode.*; ‒ Says that you’re going to use Robocode objects in your robot.

public class MyFirstRobot extends Robot ‒ Says the object I’m describing here
is a type of Robot , named MyFirstRobot .

public void run() { … } ‒ The game calls your run() method when the battle
begins.
{ … } ‒ “Curly brackets” ( { } ) group things together. In this case, they’re grouping
together all the code for the robot.

Let’s move somewhere
Let’s add a couple lines so that it will do something.
First, we’ll examine the run() method:
while(true) {
ahead(100);
turnGunRight(360);
back(100);
turnGunRight(360);
}
while(true) { … } means: “Do the stuff inside my curly brackets, forever”.
So this robot will:
1.
2.
3.
4.
Move ahead 100 pixels.
Turn the gun right by 360 degrees.
Move back 100 pixels.
Turn the gun right by 360 degrees again.
The robot will continue doing this over and over and over, until it dies, due to
the while(true) statement.
Not so bad, right?
Your First Robot
https://robowiki.net/wiki/Robocode/My_First_Robot
Fire at will!
When our radar scans a robot, we want to fire:
public void onScannedRobot(ScannedRobotEvent e) {
fire(1);
}
The game calls your onScannedRobot() method whenever ‒ during one of the actions ‒ you see
another robot. It sends along an event that can tell us lots of information about the robot ‒ its name,
how much life it has, where it is, where it’s heading, how fast it’s going, etc.
However, since this is a simple robot, we’re not going to look at any of that stuff. Let’s just fire!
Compile your robot
First, save your robot by selecting the Save in the File menu. Follow the prompts to save your robot.
Now, compile it by selecting Compile in the Compiler menu.
If your robot compiles without any errors, you can start a new battle with your robot. Start a new
battle by selecting New in the Battle menu. (If you cannot see your robot, you might have to refresh
the list of robots by selecting Options -> Clean robot cache). Add your robot to the battle together
with at least one other robot as e.g. sample.Target, and press the Start Battle button to let the
games begin!
What’s next?
You should have a look at all the sample robots to see how certain things are done.
After you have gotten used to Robocode, you will probably want to switch your robot to
an AdvancedRobot . Read the FAQ to learn what that is.
After that, you’ll have to decide whether your bot will be a 1v1 bot (a duelist), or a melee bot (fights
multiple opponents). One-on-one bots are simpler, and you’ll want to start with them.
You’ll eventually want to look at the Robocode API to see all the other things your robot can do.
Above all, good luck, have fun, and enjoy!
Your First Robot
https://robowiki.net/wiki/Robocode/My_First_Robot
Going Deeper
With a basic robot functioning, now its time to improve upon its ability in a serious game.
The three basic components of any robot include:

Radar, Movement, and Targeting.
Additional Tutorials
To better understand how to implement code that results in better serious game outcomes, consider
the list of tutorials as part of the Robocode Wiki!
https://robowiki.net/wiki/Tutorials
INTEROFFICE MEMORANDUM
TO:
FROM:
DATE:
RE:
INTRODUCTION:
BODY:
CONCLUSION:

Purchase answer to see full
attachment

Tags:
R code

Interoffice Memorandum

Louisiana Programming

coding paper

User generated content is uploaded by users for the purposes of learning and should be used following Studypool’s honor code & terms of service.

Reviews, comments, and love from our customers and community:

Article Writing

Keep doing what you do, I am really impressed by the work done.

Alexender

Researcher

PowerPoint Presentation

I am speechless…WoW! Thank you so much!

Stacy V.

Part-time student

Dissertation & Thesis

This was a very well-written paper. Great work fast.

M.H.H. Tony

Student

Annotated Bibliography

I love working with this company. You always go above and beyond and exceed my expectations every time.

Francisca N.

Student

Book Report / Review

I received my order wayyyyyyy sooner than I expected. Couldn’t ask for more.

Mary J.

Student

Essay (Any Type)

On time, perfect paper

Prof. Kate (Ph.D)

Student

Case Study

Awesome! Great papers, and early!

Kaylin Green

Student

Proofreading & Editing

Thank you Dr. Rebecca for editing my essays! She completed my task literally in 3 hours. For sure will work with her again, she is great and follows all instructions

Rebecca L.

Researcher

Critical Thinking / Review

Extremely thorough summary, understanding and examples found for social science readings, with edits made as needed and on time. Transparent

Arnold W.

Customer

Coursework

Perfect!

Joshua W.

Student

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>